Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sbin/fsck Don't re-use the same buffer that we pass in for n...
details: https://anonhg.NetBSD.org/src/rev/f0e165a948a2
branches: trunk
changeset: 778674:f0e165a948a2
user: christos <christos%NetBSD.org@localhost>
date: Sun Apr 08 04:19:14 2012 +0000
description:
Don't re-use the same buffer that we pass in for newname in the cooked->raw
conversion. Better variable names.
diffstat:
sbin/fsck/fsutil.c | 28 ++++++++++++++--------------
1 files changed, 14 insertions(+), 14 deletions(-)
diffs (83 lines):
diff -r f24c70e09ddd -r f0e165a948a2 sbin/fsck/fsutil.c
--- a/sbin/fsck/fsutil.c Sun Apr 08 03:11:14 2012 +0000
+++ b/sbin/fsck/fsutil.c Sun Apr 08 04:19:14 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: fsutil.c,v 1.22 2012/04/07 16:44:10 christos Exp $ */
+/* $NetBSD: fsutil.c,v 1.23 2012/04/08 04:19:14 christos Exp $ */
/*
* Copyright (c) 1990, 1993
@@ -31,7 +31,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: fsutil.c,v 1.22 2012/04/07 16:44:10 christos Exp $");
+__RCSID("$NetBSD: fsutil.c,v 1.23 2012/04/08 04:19:14 christos Exp $");
#endif /* not lint */
#include <sys/param.h>
@@ -170,9 +170,10 @@
blockcheck(const char *origname)
{
struct stat stslash, stblock, stchar;
- const char *newname, *raw;
+ const char *newname, *raw, *cooked;
struct fstab *fsp;
int retried = 0;
+ char cbuf[MAXPATHLEN];
static char buf[MAXPATHLEN];
hot = 0;
@@ -184,7 +185,7 @@
retry:
if (stat(newname, &stblock) < 0) {
perr("Can't stat `%s'", newname);
- return (origname);
+ return origname;
}
if (S_ISBLK(stblock.st_mode)) {
if (stslash.st_dev == stblock.st_rdev)
@@ -196,26 +197,25 @@
}
if (stat(raw, &stchar) < 0) {
perr("Can't stat `%s'", raw);
- return (origname);
+ return origname;
}
if (S_ISCHR(stchar.st_mode)) {
- return (raw);
+ return raw;
} else {
- printf("%s is not a character device\n", raw);
- return (origname);
+ perr("%s is not a character device\n", raw);
+ return origname;
}
} else if (S_ISCHR(stblock.st_mode) && !retried) {
- raw = getdiskcookedname(buf, sizeof(buf), newname);
- if (raw == NULL) {
+ cooked = getdiskcookedname(cbuf, sizeof(cbuf), newname);
+ if (cooked == NULL) {
perr("Can't convert to cooked `%s'", newname);
return origname;
} else
- newname = raw;
+ newname = cooked;
retried++;
goto retry;
} else if ((fsp = getfsfile(newname)) != 0 && !retried) {
- char rbuf[MAXPATHLEN];
- newname = getfsspecname(rbuf, sizeof(rbuf), fsp->fs_spec);
+ newname = getfsspecname(cbuf, sizeof(cbuf), fsp->fs_spec);
if (newname == NULL)
perr("%s", buf);
retried++;
@@ -225,7 +225,7 @@
* Not a block or character device, just return name and
* let the user decide whether to use it.
*/
- return (origname);
+ return origname;
}
const char *
Home |
Main Index |
Thread Index |
Old Index