summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Changelog5
-rw-r--r--common.h2
-rw-r--r--convertquota.810
-rw-r--r--convertquota.c20
-rw-r--r--edquota.820
-rw-r--r--edquota.c192
-rw-r--r--quota.120
-rw-r--r--quota.c50
-rw-r--r--quotacheck.828
-rw-r--r--quotacheck.c44
-rw-r--r--quotaon.838
-rw-r--r--quotaon.c33
-rw-r--r--quotaops.c6
-rw-r--r--quotasys.c26
-rw-r--r--quotasys.h6
-rw-r--r--repquota.822
-rw-r--r--repquota.c33
-rw-r--r--setquota.820
-rw-r--r--setquota.c73
-rw-r--r--warnquota.820
-rw-r--r--warnquota.c34
21 files changed, 487 insertions, 215 deletions
diff --git a/Changelog b/Changelog
index 8b6f79d..3da8974 100644
--- a/Changelog
+++ b/Changelog
@@ -1,4 +1,7 @@
Changes in quota-tools from 3.13 to 3.14
+* added option --always-resolve to force resolving even names with digits only (Jan Kara)
+* minor language corrections in manpages (Jan Kara)
+* implemented long options parsing for all quota tools (Jan Kara)
* quota(1) has -f option to specify filesystem list (Jan Kara)
* corrected some informal language in messages (Jan Kara)
* we cannot even stat NFS mounts in local mode as server may be unreachable (Jan Kara)
@@ -397,7 +400,7 @@ Changes in quota-tools from 1.60 to 1.65
Changes in quota-tools from 1.55 to 1.60
* Added new option to kernel root_squash which means when that option is
- set the kernel system threats root as any normal user and he cannot
+ set the kernel system treats root as any normal user and he cannot
write to any file anymore without obeing the quota limits.
* Added support for root_squash to quotaon and quotaoff using the new
diff --git a/common.h b/common.h
index 3aff238..2085571 100644
--- a/common.h
+++ b/common.h
@@ -13,7 +13,7 @@
# endif
#endif
-#define MY_EMAIL "mvw@planets.elm.net, jack@suse.cz"
+#define MY_EMAIL "jack@suse.cz"
/* Name of current program for error reporting */
extern char *progname;
diff --git a/convertquota.8 b/convertquota.8
index 0516bb5..5ce5b31 100644
--- a/convertquota.8
+++ b/convertquota.8
@@ -31,19 +31,19 @@ is also architecture independent. This format introduces Radix Tree (a simple fo
structure) to quota file.
.SH OPTIONS
.TP
-.B -u
+.B -u, --user
convert user quota file. This is the default.
.TP
-.B -g
+.B -g, --group
convert group quota file.
.TP
-.B -f
+.B -f, --convert-format
convert from old file format to new one. This is the default.
.TP
-.B -e
+.B -e, --convert-endian
convert new file format from big endian to little endian.
.TP
-.B -V
+.B -V, --version
print version information.
.SH FILES
.TP 20
diff --git a/convertquota.c b/convertquota.c
index 9b29a95..1572cb9 100644
--- a/convertquota.c
+++ b/convertquota.c
@@ -11,6 +11,7 @@
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
+#include <getopt.h>
#include <asm/byteorder.h>
@@ -34,7 +35,13 @@ int action; /* Action to be performed */
static void usage(void)
{
- errstr(_("Utility for converting quota files.\nUsage:\n\t%s [-u] [-g] [-e|-f] mountpoint\n"), progname);
+ errstr(_("Utility for converting quota files.\nUsage:\n\t%s [options] mountpoint\n\n\
+-u, --user convert user quota file\n\
+-g, --group convert group quota file\n\
+-e, --convert-endian convert quota file to correct endianity\n\
+-f, --convert-format convert from old to VFSv0 quota format\n\
+-h, --help show this help text and exit\n\
+-V, --version output version information and exit\n\n"), progname);
errstr(_("Bugs to %s\n"), MY_EMAIL);
exit(1);
}
@@ -42,9 +49,18 @@ static void usage(void)
static void parse_options(int argcnt, char **argstr)
{
int ret;
+ struct option long_opts[] = {
+ { "help", 0, NULL, 'h'},
+ { "version", 0, NULL, 'V'},
+ { "user", 0, NULL, 'u'},
+ { "group", 0, NULL, 'g'},
+ { "convert-endian", 0, NULL, 'e'},
+ { "convert-format", 0, NULL, 'f'},
+ { NULL, 0, NULL, 0}
+ };
action = ACT_FORMAT;
- while ((ret = getopt(argcnt, argstr, "Vugefh:")) != -1) {
+ while ((ret = getopt_long(argcnt, argstr, "Vugefh:", long_opts, NULL)) != -1) {
switch (ret) {
case '?':
case 'h':
diff --git a/edquota.8 b/edquota.8
index 3e05267..320c00a 100644
--- a/edquota.8
+++ b/edquota.8
@@ -56,7 +56,7 @@ edquota \- edit user quotas
.IX "filesystem" "edquota command" "" "\fLedquota\fP \(em edit user quotas"
.B edquota
is a quota editor. One or more users or groups may be specified on the command
-line. If a number is given in the place of user/group name it is threated as
+line. If a number is given in the place of user/group name it is treated as
an UID/GID. For each user or group a temporary file is created with an
.SM ASCII
representation of the current disk quotas for that user or group and an editor
@@ -87,26 +87,26 @@ environment variable specifies otherwise.
Only the super-user may edit quotas.
.SH OPTIONS
.TP
-.B \-r
+.B -r, --remote
Edit also non-local quota use rpc.rquotad on remote server to set quota.
This option is available only if quota tools were compiled with enabled
support for setting quotas over RPC.
The
-.B \-n
+.B -n
option is equivalent, and is maintained for backward compatibility.
.TP
-.B \-u
+.B -u, --user
Edit the user quota. This is the default.
.TP
-.B \-g
+.B -g, --group
Edit the group quota.
.TP
-.B \-p \f2protoname\f1
+.B -p, --prototype=\f2protoname\f1
Duplicate the quotas of the prototypical user
specified for each user specified. This is the normal
mechanism used to initialize quotas for groups of users.
.TP
-.B \-F \f2format-name\f1
+.B -F, --format=\f2format-name\f1
Edit quota for specified format (ie. don't perform format autodetection).
Possible format names are:
.B vfsold
@@ -118,11 +118,11 @@ Possible format names are:
.B xfs
(quota on XFS filesystem)
.TP
-.B \-f \f2filesystem\f1
+.B \-f, --filesystem \f2filesystem\f1
Perform specified operations only for given filesystem (default is to perform
operations for all filesystems with quota).
.TP
-.B \-t
+.B \-t, --edit-period
Edit the soft time limits for each filesystem.
In old quota format if the time limits are zero, the default time limits in
.B <linux/quota.h>
@@ -131,7 +131,7 @@ value set in kernel). Time units of 'seconds', 'minutes', 'hours', and 'days'
are understood. Time limits are printed in the greatest possible time unit such that
the value is greater than or equal to one.
.TP
-.B \-T
+.B \-T, --edit-times
Edit time for the user/group when softlimit is enforced. Possible values
are 'unset' or number and unit. Units are the same as in
.B \-t
diff --git a/edquota.c b/edquota.c
index 3e0e0cb..78b9081 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.18 2005/11/21 22:30:23 jkar8572 Exp $"
+#ident "$Id: edquota.c,v 1.19 2006/05/13 01:05:24 jkar8572 Exp $"
/*
* Disk quota editor.
@@ -52,6 +52,7 @@
#include <paths.h>
#include <stdlib.h>
#include <fcntl.h>
+#include <getopt.h>
#include "pot.h"
#include "quotaops.h"
@@ -59,55 +60,80 @@
#include "quotaio.h"
#include "common.h"
+#define FL_EDIT_PERIOD 1
+#define FL_EDIT_TIMES 2
+#define FL_REMOTE 4
+#define FL_NUMNAMES 8
+
char *progname;
+
+int flags, quotatype;
+int fmt = -1;
+char *protoname;
char *dirname;
void usage(void)
{
#if defined(RPC_SETQUOTA)
- errstr("%s%s%s%s",
- _("Usage:\n\tedquota [-r] [-u] [-F formatname] [-p username] [-f filesystem] username ...\n"),
- _("\tedquota [-r] -g [-F formatname] [-p groupname] [-f filesystem] groupname ...\n"),
- _("\tedquota [-r] [-u|g] [-F formatname] [-f filesystem] -t\n"),
- _("\tedquota [-r] [-u|g] [-F formatname] [-f filesystem] -T username|groupname ...\n"));
+ char *rpcflag = "[-r] ";
#else
- errstr("%s%s%s%s",
- _("Usage:\n\tedquota [-u] [-F formatname] [-p username] [-f filesystem] username ...\n"),
- _("\tedquota -g [-F formatname] [-p groupname] [-f filesystem] groupname ...\n"),
- _("\tedquota [-u|g] [-F formatname] [-f filesystem] -t\n"),
- _("\tedquota [-u|g] [-F formatname] [-f filesystem] -T username|groupname ...\n"));
+ char *rpcflag = "";
+#endif
+ errstr(_("Usage:\n\tedquota %1$s[-u] [-F formatname] [-p username] [-f filesystem] username ...\n\
+\tedquota %1$s-g [-F formatname] [-p groupname] [-f filesystem] groupname ...\n\
+\tedquota %1$s[-u|g] [-F formatname] [-f filesystem] -t\n\
+\tedquota %1$s[-u|g] [-F formatname] [-f filesystem] -T username|groupname ...\n"), rpcflag);
+ fputs(_("\n\
+-u, --user edit user data\n\
+-g, --group edit group data\n"), stderr);
+#if defined(RPC_SETQUOTA)
+ fputs(_("-r, --remote edit remote quota (via RPC)\n"), stderr);
#endif
+ fputs(_("-F, --format=formatname edit quotas of a specific format\n\
+-p, --prototype=name copy data from a prototype user/group\n\
+ --always-resolve always try to resolve name, even if it is\n\
+ composed only of digits\n\
+-f, --filesystem=filesystem edit data only on a specific filesystem\n\
+-t, --edit-period edit grace period\n\
+-T, --edit-times edit grace time of a user/group\n\
+-h, --help display this help text and exit\n\
+-V, --version display version information and exit\n\n"), stderr);
fprintf(stderr, _("Bugs to: %s\n"), MY_EMAIL);
exit(1);
}
-int main(int argc, char **argv)
+int parse_options(int argc, char **argv)
{
- struct dquot *protoprivs, *curprivs, *pprivs, *cprivs;
- long id, protoid;
- int quotatype, tmpfd, ret;
- char *protoname = NULL;
- int tflag = 0, Tflag = 0, pflag = 0, rflag = 0, fmt = -1;
- struct quota_handle **handles;
- char *tmpfil, *tmpdir = NULL;
-
- gettexton();
- progname = basename(argv[0]);
+ int ret;
+ struct option long_opts[] = {
+ { "help", 0, NULL, 'h' },
+ { "version", 0, NULL, 'V' },
+ { "prototype", 1, NULL, 'p' },
+ { "user", 0, NULL, 'u' },
+ { "group", 0, NULL, 'g' },
+ { "format", 1, NULL, 'F' },
+ { "filesystem", 1, NULL, 'f' },
+#if defined(RPC_SETQUOTA)
+ { "remote", 0, NULL, 'r' },
+#endif
+ { "always-resolve", 0, NULL, 256 },
+ { "edit-period", 0, NULL, 't' },
+ { "edit-times", 0, NULL, 'T' },
+ { NULL, 0, NULL, 0 }
+ };
if (argc < 2)
usage();
- dirname = NULL;
quotatype = USRQUOTA;
#if defined(RPC_SETQUOTA)
- while ((ret = getopt(argc, argv, "ugrntTVp:F:f:")) != -1) {
+ while ((ret = getopt_long(argc, argv, "ugrntTVp:F:f:", long_opts, NULL)) != -1) {
#else
- while ((ret = getopt(argc, argv, "ugtTVp:F:f:")) != -1) {
+ while ((ret = getopt_long(argc, argv, "ugtTVp:F:f:", long_opts, NULL)) != -1) {
#endif
switch (ret) {
case 'p':
protoname = optarg;
- pflag++;
break;
case 'g':
quotatype = GRPQUOTA;
@@ -115,17 +141,17 @@ int main(int argc, char **argv)
#if defined(RPC_SETQUOTA)
case 'n':
case 'r':
- rflag++;
+ flags |= FL_REMOTE;
break;
#endif
case 'u':
quotatype = USRQUOTA;
break;
case 't':
- tflag++;
+ flags |= FL_EDIT_PERIOD;
break;
case 'T':
- Tflag++;
+ flags |= FL_EDIT_TIMES;
break;
case 'F':
if ((fmt = name2fmt(optarg)) == QF_ERROR) /* Error? */
@@ -134,6 +160,9 @@ int main(int argc, char **argv)
case 'f':
dirname = optarg;
break;
+ case 256:
+ flags |= FL_NUMNAMES;
+ break;
case 'V':
version();
exit(0);
@@ -142,51 +171,76 @@ int main(int argc, char **argv)
}
}
argc -= optind;
- argv += optind;
- if ((tflag && argc != 0) || (Tflag && argc < 1))
+ if (((flags & FL_EDIT_PERIOD) && argc != 0) || ((flags & FL_EDIT_TIMES) && argc < 1))
+ usage();
+ if ((flags & (FL_EDIT_PERIOD | FL_EDIT_TIMES)) && protoname) {
+ errstr(_("Prototype name does not make sence when editting grace period or times.\n"));
usage();
+ }
+ return optind;
+}
+
+void copy_prototype(int argc, char **argv, struct quota_handle **handles)
+{
+ int ret, protoid, id;
+ struct dquot *protoprivs, *curprivs, *pprivs, *cprivs;
+
+ ret = 0;
+ protoid = name2id(protoname, quotatype, !!(flags & FL_NUMNAMES), NULL);
+ protoprivs = getprivs(protoid, handles, 0);
+ while (argc-- > 0) {
+ id = name2id(*argv++, quotatype, !!(flags & FL_NUMNAMES), NULL);
+ curprivs = getprivs(id, handles, 0);
+
+ for (pprivs = protoprivs, cprivs = curprivs; pprivs && cprivs;
+ pprivs = pprivs->dq_next, cprivs = cprivs->dq_next) {
+ if (!devcmp_handles(pprivs->dq_h, cprivs->dq_h)) {
+ errstr(_("fsname mismatch\n"));
+ continue;
+ }
+ cprivs->dq_dqb.dqb_bsoftlimit =
+ pprivs->dq_dqb.dqb_bsoftlimit;
+ cprivs->dq_dqb.dqb_bhardlimit =
+ pprivs->dq_dqb.dqb_bhardlimit;
+ cprivs->dq_dqb.dqb_isoftlimit =
+ pprivs->dq_dqb.dqb_isoftlimit;
+ cprivs->dq_dqb.dqb_ihardlimit =
+ pprivs->dq_dqb.dqb_ihardlimit;
+ update_grace_times(cprivs);
+ }
+ if (putprivs(curprivs, COMMIT_LIMITS) == -1)
+ ret = -1;
+ freeprivs(curprivs);
+ }
+ if (dispose_handle_list(handles) == -1)
+ ret = -1;
+ freeprivs(protoprivs);
+ exit(ret ? 1 : 0);
+}
+
+int main(int argc, char **argv)
+{
+ struct dquot *curprivs;
+ int tmpfd, ret, id;
+ struct quota_handle **handles;
+ char *tmpfil, *tmpdir = NULL;
+
+ gettexton();
+ progname = basename(argv[0]);
+ ret = parse_options(argc, argv);
+ argc -= ret;
+ argv += ret;
init_kernel_interface();
- handles = create_handle_list(dirname ? 1 : 0, dirname ? &dirname : NULL, quotatype, fmt, 0, rflag ? 0 : MS_LOCALONLY);
+ handles = create_handle_list(dirname ? 1 : 0, dirname ? &dirname : NULL, quotatype, fmt, 0, (flags & FL_REMOTE) ? 0 : MS_LOCALONLY);
if (!handles[0]) {
dispose_handle_list(handles);
fputs(_("No filesystems with quota detected.\n"), stderr);
return 0;
}
- if (pflag) {
- ret = 0;
- protoid = name2id(protoname, quotatype, NULL);
- protoprivs = getprivs(protoid, handles, 0);
- while (argc-- > 0) {
- id = name2id(*argv++, quotatype, NULL);
- curprivs = getprivs(id, handles, 0);
-
- for (pprivs = protoprivs, cprivs = curprivs; pprivs && cprivs;
- pprivs = pprivs->dq_next, cprivs = cprivs->dq_next) {
- if (!devcmp_handles(pprivs->dq_h, cprivs->dq_h))
- errstr(_("fsname mismatch\n"));
- else {
- cprivs->dq_dqb.dqb_bsoftlimit =
- pprivs->dq_dqb.dqb_bsoftlimit;
- cprivs->dq_dqb.dqb_bhardlimit =
- pprivs->dq_dqb.dqb_bhardlimit;
- cprivs->dq_dqb.dqb_isoftlimit =
- pprivs->dq_dqb.dqb_isoftlimit;
- cprivs->dq_dqb.dqb_ihardlimit =
- pprivs->dq_dqb.dqb_ihardlimit;
- update_grace_times(cprivs);
- }
- }
- if (putprivs(curprivs, COMMIT_LIMITS) == -1)
- ret = -1;
- freeprivs(curprivs);
- }
- if (dispose_handle_list(handles) == -1)
- ret = -1;
- freeprivs(protoprivs);
- exit(ret ? 1 : 0);
- }
+ if (protoname)
+ copy_prototype(argc, argv, handles);
umask(077);
if (getuid() == geteuid() && getgid() == getegid())
@@ -199,7 +253,7 @@ int main(int argc, char **argv)
tmpfd = mkstemp(tmpfil);
fchown(tmpfd, getuid(), getgid());
ret = 0;
- if (tflag) {
+ if (flags & FL_EDIT_PERIOD) {
if (writetimes(handles, tmpfd) < 0) {
errstr(_("Cannot write grace times to file.\n"));
ret = -1;
@@ -213,9 +267,9 @@ int main(int argc, char **argv)
ret = -1;
}
}
- else if (Tflag) {
+ else if (flags & FL_EDIT_TIMES) {
for (; argc > 0; argc--, argv++) {
- id = name2id(*argv, quotatype, NULL);
+ id = name2id(*argv, quotatype, !!(flags & FL_NUMNAMES), NULL);
curprivs = getprivs(id, handles, 0);
if (writeindividualtimes(curprivs, tmpfd, *argv, quotatype) < 0) {
errstr(_("Cannot write individual grace times to file.\n"));
@@ -239,7 +293,7 @@ int main(int argc, char **argv)
}
else {
for (; argc > 0; argc--, argv++) {
- id = name2id(*argv, quotatype, NULL);
+ id = name2id(*argv, quotatype, !!(flags & FL_NUMNAMES), NULL);
curprivs = getprivs(id, handles, 0);
if (writeprivs(curprivs, tmpfd, *argv, quotatype) < 0) {
errstr(_("Cannot write quotas to file.\n"));
diff --git a/quota.1 b/quota.1
index 789b909..355649c 100644
--- a/quota.1
+++ b/quota.1
@@ -42,7 +42,7 @@ For filesystems that are NFS-mounted a call to the rpc.rquotad on
the server machine is performed to get the information.
.SH OPTIONS
.TP
-.B \-F \f2format-name\f1
+.B -F, --format=\f2format-name\f1
Show quota for specified format (ie. don't perform format autodetection).
Possible format names are:
.B vfsold
@@ -54,41 +54,41 @@ Possible format names are:
.B xfs
(quota on XFS filesystem)
.TP
-.B \-g
+.B -g, --group
Print group quotas for the group
of which the user is a member.
The optional
.B group
argument(s) restricts the display to the specified group(s).
.TP
-.B \-u
+.B -u, --user
flag is equivalent to the default.
.TP
-.B \-v
+.B -v, --verbose
will display quotas on filesystems
where no storage is allocated.
.TP
-.B \-s
+.B -s, --human-readable
option will make
.BR quota (1)
try to choose units for showing limits, used space and used inodes.
.TP
-.B \-i
+.B -i, --no-autofs
ignore mountpoints mounted by automounter
.TP
-.B \-l
+.B -l, --local-only
report quotas only on local filesystems (ie. ignore NFS mounted filesystems).
.TP
-.B \-q
+.B -q, --quiet
Print a more terse message,
containing only information
on filesystems where usage is over quota.
.TP
-.B \-Q
+.B -Q, --quiet-refuse
Do not print error message if connection to rpc.rquotad is refused (usually this happens
when rpc.rquotad is not running on the server).
.TP
-.B \-w
+.B -w, --no-wrap
Do not wrap the line if the device name is too long. This can be useful when parsing
the output of
.BR quota (1)
diff --git a/quota.c b/quota.c
index 9fc8457..c681946 100644
--- a/quota.c
+++ b/quota.c
@@ -34,7 +34,7 @@
#ident "$Copyright: (c) 1980, 1990 Regents of the University of California. $"
#ident "$Copyright: All rights reserved. $"
-#ident "$Id: quota.c,v 1.19 2005/11/21 22:30:23 jkar8572 Exp $"
+#ident "$Id: quota.c,v 1.20 2006/05/13 01:05:24 jkar8572 Exp $"
/*
* Disk quota reporting program.
@@ -70,17 +70,35 @@
#define FL_NOAUTOFS 128
#define FL_NOWRAP 256
#define FL_FSLIST 512
+#define FL_NUMNAMES 1024
int flags, fmt = -1;
char *progname;
void usage(void)
{
- errstr( "%s%s%s%s",
+ errstr( "%s%s%s%s%s",
_("Usage: quota [-guqvsw] [-l | -Q] [-i] [-F quotaformat]\n"),
_("\tquota [-qvsw] [-l | -Q] [-i] [-F quotaformat] -u username ...\n"),
_("\tquota [-qvsw] [-l | -Q] [-i] [-F quotaformat] -g groupname ...\n"),
- _("\tquota [-qvswugQ] [-F quotaformat] -f filesystem ...\n"));
+ _("\tquota [-qvswugQ] [-F quotaformat] -f filesystem ...\n"),
+ _("\n\
+-u, --user display quota for user\n\
+-g, --group display quota for group\n\
+-q, --quiet print more terse message\n\
+-v, --verbose print more verbose message\n\
+-s, --human-readable display numbers in human friendly units (MB, GB...)\n\
+ --always-resolve always try to translate name to id, even if it is\n\
+ composed of only digits\n\
+-w, --no-wrap do not wrap long lines\n\
+-l, --local-only do not query NFS filesystems\n\
+-Q, --quiet-refuse do not print error message when NFS server does\n\
+ not respond\n\
+-i, --no-autofs do not query autofs mountpoints\n\
+-F, --format=formatname display quota of a specific format\n\
+-f, --filesystem-list display quota information only for given filesystems\n\
+-h, --help display this help message and exit\n\
+-V, --version display version information and exit\n\n"));
fprintf(stderr, _("Bugs to: %s\n"), MY_EMAIL);
exit(1);
}
@@ -196,11 +214,28 @@ int main(int argc, char **argv)
int ngroups;
gid_t gidset[NGROUPS], *gidsetp;
int i, ret;
+ struct option long_opts[] = {
+ { "help", 0, NULL, 'h' },
+ { "version", 0, NULL, 'V' },
+ { "user", 0, NULL, 'u' },
+ { "group", 0, NULL, 'g' },
+ { "quiet", 0, NULL, 'q' },
+ { "verbose", 0, NULL, 'v' },
+ { "human-readable", 0, NULL, 's' },
+ { "always-resolve", 0, NULL, 256 },
+ { "local-only", 0, NULL, 'l' },
+ { "no-autofs", 0, NULL, 'i' },
+ { "quiet-refuse", 0, NULL, 'Q' },
+ { "format", 1, NULL, 'F' },
+ { "no-wrap", 0, NULL, 'w' },
+ { "filesystem-list", 0, NULL, 'f' },
+ { NULL, 0, NULL, 0 }
+ };
gettexton();
progname = basename(argv[0]);
- while ((ret = getopt(argc, argv, "guqvsVliQF:wf")) != -1) {
+ while ((ret = getopt_long(argc, argv, "guqvsVliQF:wf", long_opts, NULL)) != -1) {
switch (ret) {
case 'g':
flags |= FL_GROUP;
@@ -221,6 +256,9 @@ int main(int argc, char **argv)
case 's':
flags |= FL_SMARTSIZE;
break;
+ case 256:
+ flags |= FL_NUMNAMES;
+ break;
case 'l':
flags |= FL_LOCALONLY;
break;
@@ -282,9 +320,9 @@ int main(int argc, char **argv)
if (flags & FL_USER)
for (; argc > 0; argc--, argv++)
- ret |= showquotas(USRQUOTA, user2uid(*argv, NULL), 0, NULL);
+ ret |= showquotas(USRQUOTA, user2uid(*argv, !!(flags & FL_NUMNAMES), NULL), 0, NULL);
else if (flags & FL_GROUP)
for (; argc > 0; argc--, argv++)
- ret |= showquotas(GRPQUOTA, group2gid(*argv, NULL), 0, NULL);
+ ret |= showquotas(GRPQUOTA, group2gid(*argv, !!(flags & FL_NUMNAMES), NULL), 0, NULL);
return ret;
}
diff --git a/quotacheck.8 b/quotacheck.8
index e3188fa..1b5a01f 100644
--- a/quotacheck.8
+++ b/quotacheck.8
@@ -70,65 +70,65 @@ ignore the failure to remount the filesystem read-only with option
.BR \-M .
.SH OPTIONS
.TP
-.B \-b
+.B -b, --backup
Forces
.B quotacheck
to make backups of the quota file before writing the new data.
.TP
-.B \-v
+.B -v, --verbose
.B quotacheck
reports its operation as it progresses. Normally it operates silently.
If the option is specified twice, also the current directory is printed (note
that printing can slow down the scan measurably).
.TP
-.B \-d
+.B -d, --debug
Enable debugging mode. It will result in a lot of information which can
be used in debugging the program. The output is very verbose and the
scan will be slow.
.TP
-.B \-u
+.B -u, --user
Only user quotas listed in
.I /etc/mtab
or on the filesystems specified are to be checked. This is the default action.
.TP
-.B \-g
+.B -g, --group
Only group quotas listed in
.I /etc/mtab
or on the filesystems specified are to be checked.
.TP
-.B \-c
+.B -c, --create-files
Don't read existing quota files. Just perform a new scan and save it to disk.
.B quotacheck
also skips scanning of old quota files when they are not found.
.TP
-.B \-f
+.B -f, --force
Forces checking and writing of new quota files on filesystems with quotas
enabled. This is not recommended as the created quota files may be out of sync.
.TP
-.B \-M
+.B -M, --try-remount
This flag forces checking of filesystem in read-write mode if a remount
fails. Do this only when you are sure no process will write to a
filesystem while scanning.
.TP
-.B \-m
+.B -m, --no-remount
Don't try to remount filesystem read-only. See comment with option
.BR \-M .
.TP
-.B \-i
+.B -i, --interactive
Interactive mode. By default
.B quotacheck
exits when it finds an error. In interactive mode user is asked for
input instead. See option
.BR \-n .
.TP
-.B \-n
+.B -n, --use-first-dquot
If the quota files become corrupted, it is possible for duplicate
entries for a single user or group ID to exist. Normally in this case,
.B quotacheck
exits or asks user for input. When this option is set, the first entry found
is always used (this option works in interactive mode too).
.TP
-.B \-F \f2format-name\f1
+.B -F, --format=\f2format-name\f1
Check and fix quota files of specified format (ie. don't perform format
auto-detection). This is recommended as detection might not work well on
corrupted quota files. Possible format names are:
@@ -141,11 +141,11 @@ corrupted quota files. Possible format names are:
.B xfs
(quota on XFS filesystem)
.TP
-.B \-a
+.B -a, --all
Check all mounted non-NFS filesystems in
.B /etc/mtab
.TP
-.B \-R
+.B -R, --exclude-root
When used together with the
.B \-a
option, all filesystems except for the root filesystem are checked for
diff --git a/quotacheck.c b/quotacheck.c
index fb24b70..9082917 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.50 2005/11/21 22:30:23 jkar8572 Exp $"
+#ident "$Id: quotacheck.c,v 1.51 2006/05/13 01:05:24 jkar8572 Exp $"
#include <dirent.h>
#include <stdio.h>
@@ -296,7 +296,24 @@ static inline void blit(char *msg)
static void usage(void)
{
- printf(_("Utility for checking and repairing quota files.\n%s [-gucfinvdmMR] [-F <quota-format>] filesystem|-a\n"), progname);
+ printf(_("Utility for checking and repairing quota files.\n%s [-gucbfinvdmMR] [-F <quota-format>] filesystem|-a\n\n\
+-u, --user check user files\n\
+-g, --group check group files\n\
+-c, --create-files create new quota files\n\
+-b, --backup create backups of old quota files\n\
+-f, --force force check even if quotas are enabled\n\
+-i, --interactive interactive mode\n\
+-n, --use-first-dquot use the first copy of duplicated structure\n\
+-v, --verbose print more information\n\
+-d, --debug print even more messages\n\
+-m, --no-remount do not remount filesystem read-only\n\
+-M, --try-remount try remounting filesystem read-only,\n\
+ continue even if it fails\n\
+-R, --exclude-root exclude root when checking all filesystems\n\
+-F, --format=formatname check quota files of specific format\n\
+-a, --all check all filesystems\n\
+-h, --help display this message and exit\n\
+-V, --version display version information and exit\n\n"), progname);
printf(_("Bugs to %s\n"), MY_EMAIL);
exit(1);
}
@@ -304,8 +321,27 @@ static void usage(void)
static void parse_options(int argcnt, char **argstr)
{
int ret;
-
- while ((ret = getopt(argcnt, argstr, "VhbcvugidnfF:mMRa")) != -1) {
+ struct option long_opts[] = {
+ { "version", 0, NULL, 'V' },
+ { "help", 0, NULL, 'h' },
+ { "backup", 0, NULL, 'b' },
+ { "create-files", 0, NULL, 'c' },
+ { "verbose", 0, NULL, 'v' },
+ { "debug", 0, NULL, 'd' },
+ { "user", 0, NULL, 'u' },
+ { "group", 0, NULL, 'g' },
+ { "interactive", 0, NULL, 'i' },
+ { "use-first-dquot", 0, NULL, 'n' },
+ { "force", 0, NULL, 'f' },
+ { "format", 1, NULL, 'F' },
+ { "no-remount", 0, NULL, 'm' },
+ { "try-remount", 0, NULL, 'M' },
+ { "exclude-root", 0, NULL, 'R' },
+ { "all", 0, NULL, 'a' },
+ { NULL, 0, NULL, 0 }
+ };
+
+ while ((ret = getopt_long(argcnt, argstr, "VhbcvugidnfF:mMRa", long_opts, NULL)) != -1) {
switch (ret) {
case 'b':
flags |= FL_BACKUPS;
diff --git a/quotaon.8 b/quotaon.8
index 1edfc79..3b199dd 100644
--- a/quotaon.8
+++ b/quotaon.8
@@ -80,7 +80,17 @@ have any disk quotas turned off.
.SH OPTIONS
.SS quotaon
.TP
-.B \-a
+.B -F, --format=\f2format-name\f1
+Report quota for specified format (ie. don't perform format autodetection).
+Possible format names are:
+.B vfsold
+(version 1 quota),
+.B vfsv0
+(version 2 quota),
+.B xfs
+(quota on XFS filesystem)
+.TP
+.B -a, --all
All automatically mounted (no
.B noauto
option) non-NFS filesystems in
@@ -88,26 +98,26 @@ option) non-NFS filesystems in
with quotas will have their quotas turned on.
This is normally used at boot time to enable quotas.
.TP
-.B \-v
+.B -v, --verbose
Display a message for each filesystem where quotas are turned on.
.TP
-.B \-u
+.B -u, --user
Manipulate user quotas. This is the default.
.TP
-.B \-g
+.B -g, --group
Manipulate group quotas.
.TP
-.B \-p
+.B -p, --print-state
Instead of turning quotas on just print state of quotas (ie. whether. quota is on or off)
.TP
-.B \-f
+.B -f, --off
Make
.B quotaon
behave like being called as
.BR quotaoff .
.SS quotaoff
.TP
-.B \-F \f2format-name\f1
+.B -F, --format=\f2format-name\f1
Report quota for specified format (ie. don't perform format autodetection).
Possible format names are:
.B vfsold
@@ -117,31 +127,31 @@ Possible format names are:
.B xfs
(quota on XFS filesystem)
.TP
-.B \-a
+.B -a, --all
Force all filesystems in
.B /etc/fstab
to have their quotas disabled.
.TP
-.B \-v
+.B -v, --verbose
Display a message for each filesystem affected.
.TP
-.B \-u
+.B -u, --user
Manipulate user quotas. This is the default.
.TP
-.B \-g
+.B -g, --group
Manipulate group quotas.
.TP
-.B \-p
+.B -p, --print-state
Instead of turning quotas off just print state of quotas (ie. whether. quota is on or off)
.TP
-.B \-x delete
+.B -x, --xfs-command delete
Free up the space used to hold quota information (maintained
internally) within XFS.
This option is only applicable to XFS, and is silently
ignored for other filesystem types.
It can only be used on a filesystem with quota previously turned off.
.TP
-.B \-x enforce
+.B -x, --xfs-command enforce
Switch off limit enforcement for XFS filesystems (perform
quota accounting only).
This option is only applicable to XFS, and is silently
diff --git a/quotaon.c b/quotaon.c
index 4062550..035c891 100644
--- a/quotaon.c
+++ b/quotaon.c
@@ -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.21 2005/11/21 22:30:23 jkar8572 Exp $"
+#ident "$Id: quotaon.c,v 1.22 2006/05/13 01:05:24 jkar8572 Exp $"
/*
* Turn quota on/off for a filesystem.
@@ -64,15 +64,39 @@ char *xarg = NULL;
static void usage(void)
{
- errstr(_("Usage:\n\t%s [-guvp] [-F quotaformat] [-x state] -a\n\t%s [-guvp] [-F quotaformat] [-x state] filesys ...\n"), progname, progname);
+ errstr(_("Usage:\n\t%s [-guvp] [-F quotaformat] [-x state] -a\n\
+\t%s [-guvp] [-F quotaformat] [-x state] filesys ...\n\n\
+-a, --all turn quotas on for all filesystems\n\
+-f, --off turn quotas off\n\
+-u, --user operate on user quotas\n\
+-g, --group operate on group quotas\n\
+-p, --print-state print whether quotas are on or off\n\
+-x, --xfs-command=cmd perform XFS quota command\n\
+-F, --format=formatname operate on specific quota format\n\
+-v, --verbose print more messages\n\
+-h, --help display this help text and exit\n\
+-V, --version display version information and exit\n"), progname, progname);
exit(1);
}
static void parse_options(int argcnt, char **argstr)
{
int c;
-
- while ((c = getopt(argcnt, argstr, "afvugpx:VF:")) != -1) {
+ struct option long_opts[] = {
+ { "all", 0, NULL, 'a' },
+ { "off", 0, NULL, 'f' },
+ { "verbose", 0, NULL, 'v' },
+ { "user", 0, NULL, 'u' },
+ { "group", 0, NULL, 'g' },
+ { "print-state", 0, NULL, 'p' },
+ { "xfs-command", 1, NULL, 'x' },
+ { "format", 1, NULL, 'F' },
+ { "version", 0, NULL, 'V' },
+ { "help", 0, NULL, 'h' },
+ { NULL, 0, NULL, 0 }
+ };
+
+ while ((c = getopt_long(argcnt, argstr, "afvugpx:VF:h", long_opts, NULL)) != -1) {
switch (c) {
case 'a':
flags |= FL_ALL;
@@ -102,6 +126,7 @@ static void parse_options(int argcnt, char **argstr)
case 'V':
version();
exit(0);
+ case 'h':
default:
usage();
}
diff --git a/quotaops.c b/quotaops.c
index d42819a..83cf377 100644
--- a/quotaops.c
+++ b/quotaops.c
@@ -34,7 +34,7 @@
#ident "$Copyright: (c) 1980, 1990 Regents of the University of California. $"
#ident "$Copyright: All rights reserved. $"
-#ident "$Id: quotaops.c,v 1.18 2005/11/21 22:30:23 jkar8572 Exp $"
+#ident "$Id: quotaops.c,v 1.19 2006/05/13 01:05:24 jkar8572 Exp $"
#include <rpc/rpc.h>
#include <sys/types.h>
@@ -256,7 +256,7 @@ int writeprivs(struct dquot *qlist, int outfd, char *name, int quotatype)
#if defined(ALT_FORMAT)
fprintf(fd, _("Disk quotas for %s %s (%cid %d):\n"),
- type2name(quotatype), name, *type2name(quotatype), name2id(name, quotatype, NULL));
+ type2name(quotatype), name, *type2name(quotatype), qlist->dq_id);
fprintf(fd,
_(" Filesystem blocks soft hard inodes soft hard\n"));
@@ -440,7 +440,7 @@ int writeindividualtimes(struct dquot *qlist, int outfd, char *name, int quotaty
die(1, _("Cannot duplicate descriptor of file to write to: %s\n"), strerror(errno));
fprintf(fd, _("Times to enforce softlimit for %s %s (%cid %d):\n"),
- type2name(quotatype), name, *type2name(quotatype), name2id(name, quotatype, NULL));
+ type2name(quotatype), name, *type2name(quotatype), qlist->dq_id);
fprintf(fd, _("Time units may be: days, hours, minutes, or seconds\n"));
fprintf(fd,
_(" Filesystem block grace inode grace\n"));
diff --git a/quotasys.c b/quotasys.c
index 80aa843..a62f79a 100644
--- a/quotasys.c
+++ b/quotasys.c
@@ -89,7 +89,7 @@ char *type2name(int type)
/*
* Convert name to uid
*/
-uid_t user2uid(char *name, int *err)
+uid_t user2uid(char *name, int flag, int *err)
{
struct passwd *entry;
uid_t ret;
@@ -97,9 +97,11 @@ uid_t user2uid(char *name, int *err)
if (err)
*err = 0;
- ret = strtoul(name, &errch, 0);
- if (!*errch) /* Is name number - we got directly uid? */
- return ret;
+ if (!flag) {
+ ret = strtoul(name, &errch, 0);
+ if (!*errch) /* Is name number - we got directly uid? */
+ return ret;
+ }
if (!(entry = getpwnam(name))) {
if (!err) {
errstr(_("user %s does not exist.\n"), name);
@@ -116,7 +118,7 @@ uid_t user2uid(char *name, int *err)
/*
* Convert group name to gid
*/
-gid_t group2gid(char *name, int *err)
+gid_t group2gid(char *name, int flag, int *err)
{
struct group *entry;
gid_t ret;
@@ -124,9 +126,11 @@ gid_t group2gid(char *name, int *err)
if (err)
*err = 0;
- ret = strtoul(name, &errch, 0);
- if (!*errch) /* Is name number - we got directly gid? */
- return ret;
+ if (!flag) {
+ ret = strtoul(name, &errch, 0);
+ if (!*errch) /* Is name number - we got directly gid? */
+ return ret;
+ }
if (!(entry = getgrnam(name))) {
if (!err) {
errstr(_("group %s does not exist.\n"), name);
@@ -143,12 +147,12 @@ gid_t group2gid(char *name, int *err)
/*
* Convert name to id
*/
-int name2id(char *name, int qtype, int *err)
+int name2id(char *name, int qtype, int flag, int *err)
{
if (qtype == USRQUOTA)
- return user2uid(name, err);
+ return user2uid(name, flag, err);
else
- return group2gid(name, err);
+ return group2gid(name, flag, err);
}
/*
diff --git a/quotasys.h b/quotasys.h
index 6f9491e..578cdb5 100644
--- a/quotasys.h
+++ b/quotasys.h
@@ -45,13 +45,13 @@ int nfs_fstype(char *);
char *type2name(int);
/* Convert username to uid */
-uid_t user2uid(char *, int *err);
+uid_t user2uid(char *, int flag, int *err);
/* Convert groupname to gid */
-gid_t group2gid(char *, int *err);
+gid_t group2gid(char *, int flag, int *err);
/* Convert user/groupname to id */
-int name2id(char *name, int qtype, int *err);
+int name2id(char *name, int qtype, int flag, int *err);
/* Convert uid to username */
int uid2user(uid_t, char *);
diff --git a/repquota.8 b/repquota.8
index 2826a52..cb2f196 100644
--- a/repquota.8
+++ b/repquota.8
@@ -68,37 +68,37 @@ or
options.
.SH OPTIONS
.TP
-.B \-a
+.B -a, --all
Report on all filesystems indicated in
.B /etc/mtab
to be read-write with quotas.
.TP
-.B \-v
+.B -v, --verbose
Report all quotas, even if there is no usage. Be also more verbose about quotafile
information.
.TP
-.B \-c
+.B -c, --batch-translation
Cache entries to report and translate uids/gids to names in big chunks by scanning
all users (default). This is good (fast) behaviour when using /etc/passwd file.
.TP
-.B \-C
+.B -C, --no-batch-translation
Translate individual entries. This is faster when you have users stored in database.
.TP
-.B \-t
+.B -t, --truncate-names
Truncate user/group names longer than 9 characters. This results in nicer output when
there are such names.
.TP
-.B \-n
+.B -n, --no-names
Don't resolve UIDs/GIDs to names. This can speedup printing a lot.
.TP
-.B \-s
+.B -s, --human-readable
Try to report used space, number of used inodes and limits in more appropriate units
than the default ones.
.TP
-.B \-i
+.B -i, --no-autofs
Ignore mountpoints mounted by automounter.
.TP
-.B \-F \f2format-name\f1
+.B \-F, --format=\f2format-name\f1
Report quota for specified format (ie. don't perform format autodetection).
Possible format names are:
.B vfsold
@@ -108,10 +108,10 @@ Possible format names are:
.B xfs
(quota on XFS filesystem)
.TP
-.B \-g
+.B -g, --group
Report quotas for groups.
.TP
-.B \-u
+.B -u, --user
Report quotas for users. This is the default.
.LP
Only the super-user may view quotas which are not their own.
diff --git a/repquota.c b/repquota.c
index e193b32..ab57894 100644
--- a/repquota.c
+++ b/repquota.c
@@ -15,6 +15,7 @@
#include <errno.h>
#include <pwd.h>
#include <grp.h>
+#include <getopt.h>
#include "pot.h"
#include "common.h"
@@ -43,7 +44,19 @@ char *progname;
static void usage(void)
{
- errstr(_("Utility for reporting quotas.\nUsage:\n%s [-vugsi] [-c|C] [-t|n] [-F quotaformat] (-a | mntpoint)\n"), progname);
+ errstr(_("Utility for reporting quotas.\nUsage:\n%s [-vugsi] [-c|C] [-t|n] [-F quotaformat] (-a | mntpoint)\n\n\
+-v, --verbose display also users/groups without any usage\n\
+-u, --user display information about users\n\
+-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\
+-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\
+-C, --no-batch-translation translate ids one by one\n\
+-F, --format=formatname report information for specific format\n\
+-h, --help display this help message and exit\n\
+-V, --version display version information and exit\n\n"), progname);
fprintf(stderr, _("Bugs to %s\n"), MY_EMAIL);
exit(1);
}
@@ -52,8 +65,24 @@ static void parse_options(int argcnt, char **argstr)
{
int ret;
int cache_specified = 0;
+ struct option long_opts[] = {
+ { "version", 0, NULL, 'V' },
+ { "all", 0, NULL, 'a' },
+ { "verbose", 0, NULL, 'v' },
+ { "user", 0, NULL, 'u' },
+ { "group", 0, NULL, 'g' },
+ { "help", 0, NULL, 'h' },
+ { "truncate-names", 0, NULL, 't' },
+ { "human-readable", 0, NULL, 's' },
+ { "no-names", 0, NULL, 'n' },
+ { "cache", 0, NULL, 'c' },
+ { "no-cache", 0, NULL, 'C' },
+ { "no-autofs", 0, NULL, 'i' },
+ { "format", 1, NULL, 'F' },
+ { NULL, 0, NULL, 0 }
+ };
- while ((ret = getopt(argcnt, argstr, "VavughtsncCiF:")) != -1) {
+ while ((ret = getopt_long(argcnt, argstr, "VavughtsncCiF:", long_opts, NULL)) != -1) {
switch (ret) {
case '?':
case 'h':
diff --git a/setquota.8 b/setquota.8
index e0a7b8d..3879532 100644
--- a/setquota.8
+++ b/setquota.8
@@ -109,14 +109,14 @@ setquota \- set disk quotas
is a command line quota editor.
The filesystem, user/group name and new quotas for this
filesystem can be specified on the command line. Note that if a number is
-given in the place of a user/group name it is threated as an UID/GID.
+given in the place of a user/group name it is treated as an UID/GID.
.TP
-.B -r
+.B -r, --remote
Edit also remote quota use rpc.rquotad on remote server to set quota. This
option is available only if quota tools were compiled with enabled support
for setting quotas over RPC.
.TP
-.B -F \f2quotaformat\f1
+.B -F, --format=\f2quotaformat\f1
Perform setting for specified format (ie. don't perform format autodetection).
Possible format names are:
.B vfsold
@@ -128,37 +128,37 @@ Possible format names are:
.B xfs
(quota on XFS filesystem)
.TP
-.B -u
+.B -u, --user
Set user quotas for named user. This is the default.
.TP
-.B -g
+.B -g, --group
Set group quotas for named group.
.TP
-.B -p \f2protoname\f1
+.B -p, --prototype=\f2protoname\f1
Use quota settings of user or group
.I protoname
to set the quota for the named user or group.
.TP
-.B -b
+.B -b, --batch
Read information to set from stdin (input format is
.I name block-softlimit block-hardlimit inode-softlimit inode-hardlimit
).
.TP
-.B -t
+.B -t, --edit-period
Set grace times for users/groups. Times
.B block-grace
and
.B inode-grace
are specified in seconds.
.TP
-.B -T
+.B -T, --edit-times
Alter times for individual user/group when softlimit is enforced. Times
.B block-grace
and
.B inode-grace
are specified in seconds or can be string 'unset'.
.TP
-.B -a
+.B -a, --all
Go through all filesystems with quota in
.B /etc/mtab
and perform setting.
diff --git a/setquota.c b/setquota.c
index f22326b..7aad2e1 100644
--- a/setquota.c
+++ b/setquota.c
@@ -29,6 +29,7 @@
#define FL_GRACE 32
#define FL_INDIVIDUAL_GRACE 64
#define FL_BATCH 128
+#define FL_NUMNAMES 256
int flags, fmt = -1;
char **mnt;
@@ -41,22 +42,32 @@ struct util_dqblk toset;
static void usage(void)
{
#if defined(RPC_SETQUOTA)
- errstr(_("Usage:\n"
- " setquota [-u|-g] [-r] [-F quotaformat] <user|group>\n"
- "\t<block-softlimit> <block-hardlimit> <inode-softlimit> <inode-hardlimit> -a|<filesystem>...\n"
- " setquota [-u|-g] [-r] [-F quotaformat] <-p protouser|protogroup> <user|group> -a|<filesystem>...\n"
- " setquota [-u|-g] [-r] [-F quotaformat] -b -a|<filesystem>...\n"
- " setquota [-u|-g] [-F quotaformat] -t <blockgrace> <inodegrace> -a|<filesystem>...\n"
- " setquota [-u|-g] [-F quotaformat] <user|group> -T <blockgrace> <inodegrace> -a|<filesystem>...\n"));
+ char *ropt = "[-r] ";
#else
- errstr(_("Usage:\n"
- " setquota [-u|-g] [-F quotaformat] <user|group>\n"
- "\t<block-softlimit> <block-hardlimit> <inode-softlimit> <inode-hardlimit> -a|<filesystem>...\n"
- " setquota [-u|-g] [-F quotaformat] <-p protouser|protogroup> <user|group> -a|<filesystem>...\n"
- " setquota [-u|-g] [-F quotaformat] -b -a|<filesystem>...\n"
- " setquota [-u|-g] [-F quotaformat] -t <blockgrace> <inodegrace> -a|<filesystem>...\n"
- " setquota [-u|-g] [-F quotaformat] <user|group> -T <blockgrace> <inodegrace> -a|<filesystem>...\n"));
+ char *ropt = "";
#endif
+ errstr(_("Usage:\n\
+ setquota [-u|-g] %1$s[-F quotaformat] <user|group>\n\
+\t<block-softlimit> <block-hardlimit> <inode-softlimit> <inode-hardlimit> -a|<filesystem>...\n\
+ setquota [-u|-g] %1$s[-F quotaformat] <-p protouser|protogroup> <user|group> -a|<filesystem>...\n\
+ setquota [-u|-g] %1$s[-F quotaformat] -b -a|<filesystem>...\n\
+ setquota [-u|-g] [-F quotaformat] -t <blockgrace> <inodegrace> -a|<filesystem>...\n\
+ setquota [-u|-g] [-F quotaformat] <user|group> -T <blockgrace> <inodegrace> -a|<filesystem>...\n\n\
+-u, --user set limits for user\n\
+-g, --group set limits for group\n\
+-a, --all set limits for all filesystems\n\
+ --always-resolve always try to resolve name, even if is\n\
+ composed only of digits\n\
+-F, --format=formatname operate on specific quota format\n\
+-p, --prototype=protoname copy limits from user/group\n\
+-b, --batch read limits from standard input\n"), ropt);
+#if defined(RPC_SETQUOTA)
+ fputs(_("-r, --remote set remote quota (via RPC)\n"), stderr);
+#endif
+ fputs(_("-t, --edit-period edit grace period\n\
+-T, --edit-times edit grace times for user/group\n\
+-h, --help display this help text and exit\n\
+-V, --version display version information and exit\n\n"), stderr);
fprintf(stderr, _("Bugs to: %s\n"), MY_EMAIL);
exit(1);
}
@@ -91,12 +102,29 @@ static void parse_options(int argcnt, char **argstr)
char *protoname = NULL;
#ifdef RPC_SETQUOTA
- char *opts = "igp:urVF:taTb";
+ char *opts = "gp:urVF:taTb";
#else
- char *opts = "igp:uVF:taTb";
+ char *opts = "gp:uVF:taTb";
+#endif
+ struct option long_opts[] = {
+ { "user", 0, NULL, 'u' },
+ { "group", 0, NULL, 'g' },
+ { "prototype", 1, NULL, 'p' },
+#ifdef RPC_SETQUOTA
+ { "remote", 0, NULL, 'r' },
#endif
+ { "all", 0, NULL, 'a' },
+ { "always-resolve", 0, NULL, 256},
+ { "edit-period", 0, NULL, 't' },
+ { "edit-times", 0, NULL, 'T' },
+ { "batch", 0, NULL, 'b' },
+ { "format", 1, NULL, 'F' },
+ { "version", 0, NULL, 'V' },
+ { "help", 0, NULL, 'h' },
+ { NULL, 0, NULL, 0 }
+ };
- while ((ret = getopt(argcnt, argstr, opts)) != -1) {
+ while ((ret = getopt_long(argcnt, argstr, opts, long_opts, NULL)) != -1) {
switch (ret) {
case '?':
case 'h':
@@ -117,6 +145,9 @@ static void parse_options(int argcnt, char **argstr)
case 'a':
flags |= FL_ALL;
break;
+ case 256:
+ flags |= FL_NUMNAMES;
+ break;
case 't':
flags |= FL_GRACE;
break;
@@ -132,7 +163,7 @@ static void parse_options(int argcnt, char **argstr)
break;
case 'V':
version();
- break;
+ exit(0);
}
}
if (flags & FL_USER && flags & FL_GROUP) {
@@ -173,7 +204,7 @@ static void parse_options(int argcnt, char **argstr)
if (!(flags & (FL_USER | FL_GROUP)))
flags |= FL_USER;
if (!(flags & (FL_GRACE | FL_BATCH))) {
- id = name2id(argstr[optind++], flag2type(flags), NULL);
+ id = name2id(argstr[optind++], flag2type(flags), !!(flags & FL_NUMNAMES), NULL);
if (!(flags & (FL_GRACE | FL_INDIVIDUAL_GRACE | FL_PROTO))) {
toset.dqb_bsoftlimit = parse_num(argstr[optind++], _("block softlimit"));
toset.dqb_bhardlimit = parse_num(argstr[optind++], _("block hardlimit"));
@@ -181,7 +212,7 @@ static void parse_options(int argcnt, char **argstr)
toset.dqb_ihardlimit = parse_num(argstr[optind++], _("inode hardlimit"));
}
else if (flags & FL_PROTO)
- protoid = name2id(protoname, flag2type(flags), NULL);
+ protoid = name2id(protoname, flag2type(flags), !!(flags & FL_NUMNAMES), NULL);
}
if (flags & FL_GRACE) {
toset.dqb_btime = parse_num(argstr[optind++], _("block grace time"));
@@ -265,7 +296,7 @@ static int read_entry(qid_t *id, qsize_t *isoftlimit, qsize_t *ihardlimit, qsize
if (ret != 5)
die(1, _("Cannot parse input line %d.\n"), line);
ret = 0;
- *id = name2id(name, flag2type(flags), &ret);
+ *id = name2id(name, flag2type(flags), !!(flags & FL_NUMNAMES), &ret);
if (ret)
errstr(_("Unable to get name '%s'.\n"), name);
} while (ret);
diff --git a/warnquota.8 b/warnquota.8
index a936c7b..2d319cb 100644
--- a/warnquota.8
+++ b/warnquota.8
@@ -25,7 +25,7 @@ message to those users who have reached their softlimit.
It is typically run via
.BR cron (8).
.TP
-.B -F \f2quotaformat\f1
+.B -F, --format=\f2quotaformat\f1
Perform setting for specified format (ie. don't perform format autodetection).
Possible format names are:
.B vfsold
@@ -37,43 +37,43 @@ Possible format names are:
.B xfs
(quota on XFS filesystem)
.TP
-.B -q \f2quotatab\f1
+.B -q, --quota-tab=\f2quotatab\f1
Use
.I quotatab
instead of
.I /etc/quotatab
as file with device description strings (see example file for syntax).
.TP
-.B -c \f2configfile\f1
+.B -c, --config=\f2configfile\f1
Use
.I configfile
instead of
.I /etc/warnquota.conf
as configuration file (see example file for syntax).
.TP
-.B -a \f2adminsfile\f1
+.B -a, --admins-file=\f2adminsfile\f1
Use
.I adminsfile
instead of
.I /etc/quotagrpadmins
as a file with administrators of the groups.
.TP
-.B -u
+.B -u, --user
check whether users are not exceeding quotas (default).
.TP
-.B -g
+.B -g, --group
check whether groups are not exceeding quotas. If group is exceeding quota
a mail is sent to the user specified in /etc/quotagrpadmins.
.TP
-.B -s
+.B -s, --human-readable
Try to report used space, number of used inodes and limits in more appropriate units
than the default ones.
.TP
-.B \-i
+.B -i, --no-autofs
ignore mountpoints mounted by automounter.
.TP
-.B -d
-don't attach quota report in email.
+.B -d, --no-details
+do not attach quota report in email.
.SH FILES
.PD 0
.TP 20
diff --git a/warnquota.c b/warnquota.c
index 79f4084..74e1483 100644
--- a/warnquota.c
+++ b/warnquota.c
@@ -10,7 +10,7 @@
*
* Author: Marco van Wieringen <mvw@planets.elm.net>
*
- * Version: $Id: warnquota.c,v 1.25 2005/11/21 22:30:23 jkar8572 Exp $
+ * Version: $Id: warnquota.c,v 1.26 2006/05/13 01:05:24 jkar8572 Exp $
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -28,6 +28,7 @@
#include <signal.h>
#include <grp.h>
#include <time.h>
+#include <getopt.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <sys/utsname.h>
@@ -917,7 +918,18 @@ static void warn_quota(void)
/* Print usage information */
static void usage(void)
{
- errstr(_("Usage:\n warnquota [-ugsid] [-F quotaformat] [-c configfile] [-q quotatabfile]\n"));
+ errstr(_("Usage:\n warnquota [-ugsid] [-F quotaformat] [-c configfile] [-q quotatabfile] [-a adminsfile]\n\n\
+-u, --user warn users\n\
+-g, --group warn groups\n\
+-s, --human-readable send information in more human friendly units\n\
+-i, --no-autofs avoid autofs mountpoints\n\
+-d, --no-details do not send quota information itself\n\
+-F, --format=formatname use quotafiles of specific format\n\
+-c, --config=config-file non-default config file\n\
+-q, --quota-tab=quotatab-file non-default quotatab\n\
+-a, --admins-file=admins-file non-default admins file\n\
+-h, --help display this help message and exit\n\
+-v, --version display version information and exit\n\n"));
fprintf(stderr, _("Bugs to %s\n"), MY_EMAIL);
wc_exit(1);
}
@@ -925,15 +937,29 @@ static void usage(void)
static void parse_options(int argcnt, char **argstr)
{
int ret;
+ struct option long_opts[] = {
+ { "user", 0, NULL, 'u' },
+ { "group", 0, NULL, 'g' },
+ { "version", 0, NULL, 'V' },
+ { "help", 0, NULL, 'h' },
+ { "format", 1, NULL, 'F' },
+ { "config", 1, NULL, 'c' },
+ { "quota-tab", 1, NULL, 'q' },
+ { "admins-file", 1, NULL, 'a' },
+ { "no-autofs", 0, NULL, 'i' },
+ { "human-readable", 0, NULL, 's' },
+ { "no-details", 0, NULL, 'd' },
+ { NULL, 0, NULL, 0 }
+ };
- while ((ret = getopt(argcnt, argstr, "ugVF:hc:q:a:isd")) != -1) {
+ while ((ret = getopt_long(argcnt, argstr, "ugVF:hc:q:a:isd", long_opts, NULL)) != -1) {
switch (ret) {
case '?':
case 'h':
usage();
case 'V':
version();
- break;
+ exit(0);
case 'F':
if ((fmt = name2fmt(optarg)) == QF_ERROR)
wc_exit(1);