From 9e86f62b400c4b178751fbe0af85a8d1dc7372b5 Mon Sep 17 00:00:00 2001 From: jkar8572 Date: Sun, 21 Dec 2003 21:48:08 +0000 Subject: Implemented parsing of comma-separated list of filesystem types in fstab (Jan Kara) --- quotasys.c | 43 ++++++++++++++++++++++++++++++++----------- 1 file changed, 32 insertions(+), 11 deletions(-) (limited to 'quotasys.c') diff --git a/quotasys.c b/quotasys.c index 23ff4cb..4e9a6ff 100644 --- a/quotasys.c +++ b/quotasys.c @@ -34,20 +34,41 @@ #include "quotaio_v2.h" #define min(x,y) (((x) < (y)) ? (x) : (y)) -#define CORRECT_FSTYPE(type) \ -((!strcmp(type, MNTTYPE_EXT2)) || \ -(!strcmp(type, MNTTYPE_EXT3)) || \ -(!strcmp(type, MNTTYPE_MINIX)) || \ -(!strcmp(type, MNTTYPE_UFS)) || \ -(!strcmp(type, MNTTYPE_UDF)) || \ -(!strcmp(type, MNTTYPE_REISER)) || \ -(!strcmp(type, MNTTYPE_XFS)) || \ -(!strcmp(type, MNTTYPE_NFS))) static char extensions[MAXQUOTAS + 2][20] = INITQFNAMES; static char *basenames[] = INITQFBASENAMES; static char *fmtnames[] = INITQFMTNAMES; +/* + * Check whether give filesystem type is supported + */ + +static int correct_fstype(char *type) +{ + char *mtype = sstrdup(type), *next; + + type = mtype; + do { + next = strchr(type, ','); + if (next) + *next = 0; + if (!strcmp(type, MNTTYPE_EXT2) || + !strcmp(type, MNTTYPE_EXT3) || + !strcmp(type, MNTTYPE_MINIX) || + !strcmp(type, MNTTYPE_UFS) || + !strcmp(type, MNTTYPE_UDF) || + !strcmp(type, MNTTYPE_REISER) || + !strcmp(type, MNTTYPE_XFS) || + !strcmp(type, MNTTYPE_NFS)) { + free(mtype); + return 1; + } + type = next+1; + } while (next); + free(mtype); + return 0; +} + /* * Convert type of quota to written representation */ @@ -383,7 +404,7 @@ static int hasxfsquota(struct mntent *mnt, int type) */ int hasquota(struct mntent *mnt, int type) { - if (!CORRECT_FSTYPE(mnt->mnt_type) || hasmntopt(mnt, MNTOPT_NOQUOTA)) + if (!correct_fstype(mnt->mnt_type) || hasmntopt(mnt, MNTOPT_NOQUOTA)) return 0; if (!strcmp(mnt->mnt_type, MNTTYPE_XFS)) @@ -783,7 +804,7 @@ static int cache_mnt_table(int flags) /* Further we are not interested in mountpoints without quotas and we don't want to touch them */ - if (!CORRECT_FSTYPE(mnt->mnt_type) || hasmntopt(mnt, MNTOPT_NOQUOTA) || !(hasmntopt(mnt, MNTOPT_USRQUOTA) || hasmntopt(mnt, MNTOPT_GRPQUOTA) || hasmntopt(mnt, MNTOPT_QUOTA) || !strcmp(mnt->mnt_type, MNTTYPE_NFS))) { + if (!correct_fstype(mnt->mnt_type) || hasmntopt(mnt, MNTOPT_NOQUOTA) || !(hasmntopt(mnt, MNTOPT_USRQUOTA) || hasmntopt(mnt, MNTOPT_GRPQUOTA) || hasmntopt(mnt, MNTOPT_QUOTA) || !strcmp(mnt->mnt_type, MNTTYPE_NFS))) { free((char *)devname); continue; } -- cgit v1.2.3