diff options
author | Kent Overstreet <kent.overstreet@gmail.com> | 2018-01-09 04:34:35 -0500 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2024-07-20 16:33:38 -0400 |
commit | 6de3144776e099cd64ac73c68c95cdfae684b0e5 (patch) | |
tree | 11b0d0cd38678ca511a55ce7c89785e6073fcb1d /quotasys.c | |
parent | 05151827d39453bc6728b28ab5fcb81bc7fffabd (diff) |
Add bcachefs support
bcachefs multi device filesystems require a bit of hackery, since the
line in /proc/mounts isn't actually a device: when checking if a
bcachefs device has quotas, we return an actually device path in @dev.
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'quotasys.c')
-rw-r--r-- | quotasys.c | 25 |
1 files changed, 23 insertions, 2 deletions
@@ -764,6 +764,24 @@ static int hasvfsmetaquota(const char *dev, struct mntent *mnt, int type, int fl return QF_ERROR; } +static int hasbcachefsquota(char *dev, struct mntent *mnt, int type, int flags) +{ + /* For multi device filesytems, figure out which is the right device: */ + char *devs = strdup(dev), *p = devs, *d; + uint32_t fmt; + + while ((d = strsep(&p, ":"))) { + if (!quotactl(QCMD(Q_XFS_GETQSTAT, type), d, 0, (void *)&fmt)) { + strcpy(dev, d); + free(devs); + return QF_META; + } + } + + free(devs); + return QF_ERROR; +} + /* Return pointer to given mount option in mount option string */ char *str_hasmntopt(const char *optstring, const char *opt) { @@ -819,7 +837,7 @@ static void copy_mntoptarg(char *buf, const char *optarg, int buflen) /* * Check to see if a particular quota is to be enabled (filesystem mounted with proper option) */ -static int hasquota(const char *dev, struct mntent *mnt, int type, int flags) +static int hasquota(char *dev, struct mntent *mnt, int type, int flags) { if (!strcmp(mnt->mnt_type, MNTTYPE_GFS2) || !strcmp(mnt->mnt_type, MNTTYPE_XFS) || @@ -832,6 +850,9 @@ static int hasquota(const char *dev, struct mntent *mnt, int type, int 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); + + if (!strcmp(mnt->mnt_type, MNTTYPE_BCACHEFS)) + return hasbcachefsquota(dev, mnt, type, flags) != QF_ERROR ? QF_META : QF_ERROR; /* * 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 @@ -1317,7 +1338,7 @@ alloc: autofsdircnt = 0; autofsdir_allocated = ALLOC_ENTRIES_NUM; while ((mnt = getmntent(mntf))) { - const char *devname; + char *devname; char *opt; int qfmt[MAXQUOTAS]; |