From 24232b615d41fb5e5e7a5ee56691f4caeacdf216 Mon Sep 17 00:00:00 2001 From: mpp Date: Tue, 15 Jan 2008 06:33:20 +0000 Subject: Quotacheck may possibly skip quota accounting for up to 2 files on a filesystem if the quota data files reside on a different filesystem (e.g. the userquota=/somepath,groupquota=/somepath2 options are specified in /etc/fstab to place the quota files somewhere other than the default location). Fix quotacheck to only skip accounting if the quota data file actually resides on the filesystem being checked. --- sbin/quotacheck/quotacheck.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'sbin') diff --git a/sbin/quotacheck/quotacheck.c b/sbin/quotacheck/quotacheck.c index 1956184..7e4c026 100644 --- a/sbin/quotacheck/quotacheck.c +++ b/sbin/quotacheck/quotacheck.c @@ -275,6 +275,7 @@ chkquota(fsname, mntpt, qnp) union dinode *dp; int cg, i, mode, errs = 0; ino_t ino, inosused, userino = 0, groupino = 0; + dev_t dev, userdev = 0, groupdev = 0; char *cp; struct stat sb; @@ -282,6 +283,11 @@ chkquota(fsname, mntpt, qnp) warn("%s", fsname); return (1); } + if ((stat(mntpt, &sb)) < 0) { + warn("%s", mntpt); + return (1); + } + dev = sb.st_dev; if (vflag) { (void)printf("*** Checking "); if (qnp->flags & HASUSR) @@ -292,12 +298,16 @@ chkquota(fsname, mntpt, qnp) (void)printf(" quotas for %s (%s)\n", fsname, mntpt); } if (qnp->flags & HASUSR) { - if (stat(qnp->usrqfname, &sb) == 0) + if (stat(qnp->usrqfname, &sb) == 0) { userino = sb.st_ino; + userdev = sb.st_dev; + } } if (qnp->flags & HASGRP) { - if (stat(qnp->grpqfname, &sb) == 0) + if (stat(qnp->grpqfname, &sb) == 0) { groupino = sb.st_ino; + groupdev = sb.st_dev; + } } sync(); dev_bsize = 1; @@ -379,7 +389,8 @@ chkquota(fsname, mntpt, qnp) if (DIP(dp, di_flags) & SF_SNAPSHOT) continue; #endif - if (ino == userino || ino == groupino) + if ((ino == userino && dev == userdev) || + (ino == groupino && dev == groupdev)) continue; if (qnp->flags & HASGRP) { fup = addid((u_long)DIP(dp, di_gid), GRPQUOTA, -- cgit v1.1