summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjkar8572 <jkar8572>2006-10-30 15:26:20 +0000
committerjkar8572 <jkar8572>2006-10-30 15:26:20 +0000
commitde6f79f123371ffab995baa1b8a510b6a0509f88 (patch)
treec59577de8d5063bc43c65d5aefd756506ea9c841
parenta72fd94e8e99ccc116bffd47632b70ea8bcb86fe (diff)
Fixed error handling in edquota(8) when creating tmp files (Jan Kara)
Added option to repquota(8) to print grace in better parsable format (Jan Kara)
-rw-r--r--Changelog4
-rw-r--r--edquota.c14
-rw-r--r--repquota.89
-rw-r--r--repquota.c28
4 files changed, 46 insertions, 9 deletions
diff --git a/Changelog b/Changelog
index 4e8e4bf..4719b3c 100644
--- a/Changelog
+++ b/Changelog
@@ -1,3 +1,7 @@
+Changes in quota-tools from 3.14 to 3.15
+* added repquota(8) option for better parsable output (Jan Kara)
+* fixed error handling in edquota(8) when creating tmp file (Jan Kara)
+
Changes in quota-tools from 3.13 to 3.14
* updated Polish translations (Jakub Bogusz)
* print user/group names in error messages when cannot get quota information (Michal Marek, Jan Kara)
diff --git a/edquota.c b/edquota.c
index 78b9081..125ebe7 100644
--- a/edquota.c
+++ b/edquota.c
@@ -34,7 +34,7 @@
#ident "$Copyright: (c) 1980, 1990 Regents of the University of California. $"
#ident "$Copyright: All rights reserved. $"
-#ident "$Id: edquota.c,v 1.19 2006/05/13 01:05:24 jkar8572 Exp $"
+#ident "$Id: edquota.c,v 1.20 2006/10/30 15:26:20 jkar8572 Exp $"
/*
* Disk quota editor.
@@ -251,7 +251,16 @@ int main(int argc, char **argv)
strcpy(tmpfil, tmpdir);
strcat(tmpfil, "/EdP.aXXXXXX");
tmpfd = mkstemp(tmpfil);
- fchown(tmpfd, getuid(), getgid());
+ if (tmpfd < 0) {
+ errstr(_("Cannot create temporary file: %s\n"), strerror(errno));
+ ret = -1;
+ goto out;
+ }
+ if (fchown(tmpfd, getuid(), getgid()) < 0) {
+ errstr(_("Cannot change owner of temporary file: %s\n"), strerror(errno));
+ ret = -1;
+ goto out;
+ }
ret = 0;
if (flags & FL_EDIT_PERIOD) {
if (writetimes(handles, tmpfd) < 0) {
@@ -318,6 +327,7 @@ int main(int argc, char **argv)
freeprivs(curprivs);
}
}
+out:
if (dispose_handle_list(handles) == -1)
ret = -1;
diff --git a/repquota.8 b/repquota.8
index cb2f196..43a0652 100644
--- a/repquota.8
+++ b/repquota.8
@@ -5,7 +5,7 @@ repquota \- summarize quotas for a filesystem
.SH SYNOPSIS
.B /usr/sbin/repquota
[
-.B \-vsiug
+.B \-vspiug
] [
.B \-c
|
@@ -22,7 +22,7 @@ repquota \- summarize quotas for a filesystem
.LP
.B /usr/sbin/repquota
[
-.B \-avtsiug
+.B \-avtpsiug
] [
.B \-c
|
@@ -95,6 +95,11 @@ Don't resolve UIDs/GIDs to names. This can speedup printing a lot.
Try to report used space, number of used inodes and limits in more appropriate units
than the default ones.
.TP
+.B -p, --raw-grace
+When user is in grace period, report time in seconds since epoch when his grace
+time runs out (or has run out). Field is '0' when no grace time is in effect.
+This is especially useful when parsing output by a script.
+.TP
.B -i, --no-autofs
Ignore mountpoints mounted by automounter.
.TP
diff --git a/repquota.c b/repquota.c
index ab57894..48247f7 100644
--- a/repquota.c
+++ b/repquota.c
@@ -34,6 +34,7 @@
#define FL_NONAME 64 /* Don't translate ids to names */
#define FL_NOCACHE 128 /* Don't cache dquots before resolving */
#define FL_NOAUTOFS 256 /* Ignore autofs mountpoints */
+#define FL_RAWGRACE 512 /* Print grace times in seconds since epoch */
int flags, fmt = -1;
char **mnt;
@@ -50,6 +51,7 @@ static void usage(void)
-g, --group display information about groups\n\
-s, --human-readable show numbers in human friendly units (MB, GB, ...)\n\
-t, --truncate-names truncate names to 8 characters\n\
+-p, --raw-grace print grace time in seconds since epoch\n\
-n, --no-names do not translate uid/gid to name\n\
-i, --no-autofs avoid autofs mountpoints\n\
-c, --batch-translation translate big number of ids at once\n\
@@ -73,6 +75,7 @@ static void parse_options(int argcnt, char **argstr)
{ "group", 0, NULL, 'g' },
{ "help", 0, NULL, 'h' },
{ "truncate-names", 0, NULL, 't' },
+ { "raw-grace", 0, NULL, 'p' },
{ "human-readable", 0, NULL, 's' },
{ "no-names", 0, NULL, 'n' },
{ "cache", 0, NULL, 'c' },
@@ -82,7 +85,7 @@ static void parse_options(int argcnt, char **argstr)
{ NULL, 0, NULL, 0 }
};
- while ((ret = getopt_long(argcnt, argstr, "VavughtsncCiF:", long_opts, NULL)) != -1) {
+ while ((ret = getopt_long(argcnt, argstr, "VavughtspncCiF:", long_opts, NULL)) != -1) {
switch (ret) {
case '?':
case 'h':
@@ -105,6 +108,9 @@ static void parse_options(int argcnt, char **argstr)
case 't':
flags |= FL_TRUNCNAMES;
break;
+ case 'p':
+ flags |= FL_RAWGRACE;
+ break;
case 's':
flags |= FL_SHORTNUMS;
break;
@@ -174,9 +180,15 @@ static void print(struct dquot *dquot, char *name)
if (flags & FL_TRUNCNAMES)
pname[PRINTNAMELEN] = 0;
if (entry->dqb_bsoftlimit && toqb(entry->dqb_curspace) >= entry->dqb_bsoftlimit)
- difftime2str(entry->dqb_btime, time);
+ if (flags & FL_RAWGRACE)
+ sprintf(time, "%s", entry->dqb_btime);
+ else
+ difftime2str(entry->dqb_btime, time);
else
- time[0] = 0;
+ if (flags & FL_RAWGRACE)
+ strcpy(time, "0");
+ else
+ time[0] = 0;
space2str(toqb(entry->dqb_curspace), numbuf[0], flags & FL_SHORTNUMS);
space2str(entry->dqb_bsoftlimit, numbuf[1], flags & FL_SHORTNUMS);
space2str(entry->dqb_bhardlimit, numbuf[2], flags & FL_SHORTNUMS);
@@ -185,9 +197,15 @@ static void print(struct dquot *dquot, char *name)
overlim(entry->dqb_curinodes, entry->dqb_isoftlimit, entry->dqb_ihardlimit),
numbuf[0], numbuf[1], numbuf[2], time);
if (entry->dqb_isoftlimit && entry->dqb_curinodes >= entry->dqb_isoftlimit)
- difftime2str(entry->dqb_itime, time);
+ if (flags & FL_RAWGRACE)
+ sprintf(time, "%s", entry->dqb_itime);
+ else
+ difftime2str(entry->dqb_itime, time);
else
- time[0] = 0;
+ if (flags & FL_RAWGRACE)
+ strcpy(time, "0");
+ else
+ time[0] = 0;
number2str(entry->dqb_curinodes, numbuf[0], flags & FL_SHORTNUMS);
number2str(entry->dqb_isoftlimit, numbuf[1], flags & FL_SHORTNUMS);
number2str(entry->dqb_ihardlimit, numbuf[2], flags & FL_SHORTNUMS);