summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJaegeuk Kim <jaegeuk@kernel.org>2017-10-10 16:46:25 -0700
committerJan Kara <jack@suse.cz>2017-10-16 09:42:44 +0200
commit4d81e8b4af6fdecf20ed777d67fe4b25e9fb46f6 (patch)
tree2043902d09360177ead404620aea85ebfc7c3a8f
parent16f31b143b41aaa50e43073fa0aadb8474820e1f (diff)
downloadquota-tools-4d81e8b4af6fdecf20ed777d67fe4b25e9fb46f6.tar.gz
f2fs: support f2fs's quota sysfile
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org> Signed-off-by: Jan Kara <jack@suse.cz>
-rw-r--r--bylabel.c18
-rw-r--r--mntopt.h1
-rw-r--r--quotasys.c2
3 files changed, 20 insertions, 1 deletions
diff --git a/bylabel.c b/bylabel.c
index 68a109c..ff10422 100644
--- a/bylabel.c
+++ b/bylabel.c
@@ -65,6 +65,14 @@ struct reiserfs_super_block {
u_char s_volume_name[16];
};
+#define F2FS_SUPER_MAGIC "0xF2F52010"
+struct f2fs_super_block {
+ u_char s_magic[8];
+ u_char s_dummy[144];
+ u_char s_uuid[16];
+ u_char s_volume_name[512];
+};
+
static inline unsigned short swapped(unsigned short a)
{
return (a >> 8) | (a << 8);
@@ -81,6 +89,7 @@ static int get_label_uuid(const char *device, char **label, char *uuid)
struct ext2_super_block e2sb;
struct xfs_super_block xfsb;
struct reiserfs_super_block reisersb;
+ struct f2fs_super_block f2fssb;
fd = open(device, O_RDONLY);
if (fd < 0)
@@ -114,6 +123,15 @@ static int get_label_uuid(const char *device, char **label, char *uuid)
sstrncpy(*label, (char *)reisersb.s_volume_name, namesize);
rv = 0;
}
+ else if (lseek(fd, 65536, SEEK_SET) == 65536
+ && read(fd, (char *)&f2fssb, sizeof(f2fssb)) == sizeof(f2fssb)
+ && !strncmp((char *)&f2fssb.s_magic, F2FS_SUPER_MAGIC, 8)) {
+ memcpy(uuid, f2fssb.s_uuid, sizeof(f2fssb.s_uuid));
+ namesize = sizeof(f2fssb.s_volume_name);
+ *label = smalloc(namesize + 1);
+ sstrncpy(*label, (char *)f2fssb.s_volume_name, namesize);
+ rv = 0;
+ }
close(fd);
return rv;
}
diff --git a/mntopt.h b/mntopt.h
index f31abb7..7913048 100644
--- a/mntopt.h
+++ b/mntopt.h
@@ -7,6 +7,7 @@
#define MNTTYPE_EXT2 "ext2" /* 2nd Extended file system */
#define MNTTYPE_EXT3 "ext3" /* ext2 + journaling */
#define MNTTYPE_EXT4 "ext4" /* ext4 filesystem */
+#define MNTTYPE_F2FS "f2fs" /* f2fs filesystem */
#define MNTTYPE_NEXT3 "next3" /* next3 filesystem */
#define MNTTYPE_EXT4DEV "ext4dev"/* ext4dev filesystem */
#define MNTTYPE_MINIX "minix" /* MINIX file system */
diff --git a/quotasys.c b/quotasys.c
index fa28f6e..52938ac 100644
--- a/quotasys.c
+++ b/quotasys.c
@@ -769,7 +769,7 @@ static int hasquota(const char *dev, struct mntent *mnt, int type, int flags)
* standard GETFMT quotactl because that does not distinguish between
* quota in system file and quota in ordinary file.
*/
- if (!strcmp(mnt->mnt_type, MNTTYPE_EXT4)) {
+ if (!strcmp(mnt->mnt_type, MNTTYPE_EXT4) || !strcmp(mnt->mnt_type, MNTTYPE_F2FS)) {
struct if_dqinfo kinfo;
if (quotactl(QCMD(Q_GETINFO, type), dev, 0, (void *)&kinfo) == 0) {