diff options
author | jkar8572 <jkar8572> | 2001-05-11 11:00:40 +0000 |
---|---|---|
committer | jkar8572 <jkar8572> | 2001-05-11 11:00:40 +0000 |
commit | efb62d5ef3fe7703e790173d53cf649c156bcb4e (patch) | |
tree | 473f308f0880a1afc4995bcdd70dd70a06c8adcd | |
parent | 3dbd1e5a75e551d93ced9b3f698c29be91261415 (diff) | |
download | linuxquota-efb62d5ef3fe7703e790173d53cf649c156bcb4e.tar.gz |
Fixed bug in quotacheck for new format.
Fixed bug in version() in quot (Nathan).
Added -t (truncate names) option to repquota.
-rw-r--r-- | convertquota.c | 5 | ||||
-rw-r--r-- | quot.c | 2 | ||||
-rw-r--r-- | quotacheck.c | 17 | ||||
-rw-r--r-- | quotacheck.h | 2 | ||||
-rw-r--r-- | quotacheck_v2.c | 6 | ||||
-rw-r--r-- | repquota.8 | 12 | ||||
-rw-r--r-- | repquota.c | 58 |
7 files changed, 63 insertions, 39 deletions
diff --git a/convertquota.c b/convertquota.c index d9a95bb..9d4bb96 100644 --- a/convertquota.c +++ b/convertquota.c @@ -108,8 +108,11 @@ void convert_file(int type) while ((mnt = getmntent(mntf))) { if (!(dev = get_device_name(mnt->mnt_fsname))) continue; - if (devcmp(dev, mntpoint) || dircmp(mnt->mnt_dir, mntpoint)) + if (devcmp(dev, mntpoint) || dircmp(mnt->mnt_dir, mntpoint)) { + free((void *)dev); break; + } + free((void *)dev); } if (!mnt) die(1, _("Can't find given mountpoint %s\n"), mntpoint); @@ -76,7 +76,7 @@ static void creport(const char *, char *); static void usage(void) { - errstr(_("Usage: %s [-acfugvV] [filesystem...]\n")); + errstr(_("Usage: %s [-acfugvV] [filesystem...]\n"), progname); exit(1); } diff --git a/quotacheck.c b/quotacheck.c index 6c01ffd..aa98806 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.8 2001/05/02 09:32:22 jkar8572 Exp $" +#ident "$Id: quotacheck.c,v 1.9 2001/05/11 11:00:40 jkar8572 Exp $" #include <dirent.h> #include <stdio.h> @@ -667,8 +667,13 @@ static int dump_to_file(char *mnt_fsname, struct mntent *mnt, int type) strerror(errno)); return -1; } - memcpy(&h->qh_info, old_info + type, sizeof(h->qh_info)); - mark_quotafile_info_dirty(h); + if (!(flags & FL_NEWFILE)) { + h->qh_info.dqi_bgrace = old_info[type].dqi_bgrace; + h->qh_info.dqi_igrace = old_info[type].dqi_igrace; + if (cfmt == QF_VFSV0) + v2_merge_info(&h->qh_info, old_info + type); + mark_quotafile_info_dirty(h); + } for (i = 0; i < DQUOTHASHSIZE; i++) for (dquot = dquot_hash[type][i]; dquot; dquot = dquot->dq_next) { dquot->dq_h = h; @@ -680,8 +685,7 @@ static int dump_to_file(char *mnt_fsname, struct mntent *mnt, int type) h->qh_ops->commit_dquot(dquot); } if (end_io(h) < 0) { - errstr(_("Cannot finish IO on new quotafile: %s\n"), - strerror(errno)); + errstr(_("Cannot finish IO on new quotafile: %s\n"), strerror(errno)); return -1; } if (rename_files(mnt, type) < 0) @@ -692,8 +696,7 @@ static int dump_to_file(char *mnt_fsname, struct mntent *mnt, int type) filename = get_qf_name(mnt, type, cfmt); if (quotactl(QCMD(Q_QUOTAOFF, type), mnt_fsname, 0, NULL) || quotactl(QCMD(Q_QUOTAON, type), mnt_fsname, 0, filename)) - errstr( - _("Cannot turn %s quotas on %s off and on: %s\nKernel won't know about changes quotacheck did.\n"), + errstr(_("Cannot turn %s quotas on %s off and on: %s\nKernel won't know about changes quotacheck did.\n"), type2name(type), mnt_fsname, strerror(errno)); free(filename); } diff --git a/quotacheck.h b/quotacheck.h index a20efb3..fd09aad 100644 --- a/quotacheck.h +++ b/quotacheck.h @@ -40,5 +40,5 @@ struct dquot *lookup_dquot(qid_t id, int type); struct dquot *add_dquot(qid_t id, int type); int v2_buffer_file(char *filename, int fd, int type); int v1_buffer_file(char *filename, int fd, int type); - +void v2_merge_info(struct util_dqinfo *new, struct util_dqinfo *old); #endif diff --git a/quotacheck_v2.c b/quotacheck_v2.c index da3ede3..8c88d79 100644 --- a/quotacheck_v2.c +++ b/quotacheck_v2.c @@ -344,3 +344,9 @@ int v2_buffer_file(char *filename, int fd, int type) debug(FL_DEBUG | FL_VERBOSE, _("Not found any corrupted blocks. Congratulations.\n")); return ret; } + +/* Merge quotafile info from old and new file */ +void v2_merge_info(struct util_dqinfo *new, struct util_dqinfo *old) +{ + new->u.v2_mdqi.dqi_flags = old->u.v2_mdqi.dqi_flags; +} @@ -3,18 +3,18 @@ .SH NAME repquota \- summarize quotas for a filesystem .SH SYNOPSIS -.B /usr/etc/repquota +.B /usr/sbin/repquota [ -.B \-vug +.B \-vtug ] [ .B \-F .I format-name ] .IR filesystem .\|.\|. .LP -.B /usr/etc/repquota +.B /usr/sbin/repquota [ -.B \-avug +.B \-avtug ] [ .B \-F .I format-name @@ -45,6 +45,10 @@ to be read-write with quotas. Report all quotas, even if there is no usage. Be also more verbose about quotafile information. .TP +.B \-t +Truncate user/group names longer than 9 characters. This results in nicer output when +there are such names. +.TP .B \-F \f2format-name\f1 Report quota for specified format (ie. don't perform format autodetection). Possible format names are: @@ -19,10 +19,13 @@ #include "quotasys.h" #include "quotaio.h" +#define PRINTNAMELEN 9 /* Number of characters to be reserved for name on screen */ + #define FL_USER 1 #define FL_GROUP 2 #define FL_VERBOSE 4 #define FL_ALL 8 +#define FL_TRUNCNAMES 16 int flags, fmt = -1; char **mnt; @@ -31,7 +34,7 @@ char *progname; static void usage(void) { - errstr(_("Utility for reporting quotas.\nUsage:\n%s [-vug] [-F quotaformat] (-a | mntpoint)\n"), progname); + errstr(_("Utility for reporting quotas.\nUsage:\n%s [-vugt] [-F quotaformat] (-a | mntpoint)\n"), progname); errstr(_("Bugs to %s\n"), MY_EMAIL); exit(1); } @@ -46,30 +49,33 @@ static void parse_options(int argcnt, char **argstr) else slash++; - while ((ret = getopt(argcnt, argstr, "VavughF:")) != -1) { + while ((ret = getopt(argcnt, argstr, "VavughtF:")) != -1) { switch (ret) { - case '?': - case 'h': - usage(); - case 'V': - version(); - exit(0); - case 'u': - flags |= FL_USER; - break; - case 'g': - flags |= FL_GROUP; - break; - case 'v': - flags |= FL_VERBOSE; - break; - case 'a': - flags |= FL_ALL; - break; - case 'F': - if ((fmt = name2fmt(optarg)) == QF_ERROR) - exit(1); - break; + case '?': + case 'h': + usage(); + case 'V': + version(); + exit(0); + case 'u': + flags |= FL_USER; + break; + case 'g': + flags |= FL_GROUP; + break; + case 'v': + flags |= FL_VERBOSE; + break; + case 'a': + flags |= FL_ALL; + break; + case 't': + flags |= FL_TRUNCNAMES; + break; + case 'F': + if ((fmt = name2fmt(optarg)) == QF_ERROR) + exit(1); + break; } } @@ -99,13 +105,15 @@ static char overlim(uint usage, uint softlim, uint hardlim) static int print(struct dquot *dquot, char *name) { + char pname[PRINTNAMELEN+1]; char time[MAXTIMELEN]; struct util_dqblk *entry = &dquot->dq_dqb; if (!entry->dqb_curspace && !entry->dqb_curinodes && !(flags & FL_VERBOSE)) return 0; + sstrncpy(pname, name, sizeof(pname)); difftime2str(entry->dqb_btime, time); - printf("%-10s%c%c%8Lu%8Lu%8Lu%7s", name, + printf("%-*s %c%c%8Lu%8Lu%8Lu%7s", PRINTNAMELEN, pname, overlim(qb2kb(toqb(entry->dqb_curspace)), qb2kb(entry->dqb_bsoftlimit), qb2kb(entry->dqb_bhardlimit)), overlim(entry->dqb_curinodes, entry->dqb_isoftlimit, |