diff options
author | Carlos Maiolino <cem@kernel.org> | 2024-01-26 19:02:11 +0100 |
---|---|---|
committer | Jan Kara <jack@suse.cz> | 2024-01-29 11:59:57 +0100 |
commit | 00534e79856c8ce385ea1fdcdc2dcb32b1ed5de6 (patch) | |
tree | 602844a824d179f4930a0d62fdd7df5250e94410 /quotasys.c | |
parent | ded570b1fffbeaefbecb6c191f0b5168f3b8ad0d (diff) |
Enable support for tmpfs quotas
To achieve so, add a new function quotactl_handle() to the quotaio subsystem,
this will call do_quotactl() with or without a valid quotadev, according to the
filesystem type.
Signed-off-by: Carlos Maiolino <cmaiolino@redhat.com>
Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Signed-off-by: Jan Kara <jack@suse.cz>
Diffstat (limited to 'quotasys.c')
-rw-r--r-- | quotasys.c | 27 |
1 files changed, 21 insertions, 6 deletions
@@ -70,7 +70,15 @@ int nfs_fstype(char *type) */ int meta_qf_fstype(char *type) { - return !strcmp(type, MNTTYPE_OCFS2); + return !strcmp(type, MNTTYPE_OCFS2) || !strcmp(type, MNTTYPE_TMPFS); +} + +/* + * Check whether the filesystem is not using block device as a backing + */ +int nodev_fstype(char *type) +{ + return !strcmp(type, MNTTYPE_TMPFS) || nfs_fstype(type); } /* @@ -752,6 +760,7 @@ static int hasvfsmetaquota(const char *dev, struct mntent *mnt, int type, int fl if (!do_quotactl(QCMD(Q_GETFMT, type), dev, mnt->mnt_dir, 0, (void *)&fmt)) return QF_META; + return QF_ERROR; } @@ -816,8 +825,13 @@ static int hasquota(const char *dev, struct mntent *mnt, int type, int flags) !strcmp(mnt->mnt_type, MNTTYPE_XFS) || !strcmp(mnt->mnt_type, MNTTYPE_EXFS)) return hasxfsquota(dev, mnt, type, flags); + if (!strcmp(mnt->mnt_type, MNTTYPE_OCFS2)) return hasvfsmetaquota(dev, mnt, type, flags); + + /* tmpfs has no device, pass null here so quotactl_fd() is called */ + if (!strcmp(mnt->mnt_type, MNTTYPE_TMPFS)) + return hasvfsmetaquota(NULL, mnt, type, flags); /* * For ext4 we check whether it has quota in system files and if not, * we fall back on checking standard quotas. Furthermore we cannot use @@ -1384,7 +1398,7 @@ alloc: continue; } - if (!nfs_fstype(mnt->mnt_type)) { + if (!nodev_fstype(mnt->mnt_type)) { if (stat(devname, &st) < 0) { /* Can't stat mounted device? */ errstr(_("Cannot stat() mounted device %s: %s\n"), devname, strerror(errno)); free((char *)devname); @@ -1398,15 +1412,16 @@ alloc: dev = st.st_rdev; for (i = 0; i < mnt_entries_cnt && mnt_entries[i].me_dev != dev; i++); } - /* Cope with network filesystems or new mountpoint */ - if (nfs_fstype(mnt->mnt_type) || i == mnt_entries_cnt) { + + /* Cope with filesystems without a block device or new mountpoint */ + if (nodev_fstype(mnt->mnt_type) || i == mnt_entries_cnt) { if (stat(mnt->mnt_dir, &st) < 0) { /* Can't stat mountpoint? We have better ignore it... */ errstr(_("Cannot stat() mountpoint %s: %s\n"), mnt->mnt_dir, strerror(errno)); free((char *)devname); continue; } - if (nfs_fstype(mnt->mnt_type)) { - /* For network filesystems we must get device from root */ + if (nodev_fstype(mnt->mnt_type)) { + /* For filesystems without block device we must get device from root */ dev = st.st_dev; if (!(flags & MS_NFS_ALL)) { for (i = 0; i < mnt_entries_cnt && mnt_entries[i].me_dev != dev; i++); |