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 | |
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>
-rw-r--r-- | bylabel.c | 4 | ||||
-rw-r--r-- | bylabel.h | 2 | ||||
-rw-r--r-- | mntopt.h | 1 | ||||
-rw-r--r-- | quotasys.c | 25 |
4 files changed, 27 insertions, 5 deletions
@@ -280,9 +280,9 @@ static char *get_spec_by_volume_label(const char *s) return get_spec_by_x(VOL, s); } -const char *get_device_name(const char *item) +char *get_device_name(const char *item) { - const char *rc; + char *rc; if (!strncmp(item, "UUID=", 5)) rc = get_spec_by_uuid(item + 5); @@ -1,4 +1,4 @@ #ifndef BYLABEL_H_ #define BYLABEL_H_ -const char *get_device_name(const char *item); +char *get_device_name(const char *item); #endif /* BYLABEL_H_ */ @@ -23,6 +23,7 @@ #define MNTTYPE_OCFS2 "ocfs2" /* Oracle Cluster filesystem */ #define MNTTYPE_GFS2 "gfs2" /* Red Hat Global filesystem 2 */ #define MNTTYPE_TMPFS "tmpfs" /* tmpfs filesystem */ +#define MNTTYPE_BCACHEFS "bcachefs" #ifndef MNTTYPE_NFS #define MNTTYPE_NFS "nfs" /* Network file system. */ @@ -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]; |