Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sbin/tunefs Use getfsspecname also when not found in /etc/fs...
details: https://anonhg.NetBSD.org/src/rev/f4df0a30a02a
branches: trunk
changeset: 340193:f4df0a30a02a
user: mlelstv <mlelstv%NetBSD.org@localhost>
date: Wed Aug 26 05:41:20 2015 +0000
description:
Use getfsspecname also when not found in /etc/fstab.
diffstat:
sbin/tunefs/tunefs.c | 33 ++++++++++++++++-----------------
1 files changed, 16 insertions(+), 17 deletions(-)
diffs (60 lines):
diff -r 7c22d2e34f41 -r f4df0a30a02a sbin/tunefs/tunefs.c
--- a/sbin/tunefs/tunefs.c Wed Aug 26 03:00:52 2015 +0000
+++ b/sbin/tunefs/tunefs.c Wed Aug 26 05:41:20 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tunefs.c,v 1.48 2014/08/09 10:33:46 mlelstv Exp $ */
+/* $NetBSD: tunefs.c,v 1.49 2015/08/26 05:41:20 mlelstv Exp $ */
/*
* Copyright (c) 1983, 1993
@@ -39,7 +39,7 @@
#if 0
static char sccsid[] = "@(#)tunefs.c 8.3 (Berkeley) 5/3/95";
#else
-__RCSID("$NetBSD: tunefs.c,v 1.48 2014/08/09 10:33:46 mlelstv Exp $");
+__RCSID("$NetBSD: tunefs.c,v 1.49 2015/08/26 05:41:20 mlelstv Exp $");
#endif
#endif /* not lint */
@@ -588,27 +588,26 @@
static int
openpartition(const char *name, int flags, char *device, size_t devicelen)
{
- char rawspec[MAXPATHLEN], xbuf[MAXPATHLEN], *p;
+ char specname[MAXPATHLEN];
+ char rawname[MAXPATHLEN];
+ const char *special, *raw;
struct fstab *fs;
int fd, oerrno;
fs = getfsfile(name);
- if (fs) {
- 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 - fsspec), fsspec, p + 1);
- name = rawspec;
- } else
- name = fsspec;
- }
- fd = opendisk(name, flags, device, devicelen, 0);
+ special = fs ? fs->fs_spec : name;
+
+ raw = getfsspecname(specname, sizeof(specname), special);
+ if (raw == NULL)
+ err(1, "%s: %s", name, specname);
+ special = getdiskrawname(rawname, sizeof(rawname), raw);
+ if (special == NULL)
+ special = raw;
+
+ fd = opendisk(special, flags, device, devicelen, 0);
if (fd == -1 && errno == ENOENT) {
oerrno = errno;
- strlcpy(device, name, devicelen);
+ strlcpy(device, special, devicelen);
errno = oerrno;
}
return (fd);
Home |
Main Index |
Thread Index |
Old Index