Module Name: src Committed By: mlelstv Date: Wed Aug 26 05:41:20 UTC 2015
Modified Files: src/sbin/tunefs: tunefs.c Log Message: Use getfsspecname also when not found in /etc/fstab. To generate a diff of this commit: cvs rdiff -u -r1.48 -r1.49 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/tunefs/tunefs.c diff -u src/sbin/tunefs/tunefs.c:1.48 src/sbin/tunefs/tunefs.c:1.49 --- src/sbin/tunefs/tunefs.c:1.48 Sat Aug 9 10:33:46 2014 +++ src/sbin/tunefs/tunefs.c Wed Aug 26 05:41:20 2015 @@ -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 @@ __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.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 @@ bread(daddr_t blk, char *buffer, int cnt 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);