Use getfsspecname also when not found in /etc/fstab.

This commit is contained in:
mlelstv 2015-08-26 05:41:20 +00:00
parent 54882650b0
commit 6e7966e6f5
1 changed files with 16 additions and 17 deletions

View File

@ -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, 1993\
#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, const char *file)
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);