diff options
| author | christos <christos@NetBSD.org> | 2012-04-07 04:52:20 +0000 |
|---|---|---|
| committer | christos <christos@NetBSD.org> | 2012-04-07 04:52:20 +0000 |
| commit | 4b41a04ca79c8327ed09eec4dca46abc52aa21d8 (patch) | |
| tree | f0ee8e270b207cb1037fe0dcbd6eb29273f271d2 | |
| parent | 6f7524152bf52d8f0036fc79b625b4033e385cc3 (diff) | |
use getfsspecname()
| -rw-r--r-- | sbin/dump/Makefile | 4 | ||||
| -rw-r--r-- | sbin/dump/main.c | 16 | ||||
| -rw-r--r-- | sbin/dump/optr.c | 13 | ||||
| -rw-r--r-- | sbin/dump_lfs/Makefile | 4 | ||||
| -rw-r--r-- | sbin/fsck/fsck.c | 9 | ||||
| -rw-r--r-- | sbin/fsck/fsutil.c | 10 | ||||
| -rw-r--r-- | sbin/fsck/preen.c | 16 | ||||
| -rw-r--r-- | sbin/swapctl/swapctl.c | 31 | ||||
| -rw-r--r-- | sbin/tunefs/tunefs.c | 16 | ||||
| -rw-r--r-- | usr.sbin/dumpfs/dumpfs.c | 18 | ||||
| -rw-r--r-- | usr.sbin/edquota/edquota.c | 15 | ||||
| -rw-r--r-- | usr.sbin/quotacheck/quotacheck.c | 16 | ||||
| -rw-r--r-- | usr.sbin/quotaon/Makefile | 6 | ||||
| -rw-r--r-- | usr.sbin/quotaon/quotaon.c | 35 |
14 files changed, 138 insertions, 71 deletions
diff --git a/sbin/dump/Makefile b/sbin/dump/Makefile index ac47d8cad38..911eb3446f9 100644 --- a/sbin/dump/Makefile +++ b/sbin/dump/Makefile @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.37 2011/06/20 07:43:59 mrg Exp $ +# $NetBSD: Makefile,v 1.38 2012/04/07 04:52:20 christos Exp $ # @(#)Makefile 8.1 (Berkeley) 6/5/93 # dump.h header file @@ -32,6 +32,8 @@ SRCS= itime.c main.c optr.c dumprmt.c rcache.c snapshot.c tape.c \ traverse.c unctime.c ffs_inode.c ffs_bswap.c MAN= dump.8 MLINKS+=dump.8 rdump.8 +DPADD+= ${LIBUTIL} +LDADD+= -lutil .PATH: ${NETBSDSRCDIR}/sys/ufs/ffs diff --git a/sbin/dump/main.c b/sbin/dump/main.c index 9ec57a99090..68eeafffb74 100644 --- a/sbin/dump/main.c +++ b/sbin/dump/main.c @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.67 2012/02/19 19:49:20 christos Exp $ */ +/* $NetBSD: main.c,v 1.68 2012/04/07 04:52:20 christos Exp $ */ /*- * Copyright (c) 1980, 1991, 1993, 1994 @@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 1991, 1993, 1994\ #if 0 static char sccsid[] = "@(#)main.c 8.6 (Berkeley) 5/1/95"; #else -__RCSID("$NetBSD: main.c,v 1.67 2012/02/19 19:49:20 christos Exp $"); +__RCSID("$NetBSD: main.c,v 1.68 2012/04/07 04:52:20 christos Exp $"); #endif #endif /* not lint */ @@ -65,6 +65,7 @@ __RCSID("$NetBSD: main.c,v 1.67 2012/02/19 19:49:20 christos Exp $"); #include <string.h> #include <time.h> #include <unistd.h> +#include <util.h> #include "dump.h" #include "pathnames.h" @@ -85,7 +86,6 @@ int readblksize = 32 * 1024; /* read block size */ char default_time_string[] = "%T %Z"; /* default timestamp string */ char *time_string = default_time_string; /* timestamp string */ -int main(int, char *[]); static long numarg(const char *, long, long); static void obsolete(int *, char **[]); static void usage(void); @@ -108,6 +108,7 @@ main(int argc, char *argv[]) char *mountpoint; int just_estimate = 0; char labelstr[LBLSIZE]; + char buf[MAXPATHLEN]; char *new_time_format; char *snap_backup = NULL; @@ -294,7 +295,10 @@ main(int argc, char *argv[]) break; } if ((dt = fstabsearch(argv[i])) != NULL) { - disk = dt->fs_spec; + if (getfsspecname(buf, sizeof(buf), dt->fs_spec) + == NULL) + quit("%s (%s)", buf, strerror(errno)); + disk = buf; mountpoint = xstrdup(dt->fs_file); goto multicheck; } @@ -402,7 +406,9 @@ main(int argc, char *argv[]) mountpoint = NULL; mntinfo = mntinfosearch(disk); if ((dt = fstabsearch(disk)) != NULL) { - disk = rawname(dt->fs_spec); + if (getfsspecname(buf, sizeof(buf), dt->fs_spec) == NULL) + quit("%s (%s)", buf, strerror(errno)); + disk = rawname(buf); mountpoint = dt->fs_file; msg("Found %s on %s in %s\n", disk, mountpoint, _PATH_FSTAB); } else if (mntinfo != NULL) { diff --git a/sbin/dump/optr.c b/sbin/dump/optr.c index b11f47467b7..69000d1103d 100644 --- a/sbin/dump/optr.c +++ b/sbin/dump/optr.c @@ -1,4 +1,4 @@ -/* $NetBSD: optr.c,v 1.36 2006/12/18 20:07:32 christos Exp $ */ +/* $NetBSD: optr.c,v 1.37 2012/04/07 04:52:20 christos Exp $ */ /*- * Copyright (c) 1980, 1988, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)optr.c 8.2 (Berkeley) 1/6/94"; #else -__RCSID("$NetBSD: optr.c,v 1.36 2006/12/18 20:07:32 christos Exp $"); +__RCSID("$NetBSD: optr.c,v 1.37 2012/04/07 04:52:20 christos Exp $"); #endif #endif /* not lint */ @@ -56,6 +56,7 @@ __RCSID("$NetBSD: optr.c,v 1.36 2006/12/18 20:07:32 christos Exp $"); #include <time.h> #include <tzfile.h> #include <unistd.h> +#include <util.h> #include <ufs/ufs/dinode.h> @@ -321,11 +322,15 @@ struct fstab * allocfsent(struct fstab *fs) { struct fstab *new; + char buf[MAXPATHLEN]; - new = (struct fstab *)xmalloc(sizeof (*fs)); + new = xmalloc(sizeof (*fs)); new->fs_file = xstrdup(fs->fs_file); new->fs_type = xstrdup(fs->fs_type); - new->fs_spec = xstrdup(fs->fs_spec); + + if (getfsspecname(buf, sizeof(buf), fs->fs_spec) == NULL) + msg("%s (%s)", buf, strerror(errno)); + new->fs_spec = xstrdup(buf); new->fs_passno = fs->fs_passno; new->fs_freq = fs->fs_freq; return (new); diff --git a/sbin/dump_lfs/Makefile b/sbin/dump_lfs/Makefile index ca652be303a..1f67d121926 100644 --- a/sbin/dump_lfs/Makefile +++ b/sbin/dump_lfs/Makefile @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.13 2011/08/14 12:13:24 christos Exp $ +# $NetBSD: Makefile,v 1.14 2012/04/07 04:52:20 christos Exp $ # @(#)Makefile 8.1 (Berkeley) 6/5/93 # lfs_inode.c LFS filestore-specific routines @@ -20,6 +20,8 @@ SRCS= itime.c main.c optr.c dumprmt.c rcache.c snapshot.c tape.c \ MAN= dump_lfs.8 MLINKS+=dump_lfs.8 rdump_lfs.8 #CFLAGS+=-g +DPADD+= ${LIBUTIL} +LDADD+= -lutil .if ${MACHINE_ARCH} == "m68000" COPTS.lfs_inode.c+= -fno-tree-ter diff --git a/sbin/fsck/fsck.c b/sbin/fsck/fsck.c index 4ab17287545..e1924e8cd0f 100644 --- a/sbin/fsck/fsck.c +++ b/sbin/fsck/fsck.c @@ -1,4 +1,4 @@ -/* $NetBSD: fsck.c,v 1.50 2011/08/27 17:34:44 joerg Exp $ */ +/* $NetBSD: fsck.c,v 1.51 2012/04/07 04:52:20 christos Exp $ */ /* * Copyright (c) 1996 Christos Zoulas. All rights reserved. @@ -36,7 +36,7 @@ #include <sys/cdefs.h> #ifndef lint -__RCSID("$NetBSD: fsck.c,v 1.50 2011/08/27 17:34:44 joerg Exp $"); +__RCSID("$NetBSD: fsck.c,v 1.51 2012/04/07 04:52:20 christos Exp $"); #endif /* not lint */ #include <sys/param.h> @@ -100,6 +100,7 @@ main(int argc, char *argv[]) const char *vfstype = NULL; char globopt[3]; int ret = FSCK_EXIT_OK; + char buf[MAXPATHLEN]; globopt[0] = '-'; globopt[2] = '\0'; @@ -212,7 +213,9 @@ main(int argc, char *argv[]) type = vfstype; } else { - spec = fs->fs_spec; + spec = getfsspecname(buf, sizeof(buf), fs->fs_spec); + if (spec == NULL) + err(FSCK_EXIT_CHECK_FAILED, "%s", buf); type = fs->fs_vfstype; if (BADTYPE(fs->fs_type)) errx(FSCK_EXIT_CHECK_FAILED, diff --git a/sbin/fsck/fsutil.c b/sbin/fsck/fsutil.c index 100de1328dc..20bf81e3b53 100644 --- a/sbin/fsck/fsutil.c +++ b/sbin/fsck/fsutil.c @@ -1,4 +1,4 @@ -/* $NetBSD: fsutil.c,v 1.20 2011/06/09 19:57:50 christos Exp $ */ +/* $NetBSD: fsutil.c,v 1.21 2012/04/07 04:52:20 christos Exp $ */ /* * Copyright (c) 1990, 1993 @@ -31,7 +31,7 @@ #include <sys/cdefs.h> #ifndef lint -__RCSID("$NetBSD: fsutil.c,v 1.20 2011/06/09 19:57:50 christos Exp $"); +__RCSID("$NetBSD: fsutil.c,v 1.21 2012/04/07 04:52:20 christos Exp $"); #endif /* not lint */ #include <sys/param.h> @@ -45,6 +45,7 @@ __RCSID("$NetBSD: fsutil.c,v 1.20 2011/06/09 19:57:50 christos Exp $"); #include <fcntl.h> #include <unistd.h> #include <err.h> +#include <util.h> #include <sys/types.h> #include <sys/stat.h> @@ -236,7 +237,10 @@ retry: retried++; goto retry; } else if ((fsp = getfsfile(newname)) != 0 && !retried) { - newname = fsp->fs_spec; + char buf[MAXPATHLEN]; + newname = getfsspecname(buf, sizeof(buf), fsp->fs_spec); + if (newname == NULL) + perr("%s", buf); retried++; goto retry; } diff --git a/sbin/fsck/preen.c b/sbin/fsck/preen.c index 23d33d5e422..d71de32a1dd 100644 --- a/sbin/fsck/preen.c +++ b/sbin/fsck/preen.c @@ -1,4 +1,4 @@ -/* $NetBSD: preen.c,v 1.30 2008/02/23 21:41:47 christos Exp $ */ +/* $NetBSD: preen.c,v 1.31 2012/04/07 04:52:20 christos Exp $ */ /* * Copyright (c) 1990, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)preen.c 8.5 (Berkeley) 4/28/95"; #else -__RCSID("$NetBSD: preen.c,v 1.30 2008/02/23 21:41:47 christos Exp $"); +__RCSID("$NetBSD: preen.c,v 1.31 2012/04/07 04:52:20 christos Exp $"); #endif #endif /* not lint */ @@ -108,10 +108,16 @@ checkfstab(int flags, int maxrun, void *(*docheck)(struct fstab *), return FSCK_EXIT_CHECK_FAILED; } while ((fs = getfsent()) != 0) { + char buf[MAXPATHLEN]; + const char *fsspec; if ((auxarg = (*docheck)(fs)) == NULL) continue; - - name = blockcheck(fs->fs_spec); + fsspec = getfsspecname(buf, sizeof(buf), fs->fs_spec); + if (fsspec == NULL) { + warn("%s", buf); + return FSCK_EXIT_CHECK_FAILED; + } + name = blockcheck(fsspec); if (flags & CHECK_DEBUG) printf("pass %d, name %s\n", passno, name); @@ -135,7 +141,7 @@ checkfstab(int flags, int maxrun, void *(*docheck)(struct fstab *), } else if (passno == 2 && fs->fs_passno > 1) { if (name == NULL) { (void) fprintf(stderr, - "BAD DISK NAME %s\n", fs->fs_spec); + "BAD DISK NAME %s\n", fsspec); sumstatus = FSCK_EXIT_CHECK_FAILED; continue; } diff --git a/sbin/swapctl/swapctl.c b/sbin/swapctl/swapctl.c index 0a644194805..59535ce8a44 100644 --- a/sbin/swapctl/swapctl.c +++ b/sbin/swapctl/swapctl.c @@ -1,4 +1,4 @@ -/* $NetBSD: swapctl.c,v 1.36 2011/08/27 18:57:50 joerg Exp $ */ +/* $NetBSD: swapctl.c,v 1.37 2012/04/07 04:52:20 christos Exp $ */ /* * Copyright (c) 1996, 1997, 1999 Matthew R. Green @@ -64,7 +64,7 @@ #include <sys/cdefs.h> #ifndef lint -__RCSID("$NetBSD: swapctl.c,v 1.36 2011/08/27 18:57:50 joerg Exp $"); +__RCSID("$NetBSD: swapctl.c,v 1.37 2012/04/07 04:52:20 christos Exp $"); #endif @@ -695,9 +695,14 @@ do_fstab(int add) #define PRIORITYEQ "priority=" #define NFSMNTPT "nfsmntpt=" while ((fp = getfsent()) != NULL) { - char *spec; + char buf[MAXPATHLEN]; + char *spec, *fsspec; - spec = fp->fs_spec; + if (getfsspecname(buf, sizeof(buf), fp->fs_spec) == NULL) { + warn("%s", buf); + continue; + } + fsspec = spec = buf; cmd[0] = '\0'; if (strcmp(fp->fs_type, "dp") == 0 && add) { @@ -747,14 +752,14 @@ do_fstab(int add) } if (add) { snprintf(cmd, sizeof(cmd), "%s %s %s", - PATH_MOUNT, fp->fs_spec, spec); + PATH_MOUNT, fsspec, spec); if (system(cmd) != 0) { - warnx("%s: mount failed", fp->fs_spec); + warnx("%s: mount failed", fsspec); continue; } } else { snprintf(cmd, sizeof(cmd), "%s %s", - PATH_UMOUNT, fp->fs_spec); + PATH_UMOUNT, fsspec); } } else { /* @@ -783,35 +788,35 @@ do_fstab(int add) success = 1; printf( "%s: adding %s as swap device at priority %d\n", - getprogname(), fp->fs_spec, (int)priority); + getprogname(), fsspec, (int)priority); } else { error = 1; fprintf(stderr, "%s: failed to add %s as swap device\n", - getprogname(), fp->fs_spec); + getprogname(), fsspec); } } else { if (delete_swap(spec)) { success = 1; printf( "%s: removing %s as swap device\n", - getprogname(), fp->fs_spec); + getprogname(), fsspec); } else { error = 1; fprintf(stderr, "%s: failed to remove %s as swap device\n", - getprogname(), fp->fs_spec); + getprogname(), fsspec); } if (cmd[0]) { if (system(cmd) != 0) { - warnx("%s: umount failed", fp->fs_spec); + warnx("%s: umount failed", fsspec); error = 1; continue; } } } - if (spec != fp->fs_spec) + if (spec != fsspec) free(spec); } if (error) diff --git a/sbin/tunefs/tunefs.c b/sbin/tunefs/tunefs.c index fdbe79928ae..fb5fea18b99 100644 --- a/sbin/tunefs/tunefs.c +++ b/sbin/tunefs/tunefs.c @@ -1,4 +1,4 @@ -/* $NetBSD: tunefs.c,v 1.44 2011/08/29 14:35:04 joerg Exp $ */ +/* $NetBSD: tunefs.c,v 1.45 2012/04/07 04:52:21 christos Exp $ */ /* * Copyright (c) 1983, 1993 @@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1983, 1993\ #if 0 static char sccsid[] = "@(#)tunefs.c 8.3 (Berkeley) 5/3/95"; #else -__RCSID("$NetBSD: tunefs.c,v 1.44 2011/08/29 14:35:04 joerg Exp $"); +__RCSID("$NetBSD: tunefs.c,v 1.45 2012/04/07 04:52:21 christos Exp $"); #endif #endif /* not lint */ @@ -549,18 +549,22 @@ bread(daddr_t blk, char *buffer, int cnt, const char *file) 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) + err(4, "%s", xbuf); + 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) { diff --git a/usr.sbin/dumpfs/dumpfs.c b/usr.sbin/dumpfs/dumpfs.c index 298619f133e..a16439dc3ab 100644 --- a/usr.sbin/dumpfs/dumpfs.c +++ b/usr.sbin/dumpfs/dumpfs.c @@ -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, 1992, 1993\ #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) { diff --git a/usr.sbin/edquota/edquota.c b/usr.sbin/edquota/edquota.c index 8c05aba53d6..d88a246cc04 100644 --- a/usr.sbin/edquota/edquota.c +++ b/usr.sbin/edquota/edquota.c @@ -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, 1990, 1993\ #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/01/30 19:19:20 dholland Exp $"); #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 char *filesys) 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; } diff --git a/usr.sbin/quotacheck/quotacheck.c b/usr.sbin/quotacheck/quotacheck.c index c256f5fc4d6..b9ef4c69867 100644 --- a/usr.sbin/quotacheck/quotacheck.c +++ b/usr.sbin/quotacheck/quotacheck.c @@ -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, 1990, 1993\ #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 2011/03/06 23:25:42 christos Exp $"); #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); diff --git a/usr.sbin/quotaon/Makefile b/usr.sbin/quotaon/Makefile index 8b10728a908..a4dda4bf15d 100644 --- a/usr.sbin/quotaon/Makefile +++ b/usr.sbin/quotaon/Makefile @@ -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> diff --git a/usr.sbin/quotaon/quotaon.c b/usr.sbin/quotaon/quotaon.c index 51a6f51c42c..0485cf1a21f 100644 --- a/usr.sbin/quotaon/quotaon.c +++ b/usr.sbin/quotaon/quotaon.c @@ -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, 1990, 1993\ #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/01/30 16:45:13 dholland Exp $"); #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 quotahandle *qh, int offmode, int idtype, * 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; } |
