aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSerj Kalichev <serj.kalichev@gmail.com>2013-11-21 10:44:15 +0400
committerH. Peter Anvin <hpa@zytor.com>2014-03-13 19:58:33 -0700
commit7c5efd0977a567296573b09b6436b8ffbcd369ee (patch)
treeab9c2b5abf5e48ed937a492e285fa057986cb1bc
parent386b59e18deb2e759c14ecdcaab8a4b589a3ad63 (diff)
downloadsyslinux-7c5efd0977a567296573b09b6436b8ffbcd369ee.tar.gz
syslinux-7c5efd0977a567296573b09b6436b8ffbcd369ee.tar.xz
syslinux-7c5efd0977a567296573b09b6436b8ffbcd369ee.zip
FSUUID for ext2 filesystem
The ext2 filesystem supports volume UUID now. The FSUUID variable can be set to kernel command line. Patch is based on FSUUID for FAT patch. Signed-off-by: Serj Kalichev <serj.kalichev@gmail.com> Signed-off-by: H. Peter Anvin <hpa@zytor.com>
-rw-r--r--core/fs/ext2/ext2.c40
-rw-r--r--core/fs/ext2/ext2_fs.h1
2 files changed, 40 insertions, 1 deletions
diff --git a/core/fs/ext2/ext2.c b/core/fs/ext2/ext2.c
index df0856ff..76bd1d5a 100644
--- a/core/fs/ext2/ext2.c
+++ b/core/fs/ext2/ext2.c
@@ -312,6 +312,9 @@ static int ext2_fs_init(struct fs_info *fs)
sbi->s_first_data_block = sb.s_first_data_block;
sbi->s_inode_size = sb.s_inode_size;
+ /* Volume UUID */
+ memcpy(sbi->s_uuid, sb.s_uuid, sizeof(sbi->s_uuid));
+
/* Initialize the cache, and force block zero to all zero */
cache_init(fs->fs_dev, fs->block_shift);
cs = _get_cache_block(fs->fs_dev, 0);
@@ -321,6 +324,41 @@ static int ext2_fs_init(struct fs_info *fs)
return fs->block_shift;
}
+#define EXT2_UUID_LEN (4 + 4 + 1 + 4 + 1 + 4 + 1 + 4 + 1 + 4 + 4 + 4 + 1)
+static char *ext2_fs_uuid(struct fs_info *fs)
+{
+ char *uuid = NULL;
+
+ uuid = malloc(EXT2_UUID_LEN);
+ if (!uuid)
+ return NULL;
+
+ if (snprintf(uuid, EXT2_UUID_LEN,
+ "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x",
+ EXT2_SB(fs)->s_uuid[0],
+ EXT2_SB(fs)->s_uuid[1],
+ EXT2_SB(fs)->s_uuid[2],
+ EXT2_SB(fs)->s_uuid[3],
+ EXT2_SB(fs)->s_uuid[4],
+ EXT2_SB(fs)->s_uuid[5],
+ EXT2_SB(fs)->s_uuid[6],
+ EXT2_SB(fs)->s_uuid[7],
+ EXT2_SB(fs)->s_uuid[8],
+ EXT2_SB(fs)->s_uuid[9],
+ EXT2_SB(fs)->s_uuid[10],
+ EXT2_SB(fs)->s_uuid[11],
+ EXT2_SB(fs)->s_uuid[12],
+ EXT2_SB(fs)->s_uuid[13],
+ EXT2_SB(fs)->s_uuid[14],
+ EXT2_SB(fs)->s_uuid[15]
+ ) < 0) {
+ free(uuid);
+ return NULL;
+ }
+
+ return uuid;
+}
+
const struct fs_ops ext2_fs_ops = {
.fs_name = "ext2",
.fs_flags = FS_THISIND | FS_USEMEM,
@@ -336,5 +374,5 @@ const struct fs_ops ext2_fs_ops = {
.readlink = ext2_readlink,
.readdir = ext2_readdir,
.next_extent = ext2_next_extent,
- .fs_uuid = NULL,
+ .fs_uuid = ext2_fs_uuid,
};
diff --git a/core/fs/ext2/ext2_fs.h b/core/fs/ext2/ext2_fs.h
index 8adc9bbe..803a9954 100644
--- a/core/fs/ext2/ext2_fs.h
+++ b/core/fs/ext2/ext2_fs.h
@@ -277,6 +277,7 @@ struct ext2_sb_info {
uint32_t s_groups_count; /* Number of groups in the fs */
uint32_t s_first_data_block; /* First Data Block */
int s_inode_size;
+ uint8_t s_uuid[16]; /* 128-bit uuid for volume */
};
static inline struct ext2_sb_info *EXT2_SB(struct fs_info *fs)