diff options
author | jkar8572 <jkar8572> | 2003-12-21 21:48:08 +0000 |
---|---|---|
committer | jkar8572 <jkar8572> | 2003-12-21 21:48:08 +0000 |
commit | 9e86f62b400c4b178751fbe0af85a8d1dc7372b5 (patch) | |
tree | 77a1a3528632fd46c2adf3b225c13acfcf58f40c /quotasys.c | |
parent | 3c0919136fe7bb301c85a656f326b64859a4735b (diff) |
Implemented parsing of comma-separated list of filesystem types in fstab (Jan Kara)
Diffstat (limited to 'quotasys.c')
-rw-r--r-- | quotasys.c | 43 |
1 files changed, 32 insertions, 11 deletions
@@ -34,21 +34,42 @@ #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 */ char *type2name(int type) @@ -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; } |