diff options
author | jkar8572 <jkar8572> | 2001-08-30 10:11:24 +0000 |
---|---|---|
committer | jkar8572 <jkar8572> | 2001-08-30 10:11:24 +0000 |
commit | 5cf36f5e002247effba3cf51a77e1d3f23c35a7b (patch) | |
tree | aae1bff1957ed84360f791237e6d4a8c7678729c | |
parent | 2ea1ae7b4512b8ed4b997ff55eab75e2ec00506e (diff) |
Preston Brown's RedHat patches included:
Small Makefile fix.
Better convertquota(8) return codes.
Quotacheck doesn't scan NFS filesystems.
Quotacheck does better format detection (chooses VFSV0 when files not found
and special file names are not specified).
-rw-r--r-- | Makefile.in | 1 | ||||
-rw-r--r-- | convertquota.c | 25 | ||||
-rw-r--r-- | quotacheck.c | 22 | ||||
-rw-r--r-- | quotaon.c | 23 |
4 files changed, 48 insertions, 23 deletions
diff --git a/Makefile.in b/Makefile.in index 9307e1c..7d5af04 100644 --- a/Makefile.in +++ b/Makefile.in @@ -75,7 +75,6 @@ install: all inst_mo -$(INSTALL) -m $(DEF_SBIN_MODE) \ quotacheck quotaon convertquota $(ROOTDIR)$(root_sbindir) $(LN) quotaon $(ROOTDIR)$(root_sbindir)/quotaoff - chown -h $(BIN_OWNER):$(BIN_GROUP) $(ROOTDIR)$(root_sbindir)/quotaoff -$(INSTALL) -m $(DEF_SBIN_MODE) \ edquota repquota warnquota quotastats setquota quot xqmstats \ $(ROOTDIR)$(sbindir) diff --git a/convertquota.c b/convertquota.c index ceaf6e7..5ce8244 100644 --- a/convertquota.c +++ b/convertquota.c @@ -33,7 +33,7 @@ static void usage(void) exit(1); } -void parse_options(int argcnt, char **argstr) +static void parse_options(int argcnt, char **argstr) { int ret; char *slash = strrchr(argstr[0], '/'), cmdname[PATH_MAX]; @@ -72,7 +72,7 @@ void parse_options(int argcnt, char **argstr) mntpoint = argstr[optind]; } -int convert_dquot(struct dquot *dquot, char *name) +static int convert_dquot(struct dquot *dquot, char *name) { struct dquot newdquot; @@ -95,21 +95,22 @@ int convert_dquot(struct dquot *dquot, char *name) return 0; } -void convert_file(int type, struct mntent *mnt) +static int convert_file(int type, struct mntent *mnt) { struct quota_handle *qo; char *qfname, namebuf[PATH_MAX]; - + int ret = 0; + if (!(qo = init_io(mnt, type, QF_VFSOLD, 1))) { errstr(_("Can't open old format file for %ss on %s\n"), type2name(type), mnt->mnt_dir); - return; + return -1; } if (!(qn = new_io(mnt, type, QF_VFSV0))) { errstr(_("Can't create file for %ss for new format on %s: %s\n"), type2name(type), mnt->mnt_dir, strerror(errno)); end_io(qo); - return; + return -1; } if (qo->qh_ops->scan_dquots(qo, convert_dquot) >= 0) { /* Conversion succeeded? */ qfname = get_qf_name(mnt, type, QF_VFSV0); @@ -119,15 +120,18 @@ void convert_file(int type, struct mntent *mnt) errstr(_("Can't rename new quotafile %s to name %s: %s\n"), namebuf, qfname, strerror(errno)); free(qfname); + ret = -1; } end_io(qo); end_io(qn); + return ret; } int main(int argc, char **argv) { struct mntent *mnt; - + int ret = 0; + gettexton(); progname = basename(argv[0]); @@ -139,11 +143,12 @@ int main(int argc, char **argv) return 1; } if (ucv) - convert_file(USRQUOTA, mnt); + ret |= convert_file(USRQUOTA, mnt); if (gcv) - convert_file(GRPQUOTA, mnt); + ret |= convert_file(GRPQUOTA, mnt); end_mounts_scan(); + if (ret) + return 1; return 0; } - diff --git a/quotacheck.c b/quotacheck.c index f0a2fce..f12fadd 100644 --- a/quotacheck.c +++ b/quotacheck.c @@ -8,7 +8,7 @@ * New quota format implementation - Jan Kara <jack@suse.cz> - Sponsored by SuSE CR */ -#ident "$Id: quotacheck.c,v 1.16 2001/08/15 20:13:42 jkar8572 Exp $" +#ident "$Id: quotacheck.c,v 1.17 2001/08/30 10:11:24 jkar8572 Exp $" #include <dirent.h> #include <stdio.h> @@ -788,9 +788,24 @@ out: /* Detect quota format from filename of present files */ static int detect_filename_format(struct mntent *mnt, int type) { + char *option; struct stat statbuf; char namebuf[PATH_MAX]; + if (type == USRQUOTA) { + if ((option = hasmntopt(mnt, MNTOPT_USRQUOTA))) + option += strlen(MNTOPT_USRQUOTA); + else if ((option = hasmntopt(mnt, MNTOPT_QUOTA))) + option += strlen(MNTOPT_QUOTA); + } + else { + if ((option = hasmntopt(mnt, MNTOPT_GRPQUOTA))) + option += strlen(MNTOPT_GRPQUOTA); + } + if (!option) + die(2, _("Can't find quota option on filesystem %s with quotas!\n"), mnt->mnt_dir); + if (*option == '=') /* If the file name is specified we can't detect quota format from it... */ + return -1; snprintf(namebuf, PATH_MAX, "%s/%s.%s", mnt->mnt_dir, basenames[QF_VFSV0], extensions[type]); if (!stat(namebuf, &statbuf)) return QF_VFSV0; @@ -799,7 +814,8 @@ static int detect_filename_format(struct mntent *mnt, int type) snprintf(namebuf, PATH_MAX, "%s/%s.%s", mnt->mnt_dir, basenames[QF_VFSOLD], extensions[type]); if (!stat(namebuf, &statbuf)) return QF_VFSOLD; - return -1; + /* Old quota files don't exist, just return newest format... */ + return QF_VFSV0; } static void check_all(void) @@ -812,7 +828,7 @@ static void check_all(void) while ((mnt = get_next_mount())) { if (flags & FL_ALL && flags & FL_NOROOT && !strcmp(mnt->mnt_dir, "/")) continue; - if (!strcmp(mnt->mnt_type, MNTTYPE_XFS)) { + if (!strcmp(mnt->mnt_type, MNTTYPE_XFS) || !strcmp(mnt->mnt_type, MNTTYPE_NFS)) { debug(FL_DEBUG | FL_VERBOSE, _("Skipping %s [%s]\n"), mnt->mnt_fsname, mnt->mnt_dir); continue; } @@ -34,7 +34,7 @@ #ident "$Copyright: (c) 1980, 1990 Regents of the University of California $" #ident "$Copyright: All rights reserved. $" -#ident "$Id: quotaon.c,v 1.6 2001/08/15 20:13:42 jkar8572 Exp $" +#ident "$Id: quotaon.c,v 1.7 2001/08/30 10:11:24 jkar8572 Exp $" /* * Turn quota on/off for a filesystem. @@ -66,12 +66,12 @@ static void usage(void) */ static int newstate(struct mntent *mnt, int offmode, int type, char *extra) { - int flags, ret; + int flags, ret = 0; newstate_t *statefunc; const char *mnt_fsname = get_device_name(mnt->mnt_fsname); if (!mnt_fsname) - return -1; + return 1; flags = offmode ? STATEFLAG_OFF : STATEFLAG_ON; if (vflag > 1) flags |= STATEFLAG_VERYVERBOSE; @@ -80,12 +80,17 @@ static int newstate(struct mntent *mnt, int offmode, int type, char *extra) if (aflag) flags |= STATEFLAG_ALL; - if (kqf & (1 << QF_XFS) && - ((offmode - && (kern_quota_on(mnt_fsname, USRQUOTA, 1 << QF_XFS) - || kern_quota_on(mnt_fsname, GRPQUOTA, 1 << QF_XFS))) - || (!offmode && kern_quota_on(mnt_fsname, type, 1 << QF_XFS)))) - ret = xfs_newstate(mnt, type, extra, flags); + if (!strcmp(mnt->mnt_type, MNTTYPE_XFS)) { /* XFS filesystem has special handling... */ + if (!(kqf & (1 << QF_XFS))) { + errstr("Can't change state of XFS quota. It's not compiled in kernel.\n"); + return 1; + } + if (kqf & (1 << QF_XFS) && + ((offmode && (kern_quota_on(mnt_fsname, USRQUOTA, 1 << QF_XFS) + || kern_quota_on(mnt_fsname, GRPQUOTA, 1 << QF_XFS))) + || (!offmode && kern_quota_on(mnt_fsname, type, 1 << QF_XFS)))) + ret = xfs_newstate(mnt, type, extra, flags); + } else { extra = get_qf_name(mnt, type, (kqf & (1 << QF_VFSV0)) ? QF_VFSV0 : QF_VFSOLD); statefunc = (kqf & (1 << QF_VFSV0)) ? v2_newstate : v1_newstate; |