aboutsummaryrefslogtreecommitdiff
path: root/sbin/quotacheck
diff options
context:
space:
mode:
authorMike Pritchard <mpp@FreeBSD.org>2007-02-04 06:33:15 +0000
committerMike Pritchard <mpp@FreeBSD.org>2007-02-04 06:33:15 +0000
commitfbb42904c4bc7dfb4ed2dba2c277cfe91ad85411 (patch)
tree12409a8c0f64e04f52020f1914b5612c3779d48e /sbin/quotacheck
parent1a7bec91fb6983eee09a4d20a1dad728b64bd183 (diff)
downloadsrc-fbb42904c4bc7dfb4ed2dba2c277cfe91ad85411.tar.gz
src-fbb42904c4bc7dfb4ed2dba2c277cfe91ad85411.zip
If two files systems, /a and /b are marked as having quotas enabled
in fstab and they are normally mounted as /a/b, if /b is not mounted, the various quota utilities will incorrectly operate with the quotas on /a (silently) when operations are attemted on /b. Sync up all the hasquota() routines between all the different quota utilities and change it to detect if the file system we are attempting to perform quota operations on is not currently mounted and warn the user accordingly. PR: bin/38918
Notes
Notes: svn path=/head/; revision=166485
Diffstat (limited to 'sbin/quotacheck')
-rw-r--r--sbin/quotacheck/quotacheck.c23
1 files changed, 17 insertions, 6 deletions
diff --git a/sbin/quotacheck/quotacheck.c b/sbin/quotacheck/quotacheck.c
index 90d895457fe7..02ee25de5af7 100644
--- a/sbin/quotacheck/quotacheck.c
+++ b/sbin/quotacheck/quotacheck.c
@@ -49,6 +49,7 @@ __FBSDID("$FreeBSD$");
*/
#include <sys/param.h>
#include <sys/disklabel.h>
+#include <sys/mount.h>
#include <sys/stat.h>
#include <ufs/ufs/dinode.h>
@@ -587,14 +588,15 @@ hasquota(fs, type, qfnamep)
{
char *opt;
char *cp;
+ struct statfs sfb;
static char initname, usrname[100], grpname[100];
static char buf[BUFSIZ];
if (!initname) {
- (void)snprintf(usrname, sizeof(usrname),
- "%s%s", qfextension[USRQUOTA], qfname);
- (void)snprintf(grpname, sizeof(grpname),
- "%s%s", qfextension[GRPQUOTA], qfname);
+ (void)snprintf(usrname, sizeof(usrname), "%s%s",
+ qfextension[USRQUOTA], qfname);
+ (void)snprintf(grpname, sizeof(grpname), "%s%s",
+ qfextension[GRPQUOTA], qfname);
initname = 1;
}
strcpy(buf, fs->fs_mntops);
@@ -611,10 +613,19 @@ hasquota(fs, type, qfnamep)
if (cp)
*qfnamep = cp;
else {
- (void)snprintf(buf, sizeof(buf),
- "%s/%s.%s", fs->fs_file, qfname, qfextension[type]);
+ (void)snprintf(buf, sizeof(buf), "%s/%s.%s", fs->fs_file,
+ qfname, qfextension[type]);
*qfnamep = buf;
}
+ if (statfs(fs->fs_file, &sfb) != 0) {
+ warn("cannot statfs mount point %s", fs->fs_file);
+ return (0);
+ }
+ if (strcmp(fs->fs_file, sfb.f_mntonname)) {
+ warnx("%s not mounted for %s quotas", fs->fs_file,
+ type == USRQUOTA ? "user" : "group");
+ return (0);
+ }
return (1);
}