diff options
author | Kent Overstreet <kent.overstreet@gmail.com> | 2019-05-21 09:59:31 -0400 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@gmail.com> | 2020-07-01 17:53:05 -0400 |
commit | 5d19eae7253bf71eee3574655461c0533cac2272 (patch) | |
tree | 52ad5cdb60c01dad8f046e2015bb0da3b77a9e08 | |
parent | 95436661cde27fa88c50284cc6671f07b7fecd9e (diff) |
Fix for multi device bcachefs filesystems
-rw-r--r-- | bylabel.c | 4 | ||||
-rw-r--r-- | bylabel.h | 2 | ||||
-rw-r--r-- | quotasys.c | 25 |
3 files changed, 24 insertions, 7 deletions
@@ -279,9 +279,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_ */ @@ -723,6 +723,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) { @@ -778,7 +796,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) || @@ -786,9 +804,8 @@ static int hasquota(const char *dev, struct mntent *mnt, int type, int flags) return hasxfsquota(dev, mnt, type, flags); if (!strcmp(mnt->mnt_type, MNTTYPE_OCFS2)) return hasvfsmetaquota(dev, mnt, type, flags); - if (!strcmp(mnt->mnt_type, MNTTYPE_BCACHEFS)) - return hasxfsquota(dev, mnt, type, flags) != QF_ERROR ? QF_META : QF_ERROR; + 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 @@ -1274,7 +1291,7 @@ alloc: autofsdircnt = 0; autofsdir_allocated = ALLOC_ENTRIES_NUM; while ((mnt = getmntent(mntf))) { - const char *devname; + char *devname; char *opt; int qfmt[MAXQUOTAS]; |