Skip to contentSkip to conversation

libblkid: add f2fs support

PATCH Applied Alejandro Martinez Ruiz 2 participants 5 messages Feb 5, 2013 – Feb 6, 2013 Util-Linux package

lore
Share & tools
lore
#0 lore raw

Hi,

These patches implement support for Samsung's f2fs (Flash-Friendly File System) in libblkid. f2fs was recently merged into the Linux kernel for the 3.8 release.

The first patch implements superblocks/f2fs.c and adds it to the build system, while the second one adds a test image.

Thanks,
Alex

#1 lore raw

PATCH 1/2 libblkid: add Flash-Friendly File System (f2fs) support

This adds support for detecting Flash-Friendly File System (f2fs) to libblkid. Based on work by Sven-Göran Bergh at http://www.mail-archive.com/[email protected]/msg17874.html

---
 libblkid/src/Makemodule.am             |  1 +
 libblkid/src/superblocks/f2fs.c        | 98 ++++++++++++++++++++++++++++++++++
 libblkid/src/superblocks/superblocks.c |  3 +-
 libblkid/src/superblocks/superblocks.h |  1 +
 4 files changed, 102 insertions(+), 1 deletion(-)
 create mode 100644 libblkid/src/superblocks/f2fs.c
libblkid/src/Makemodule.am +1 -0
index de60458..90efa3d 100644
@@ -54,6 +54,7 @@ libblkid_la_SOURCES = \
 	libblkid/src/superblocks/drbdproxy_datalog.c \
 	libblkid/src/superblocks/exfat.c \
 	libblkid/src/superblocks/ext.c \
+	libblkid/src/superblocks/f2fs.c \
 	libblkid/src/superblocks/gfs.c \
 	libblkid/src/superblocks/hfs.c \
 	libblkid/src/superblocks/highpoint_raid.c \
libblkid/src/superblocks/f2fs.c new file +98 -0

98 lines not on this page · raw message

libblkid/src/superblocks/superblocks.c +2 -1
index 2929a5f..62aa662 100644
@@ -140,7 +140,8 @@ static const struct blkid_idinfo *idinfos[] =
 	&vmfs_fs_idinfo,
 	&befs_idinfo,
 	&nilfs2_idinfo,
-	&exfat_idinfo
+	&exfat_idinfo,
+	&f2fs_idinfo
 };
 
 /*
libblkid/src/superblocks/superblocks.h +1 -0
index 08f1438..887732a 100644
@@ -69,6 +69,7 @@ extern const struct blkid_idinfo drbdproxy_datalog_idinfo;
 extern const struct blkid_idinfo befs_idinfo;
 extern const struct blkid_idinfo nilfs2_idinfo;
 extern const struct blkid_idinfo exfat_idinfo;
+extern const struct blkid_idinfo f2fs_idinfo;
 
 /*
  * superblock functions
Signature · 1 line
1.8.1.2.422.g08c0e7f
maintainer
#2 lore raw

Re: [PATCH 1/2] libblkid: add Flash-Friendly File System (f2fs) support

Quoted 13 lines · Alejandro Martinez Ruiz
libblkid/src/superblocks/f2fs.c new file +13 -0
+static int probe_f2fs(blkid_probe pr, const struct blkid_idmag *mag)
+{
+	struct f2fs_super_block *sb;
+	uint16_t major, minor;
+
+	sb = blkid_probe_get_sb(pr, mag, struct f2fs_super_block);
+	if (!sb)
+		return -1;
+
+	major = le16_to_cpu(sb->major_ver);
+	minor = le16_to_cpu(sb->minor_ver);
+
+	/* For version 1.0 we cannot know the correct sb structure */

libblkid/src/superblocks/f2fs.c line 80

Quoted 10 lines
libblkid/src/superblocks/f2fs.c new file +10 -0
+	if (major == 1 && minor == 0)
+		return 0;
+
+	if (*((unsigned char *) sb->volume_name))
+		blkid_probe_set_utf8label(pr, (unsigned char *) sb->volume_name,
+						sizeof(sb->volume_name),
+						BLKID_ENC_UTF16LE);
+
+	blkid_probe_set_uuid(pr, sb->uuid);
+	blkid_probe_sprintf_version(pr, "%u.%u", major, minor);
    return 0;
Quoted 1 line

+}

Fixed, applied. Thanks.

Karel

Signature · 2 lines
 Karel Zak  <[email protected]>
 http://karelzak.blogspot.com
#3 lore raw

PATCH 2/2 tests: add f2fs image test

In reply to Alejandro Martinez Ruiz
---
 tests/expected/blkid/low-probe-f2fs   |   7 +++++++
 tests/ts/blkid/images-fs/f2fs.img.bz2 | Bin 0 -> 695 bytes
 2 files changed, 7 insertions(+)
 create mode 100644 tests/expected/blkid/low-probe-f2fs
 create mode 100644 tests/ts/blkid/images-fs/f2fs.img.bz2
tests/expected/blkid/low-probe-f2fs new file +7 -0
new file mode 100644
index 0000000..ee32864
@@ -0,0 +1,7 @@
+ID_FS_LABEL=test-f2fs
+ID_FS_LABEL_ENC=test-f2fs
+ID_FS_TYPE=f2fs
+ID_FS_USAGE=filesystem
+ID_FS_UUID=f6aee5b9-8cc2-4da7-9f8d-c95aac90e17d
+ID_FS_UUID_ENC=f6aee5b9-8cc2-4da7-9f8d-c95aac90e17d
+ID_FS_VERSION=1.1
tests/ts/blkid/images-fs/f2fs.img.bz2 new file binary +0 -0
new file mode 100644
index 0000000000000000000000000000000000000000..82e86013d833654bc871bd880b8b714d30681d72
GIT binary patch
Signature · 1 line
1.8.1.2.422.g08c0e7f
maintainer Applied
#4 lore raw

Re: [PATCH 2/2] tests: add f2fs image test

Quoted 5 lines · Alejandro Martinez Ruiz
 tests/expected/blkid/low-probe-f2fs   |   7 +++++++
 tests/ts/blkid/images-fs/f2fs.img.bz2 | Bin 0 -> 695 bytes
 2 files changed, 7 insertions(+)
 create mode 100644 tests/expected/blkid/low-probe-f2fs
 create mode 100644 tests/ts/blkid/images-fs/f2fs.img.bz2

Applied, thanks!

Karel

Signature · 2 lines
 Karel Zak  <[email protected]>
 http://karelzak.blogspot.com