Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 25 Sep 2001 18:27:34 +0400 (MSD)
From:      Dmitry Morozovsky <marck@rinet.ru>
To:        FreeBSD-gnats-submit@freebsd.org
Subject:   bin/30816: usr.sbin/edquota new option [-f]
Message-ID:  <200109251427.f8PERYu64954@woozle.rinet.ru>

next in thread | raw e-mail | index | archive | help

>Number:         30816
>Category:       bin
>Synopsis:       usr.sbin/edquota new option [-f]
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Tue Sep 25 07:30:00 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator:     Dmitry Morozovsky
>Release:        FreeBSD 4.4-RC i386 (RELENG_4 various)
>Organization:
Cronyx Plus LLC
>Environment:

	
>Description:

Adding new filesystem to the existing system with enabled quotas may produce
problems with distributing quotas for existing user accounts on new filesystem.
Although edquota has option -p, it's virtually impossible to set quotas
on the filesystem created. 

Solution would look as proposed: add `-f fspath' option to edquota to
restrict editable (or distributable via -p) filesystem list to single
filesystem. It look reasonable to specify fs either via special device or 
via mountpoint path.


>How-To-Repeat:

Sample (real) situation: system with enabled quotas, mainly equal for all users,
but with some exceptions. New disk added, new filesystem created and mounted
Proto-user quotas has beed edited to reflect new usual needs. However, there's
no simple way to distribute this value for each of users of particular
UID range.

With -f functionality, it's rather simple (given fs mount to /ar2, proto uid is 5000, uid range is 5001-5999):

edquota -p 5000 -f /ar2 5001-5999

>Fix:


Index: edquota.8
===================================================================
RCS file: /home/ncvs/src/usr.sbin/edquota/edquota.8,v
retrieving revision 1.9.2.1
diff -u -r1.9.2.1 edquota.8
--- edquota.8	2000/12/08 15:28:04	1.9.2.1
+++ edquota.8	2001/09/24 18:19:51
@@ -44,18 +44,22 @@
 .Sh SYNOPSIS
 .Nm
 .Op Fl u
+.Op Fl f Ar fspath
 .Op Fl p Ar proto-username
 .Ar username ...
 .Nm
 .Fl g
+.Op Fl f Ar fspath
 .Op Fl p Ar proto-groupname
 .Ar groupname ...
 .Nm
 .Fl t
 .Op Fl u
+.Op Fl f Ar fspath
 .Nm
 .Fl t
 .Fl g
+.Op Fl f Ar fspath
 .Sh DESCRIPTION
 .Nm Edquota
 is a quota editor.
@@ -90,6 +94,15 @@
 below).
 The current usage information in the file is for informational purposes;
 only the hard and soft limits can be changed.
+.Pp
+If the
+.Fl f
+option is specified,
+.Nm
+reads and edits quotas only for specified fylesystem. Parameter to
+.Fl f
+option may be either special device or mount point of the filesystem
+selected.
 .Pp
 On leaving the editor,
 .Nm
Index: edquota.c
===================================================================
RCS file: /home/ncvs/src/usr.sbin/edquota/edquota.c,v
retrieving revision 1.9.2.1
diff -u -r1.9.2.1 edquota.c
--- edquota.c	2000/10/28 02:22:59	1.9.2.1
+++ edquota.c	2001/09/24 18:19:51
@@ -89,7 +89,7 @@
 int editit __P((char *));
 void freeprivs __P((struct quotause *));
 int getentry __P((char *, int));
-struct quotause *getprivs __P((long, int));
+struct quotause *getprivs __P((long, int, char *));
 int hasquota __P((struct fstab *, int, char **));
 void putprivs __P((long, int, struct quotause *));
 int readprivs __P((struct quotause *, char *));
@@ -109,6 +109,7 @@
 	register uid_t startuid, enduid;
 	char *protoname, *cp, ch;
 	int tflag = 0, pflag = 0;
+	char *fspath = NULL;
 	char buf[30];
 
 	if (argc < 2)
@@ -116,8 +117,11 @@
 	if (getuid())
 		errx(1, "permission denied");
 	quotatype = USRQUOTA;
-	while ((ch = getopt(argc, argv, "ugtp:")) != -1) {
+	while ((ch = getopt(argc, argv, "ugtf:p:")) != -1) {
 		switch(ch) {
+		case 'f':
+			fspath = optarg;
+			break;
 		case 'p':
 			protoname = optarg;
 			pflag++;
@@ -140,7 +144,7 @@
 	if (pflag) {
 		if ((protoid = getentry(protoname, quotatype)) == -1)
 			exit(1);
-		protoprivs = getprivs(protoid, quotatype);
+		protoprivs = getprivs(protoid, quotatype, fspath);
 		for (qup = protoprivs; qup; qup = qup->next) {
 			qup->dqblk.dqb_btime = 0;
 			qup->dqblk.dqb_itime = 0;
@@ -173,7 +177,7 @@
 	tmpfd = mkstemp(tmpfil);
 	fchown(tmpfd, getuid(), getgid());
 	if (tflag) {
-		protoprivs = getprivs(0, quotatype);
+		protoprivs = getprivs(0, quotatype, fspath);
 		if (writetimes(protoprivs, tmpfd, quotatype) == 0)
 			exit(1);
 		if (editit(tmpfil) && readtimes(protoprivs, tmpfil))
@@ -186,7 +190,7 @@
 	for ( ; argc > 0; argc--, argv++) {
 		if ((id = getentry(*argv, quotatype)) == -1)
 			continue;
-		curprivs = getprivs(id, quotatype);
+		curprivs = getprivs(id, quotatype, fspath);
 		if (writeprivs(curprivs, tmpfd, *argv, quotatype) == 0)
 			continue;
 		if (editit(tmpfil) && readprivs(curprivs, tmpfil))
@@ -202,10 +206,10 @@
 usage()
 {
 	fprintf(stderr, "%s\n%s\n%s\n%s\n",
-		"usage: edquota [-u] [-p username] username ...",
-		"       edquota -g [-p groupname] groupname ...",
-		"       edquota [-u] -t",
-		"       edquota -g -t");
+		"usage: edquota [-u] [-f fspath] [-p username] username ...",
+		"       edquota -g [-f fspath] [-p groupname] groupname ...",
+		"       edquota [-u] -t [-f fspath]",
+		"       edquota -g -t [-f fspath]");
 	exit(1);
 }
 
@@ -247,9 +251,10 @@
  * Collect the requested quota information.
  */
 struct quotause *
-getprivs(id, quotatype)
+getprivs(id, quotatype, fspath)
 	register long id;
 	int quotatype;
+	char *fspath;
 {
 	register struct fstab *fs;
 	register struct quotause *qup, *quptail;
@@ -262,6 +267,9 @@
 	quphead = (struct quotause *)0;
 	qcmd = QCMD(Q_GETQUOTA, quotatype);
 	while ((fs = getfsent())) {
+		if (fspath && *fspath && strcmp(fspath, fs->fs_spec) &&
+			strcmp(fspath, fs->fs_file))
+			continue;
 		if (strcmp(fs->fs_vfstype, "ufs"))
 			continue;
 		if (!hasquota(fs, quotatype, &qfpathname))
>Release-Note:
>Audit-Trail:
>Unformatted:

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200109251427.f8PERYu64954>