Module Name: src
Committed By: christos
Date: Sat Apr 7 05:07:33 UTC 2012
Modified Files:
src/usr.sbin/dumpfs: dumpfs.c
src/usr.sbin/edquota: edquota.c
src/usr.sbin/quotacheck: quotacheck.c
src/usr.sbin/quotaon: Makefile quotaon.c
Log Message:
use getfsspecname()
To generate a diff of this commit:
cvs rdiff -u -r1.58 -r1.59 src/usr.sbin/dumpfs/dumpfs.c
cvs rdiff -u -r1.46 -r1.47 src/usr.sbin/edquota/edquota.c
cvs rdiff -u -r1.44 -r1.45 src/usr.sbin/quotacheck/quotacheck.c
cvs rdiff -u -r1.10 -r1.11 src/usr.sbin/quotaon/Makefile
cvs rdiff -u -r1.29 -r1.30 src/usr.sbin/quotaon/quotaon.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/usr.sbin/dumpfs/dumpfs.c
diff -u src/usr.sbin/dumpfs/dumpfs.c:1.58 src/usr.sbin/dumpfs/dumpfs.c:1.59
--- src/usr.sbin/dumpfs/dumpfs.c:1.58 Tue Aug 30 14:24:17 2011
+++ src/usr.sbin/dumpfs/dumpfs.c Sat Apr 7 01:07:32 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: dumpfs.c,v 1.58 2011/08/30 18:24:17 joerg Exp $ */
+/* $NetBSD: dumpfs.c,v 1.59 2012/04/07 05:07:32 christos Exp $ */
/*
* Copyright (c) 1983, 1992, 1993
@@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1983, 19
#if 0
static char sccsid[] = "@(#)dumpfs.c 8.5 (Berkeley) 4/29/95";
#else
-__RCSID("$NetBSD: dumpfs.c,v 1.58 2011/08/30 18:24:17 joerg Exp $");
+__RCSID("$NetBSD: dumpfs.c,v 1.59 2012/04/07 05:07:32 christos Exp $");
#endif
#endif /* not lint */
@@ -911,18 +911,24 @@ usage(void)
static int
openpartition(const char *name, int flags, char *device, size_t devicelen)
{
- char rawspec[MAXPATHLEN], *p;
+ char rawspec[MAXPATHLEN], xbuf[MAXPATHLEN], *p;
struct fstab *fs;
int fd, oerrno;
fs = getfsfile(name);
if (fs) {
- if ((p = strrchr(fs->fs_spec, '/')) != NULL) {
+ const char *fsspec;
+ fsspec = getfsspecname(xbuf, sizeof(xbuf), fs->fs_spec);
+ if (fsspec == NULL) {
+ warn("%s", xbuf);
+ return -1;
+ }
+ if ((p = strrchr(fsspec, '/')) != NULL) {
snprintf(rawspec, sizeof(rawspec), "%.*s/r%s",
- (int)(p - fs->fs_spec), fs->fs_spec, p + 1);
+ (int)(p - fsspec), fsspec, p + 1);
name = rawspec;
} else
- name = fs->fs_spec;
+ name = fsspec;
}
fd = opendisk(name, flags, device, devicelen, 0);
if (fd == -1 && errno == ENOENT) {
Index: src/usr.sbin/edquota/edquota.c
diff -u src/usr.sbin/edquota/edquota.c:1.46 src/usr.sbin/edquota/edquota.c:1.47
--- src/usr.sbin/edquota/edquota.c:1.46 Mon Jan 30 14:19:20 2012
+++ src/usr.sbin/edquota/edquota.c Sat Apr 7 01:07:32 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: edquota.c,v 1.46 2012/01/30 19:19:20 dholland Exp $ */
+/* $NetBSD: edquota.c,v 1.47 2012/04/07 05:07:32 christos Exp $ */
/*
* Copyright (c) 1980, 1990, 1993
* The Regents of the University of California. All rights reserved.
@@ -41,7 +41,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 19
#if 0
static char sccsid[] = "from: @(#)edquota.c 8.3 (Berkeley) 4/27/95";
#else
-__RCSID("$NetBSD: edquota.c,v 1.46 2012/01/30 19:19:20 dholland Exp $");
+__RCSID("$NetBSD: edquota.c,v 1.47 2012/04/07 05:07:32 christos Exp $");
#endif
#endif /* not lint */
@@ -71,6 +71,7 @@ __RCSID("$NetBSD: edquota.c,v 1.46 2012/
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <util.h>
#include "printquota.h"
@@ -279,7 +280,8 @@ static struct quotause *
getprivs1(long id, int idtype, const char *filesys)
{
struct fstab *fs;
- char qfpathname[MAXPATHLEN];
+ char qfpathname[MAXPATHLEN], xbuf[MAXPATHLEN];
+ const char *fsspec;
struct quotause *qup;
struct dqblk dqblk;
int fd;
@@ -288,7 +290,12 @@ getprivs1(long id, int idtype, const cha
while ((fs = getfsent()) != NULL) {
if (strcmp(fs->fs_vfstype, "ffs"))
continue;
- if (strcmp(fs->fs_spec, filesys) == 0 ||
+ fsspec = getfsspecname(xbuf, sizeof(xbuf), fs->fs_spec);
+ if (fsspec == NULL) {
+ warn("%s", xbuf);
+ continue;
+ }
+ if (strcmp(fsspec, filesys) == 0 ||
strcmp(fs->fs_file, filesys) == 0)
break;
}
Index: src/usr.sbin/quotacheck/quotacheck.c
diff -u src/usr.sbin/quotacheck/quotacheck.c:1.44 src/usr.sbin/quotacheck/quotacheck.c:1.45
--- src/usr.sbin/quotacheck/quotacheck.c:1.44 Sun Mar 6 18:25:42 2011
+++ src/usr.sbin/quotacheck/quotacheck.c Sat Apr 7 01:07:32 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: quotacheck.c,v 1.44 2011/03/06 23:25:42 christos Exp $ */
+/* $NetBSD: quotacheck.c,v 1.45 2012/04/07 05:07:32 christos Exp $ */
/*
* Copyright (c) 1980, 1990, 1993
@@ -42,7 +42,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 19
#if 0
static char sccsid[] = "@(#)quotacheck.c 8.6 (Berkeley) 4/28/95";
#else
-__RCSID("$NetBSD: quotacheck.c,v 1.44 2011/03/06 23:25:42 christos Exp $");
+__RCSID("$NetBSD: quotacheck.c,v 1.45 2012/04/07 05:07:32 christos Exp $");
#endif
#endif /* not lint */
@@ -70,6 +70,7 @@ __RCSID("$NetBSD: quotacheck.c,v 1.44 20
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <util.h>
#include "fsutil.h"
#include "quotautil.h"
@@ -248,10 +249,17 @@ main(int argc, char *argv[])
if (setfsent() == 0)
err(1, "%s: can't open", FSTAB);
while ((fs = getfsent()) != NULL) {
+ const char *fsspec;
+ char buf[MAXPATHLEN];
+ fsspec = getfsspecname(buf, sizeof(buf), fs->fs_spec);
+ if (fsspec == NULL) {
+ warn("%s", buf);
+ continue;
+ }
if (((argnum = oneof(fs->fs_file, argv, argc)) >= 0 ||
- (argnum = oneof(fs->fs_spec, argv, argc)) >= 0) &&
+ (argnum = oneof(fsspec, argv, argc)) >= 0) &&
(auxdata = needchk(fs)) &&
- (name = blockcheck(fs->fs_spec))) {
+ (name = blockcheck(fsspec))) {
done |= 1 << argnum;
errs += chkquota(fs->fs_type, name, fs->fs_file,
auxdata, NULL);
Index: src/usr.sbin/quotaon/Makefile
diff -u src/usr.sbin/quotaon/Makefile:1.10 src/usr.sbin/quotaon/Makefile:1.11
--- src/usr.sbin/quotaon/Makefile:1.10 Wed Feb 1 12:53:01 2012
+++ src/usr.sbin/quotaon/Makefile Sat Apr 7 01:07:32 2012
@@ -1,5 +1,5 @@
# from: @(#)Makefile 8.1 (Berkeley) 6/6/93
-# $NetBSD: Makefile,v 1.10 2012/02/01 17:53:01 dholland Exp $
+# $NetBSD: Makefile,v 1.11 2012/04/07 05:07:32 christos Exp $
.include <bsd.own.mk>
WARNS ?= 4
@@ -10,7 +10,7 @@ MAN= quotaon.8
MLINKS= quotaon.8 quotaoff.8
LINKS= ${BINDIR}/quotaon ${BINDIR}/quotaoff
-DPADD= ${LIBQUOTA} ${LIBRPCSVC}
-LDADD= -lquota -lrpcsvc
+DPADD= ${LIBQUOTA} ${LIBRPCSVC} ${LIBUTIL}
+LDADD= -lquota -lrpcsvc -lutil
.include <bsd.prog.mk>
Index: src/usr.sbin/quotaon/quotaon.c
diff -u src/usr.sbin/quotaon/quotaon.c:1.29 src/usr.sbin/quotaon/quotaon.c:1.30
--- src/usr.sbin/quotaon/quotaon.c:1.29 Mon Jan 30 11:45:13 2012
+++ src/usr.sbin/quotaon/quotaon.c Sat Apr 7 01:07:33 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: quotaon.c,v 1.29 2012/01/30 16:45:13 dholland Exp $ */
+/* $NetBSD: quotaon.c,v 1.30 2012/04/07 05:07:33 christos Exp $ */
/*
* Copyright (c) 1980, 1990, 1993
@@ -42,7 +42,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 19
#if 0
static char sccsid[] = "@(#)quotaon.c 8.1 (Berkeley) 6/6/93";
#else
-__RCSID("$NetBSD: quotaon.c,v 1.29 2012/01/30 16:45:13 dholland Exp $");
+__RCSID("$NetBSD: quotaon.c,v 1.30 2012/04/07 05:07:33 christos Exp $");
#endif
#endif /* not lint */
@@ -63,13 +63,15 @@ __RCSID("$NetBSD: quotaon.c,v 1.29 2012/
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <util.h>
static int vflag; /* verbose */
static void usage(void) __dead;
-static int quotaonoff(struct fstab *, struct quotahandle *, int, int, int);
-static int readonly(struct fstab *);
+static int quotaonoff(struct fstab *, struct quotahandle *, int, int, int,
+ const char *);
+static int readonly(struct fstab *, const char *);
static int oneof(const char *target, char *list[], int cnt);
int
@@ -133,14 +135,21 @@ main(int argc, char *argv[])
setfsent();
while ((fs = getfsent()) != NULL) {
+ char buf[MAXPATHLEN];
+ const char *fsspec;
if ((strcmp(fs->fs_vfstype, "ffs") &&
strcmp(fs->fs_vfstype, "lfs")) ||
strcmp(fs->fs_type, FSTAB_RW))
continue;
+ fsspec = getfsspecname(buf, sizeof(buf), fs->fs_spec);
+ if (fsspec == NULL) {
+ warn("%s", buf);
+ continue;
+ }
if (!aflag) {
if ((argnum = oneof(fs->fs_file, argv, argc)) < 0 &&
- (argnum = oneof(fs->fs_spec, argv, argc)) < 0) {
+ (argnum = oneof(fsspec, argv, argc)) < 0) {
continue;
}
done |= 1U << argnum;
@@ -176,14 +185,14 @@ main(int argc, char *argv[])
*/
if (noguflag) {
- errs += quotaonoff(fs, qh, offmode, GRPQUOTA, 0);
- errs += quotaonoff(fs, qh, offmode, USRQUOTA, 0);
+ errs += quotaonoff(fs, qh, offmode, GRPQUOTA, 0, fsspec);
+ errs += quotaonoff(fs, qh, offmode, USRQUOTA, 0, fsspec);
}
if (gflag) {
- errs += quotaonoff(fs, qh, offmode, GRPQUOTA, 1);
+ errs += quotaonoff(fs, qh, offmode, GRPQUOTA, 1, fsspec);
}
if (uflag) {
- errs += quotaonoff(fs, qh, offmode, USRQUOTA, 1);
+ errs += quotaonoff(fs, qh, offmode, USRQUOTA, 1, fsspec);
}
quota_close(qh);
}
@@ -205,11 +214,11 @@ usage(void)
static int
quotaonoff(struct fstab *fs, struct quotahandle *qh, int offmode, int idtype,
- int warn_on_enxio)
+ int warn_on_enxio, const char *fsspec)
{
const char *mode = (offmode == 1) ? "off" : "on";
- if (strcmp(fs->fs_file, "/") && readonly(fs)) {
+ if (strcmp(fs->fs_file, "/") && readonly(fs, fsspec)) {
return 1;
}
@@ -240,13 +249,13 @@ quotaonoff(struct fstab *fs, struct quot
* Verify file system is mounted and not readonly.
*/
static int
-readonly(struct fstab *fs)
+readonly(struct fstab *fs, const char *fsspec)
{
struct statvfs fsbuf;
if (statvfs(fs->fs_file, &fsbuf) < 0 ||
strcmp(fsbuf.f_mntonname, fs->fs_file) ||
- strcmp(fsbuf.f_mntfromname, fs->fs_spec)) {
+ strcmp(fsbuf.f_mntfromname, fsspec)) {
printf("%s: not mounted\n", fs->fs_file);
return 1;
}