summaryrefslogtreecommitdiffstats
path: root/usr.sbin/edquota/edquota.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr.sbin/edquota/edquota.c')
-rw-r--r--usr.sbin/edquota/edquota.c31
1 files changed, 23 insertions, 8 deletions
diff --git a/usr.sbin/edquota/edquota.c b/usr.sbin/edquota/edquota.c
index a333314..83de530 100644
--- a/usr.sbin/edquota/edquota.c
+++ b/usr.sbin/edquota/edquota.c
@@ -52,6 +52,7 @@ __FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/stat.h>
#include <sys/file.h>
+#include <sys/mount.h>
#include <sys/wait.h>
#include <ufs/ufs/quota.h>
#include <ctype.h>
@@ -869,18 +870,21 @@ alldigits(s)
*/
int
hasquota(fs, type, qfnamep)
- register struct fstab *fs;
+ struct fstab *fs;
int type;
char **qfnamep;
{
- register char *opt;
+ char *opt;
char *cp;
+ struct statfs sfb;
static char initname, usrname[100], grpname[100];
static char buf[BUFSIZ];
if (!initname) {
- sprintf(usrname, "%s%s", qfextension[USRQUOTA], qfname);
- sprintf(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);
@@ -894,11 +898,22 @@ hasquota(fs, type, qfnamep)
}
if (!opt)
return (0);
- if (cp) {
+ if (cp)
*qfnamep = cp;
- return (1);
+ else {
+ (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");
+ sleep(3);
+ return (0);
}
- (void) sprintf(buf, "%s/%s.%s", fs->fs_file, qfname, qfextension[type]);
- *qfnamep = buf;
return (1);
}
OpenPOWER on IntegriCloud