Module Name:    src
Committed By:   christos
Date:           Sat Apr  7 04:52:21 UTC 2012

Modified Files:
        src/sbin/dump: Makefile main.c optr.c
        src/sbin/dump_lfs: Makefile
        src/sbin/fsck: fsck.c fsutil.c preen.c
        src/sbin/swapctl: swapctl.c
        src/sbin/tunefs: tunefs.c

Log Message:
use getfsspecname()


To generate a diff of this commit:
cvs rdiff -u -r1.37 -r1.38 src/sbin/dump/Makefile
cvs rdiff -u -r1.67 -r1.68 src/sbin/dump/main.c
cvs rdiff -u -r1.36 -r1.37 src/sbin/dump/optr.c
cvs rdiff -u -r1.13 -r1.14 src/sbin/dump_lfs/Makefile
cvs rdiff -u -r1.50 -r1.51 src/sbin/fsck/fsck.c
cvs rdiff -u -r1.20 -r1.21 src/sbin/fsck/fsutil.c
cvs rdiff -u -r1.30 -r1.31 src/sbin/fsck/preen.c
cvs rdiff -u -r1.36 -r1.37 src/sbin/swapctl/swapctl.c
cvs rdiff -u -r1.44 -r1.45 src/sbin/tunefs/tunefs.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/dump/Makefile
diff -u src/sbin/dump/Makefile:1.37 src/sbin/dump/Makefile:1.38
--- src/sbin/dump/Makefile:1.37	Mon Jun 20 03:43:59 2011
+++ src/sbin/dump/Makefile	Sat Apr  7 00:52:20 2012
@@ -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 rc
 	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
 

Index: src/sbin/dump/main.c
diff -u src/sbin/dump/main.c:1.67 src/sbin/dump/main.c:1.68
--- src/sbin/dump/main.c:1.67	Sun Feb 19 14:49:20 2012
+++ src/sbin/dump/main.c	Sat Apr  7 00:52:20 2012
@@ -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, 19
 #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/
 #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 blo
 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) {

Index: src/sbin/dump/optr.c
diff -u src/sbin/dump/optr.c:1.36 src/sbin/dump/optr.c:1.37
--- src/sbin/dump/optr.c:1.36	Mon Dec 18 15:07:32 2006
+++ src/sbin/dump/optr.c	Sat Apr  7 00:52:20 2012
@@ -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/
 #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);

Index: src/sbin/dump_lfs/Makefile
diff -u src/sbin/dump_lfs/Makefile:1.13 src/sbin/dump_lfs/Makefile:1.14
--- src/sbin/dump_lfs/Makefile:1.13	Sun Aug 14 08:13:24 2011
+++ src/sbin/dump_lfs/Makefile	Sat Apr  7 00:52:20 2012
@@ -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 rc
 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

Index: src/sbin/fsck/fsck.c
diff -u src/sbin/fsck/fsck.c:1.50 src/sbin/fsck/fsck.c:1.51
--- src/sbin/fsck/fsck.c:1.50	Sat Aug 27 13:34:44 2011
+++ src/sbin/fsck/fsck.c	Sat Apr  7 00:52:20 2012
@@ -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,

Index: src/sbin/fsck/fsutil.c
diff -u src/sbin/fsck/fsutil.c:1.20 src/sbin/fsck/fsutil.c:1.21
--- src/sbin/fsck/fsutil.c:1.20	Thu Jun  9 15:57:50 2011
+++ src/sbin/fsck/fsutil.c	Sat Apr  7 00:52:20 2012
@@ -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/0
 #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;
 	}

Index: src/sbin/fsck/preen.c
diff -u src/sbin/fsck/preen.c:1.30 src/sbin/fsck/preen.c:1.31
--- src/sbin/fsck/preen.c:1.30	Sat Feb 23 16:41:47 2008
+++ src/sbin/fsck/preen.c	Sat Apr  7 00:52:20 2012
@@ -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 *
 			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 *
 			} 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;
 				}

Index: src/sbin/swapctl/swapctl.c
diff -u src/sbin/swapctl/swapctl.c:1.36 src/sbin/swapctl/swapctl.c:1.37
--- src/sbin/swapctl/swapctl.c:1.36	Sat Aug 27 14:57:50 2011
+++ src/sbin/swapctl/swapctl.c	Sat Apr  7 00:52:20 2012
@@ -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)

Index: src/sbin/tunefs/tunefs.c
diff -u src/sbin/tunefs/tunefs.c:1.44 src/sbin/tunefs/tunefs.c:1.45
--- src/sbin/tunefs/tunefs.c:1.44	Mon Aug 29 10:35:04 2011
+++ src/sbin/tunefs/tunefs.c	Sat Apr  7 00:52:21 2012
@@ -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, 19
 #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
 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) {

Reply via email to