On Sat, 29 Aug 2015 21:48:34 +1000 Steven McDonald <ste...@steven-mcdonald.id.au> wrote:
> Index: lib/libutil/opendev.c > =================================================================== > RCS file: /cvs/src/lib/libutil/opendev.c,v > retrieving revision 1.15 > diff -u -p -r1.15 opendev.c > --- lib/libutil/opendev.c 30 Jun 2011 15:04:58 -0000 > 1.15 +++ lib/libutil/opendev.c 29 Aug 2015 11:45:37 -0000 > @@ -79,7 +79,6 @@ opendev(const char *path, int oflags, in > if (ioctl(fd, DIOCMAP, &dm) == -1) { > close(fd); > fd = -1; > - errno = ENOENT; > } > } > } That hunk sneaked in from another diff. I'll give myself a good clubbing over the head for next time. Index: lib/libutil/opendev.3 =================================================================== RCS file: /cvs/src/lib/libutil/opendev.3,v retrieving revision 1.22 diff -u -p -r1.22 opendev.3 --- lib/libutil/opendev.3 15 Jan 2015 19:06:32 -0000 1.22 +++ lib/libutil/opendev.3 29 Aug 2015 11:52:30 -0000 @@ -88,7 +88,8 @@ If .Fa realpath is not .Dv NULL , -it is modified to point at the fully expanded device name. +it is modified to point at the fully expanded device name, or to the +unmodified device name if no device was found. .Sh RETURN VALUES The .Fn opendev Index: lib/libutil/opendev.c =================================================================== RCS file: /cvs/src/lib/libutil/opendev.c,v retrieving revision 1.15 diff -u -p -r1.15 opendev.c --- lib/libutil/opendev.c 30 Jun 2011 15:04:58 -0000 1.15 +++ lib/libutil/opendev.c 29 Aug 2015 11:52:30 -0000 @@ -103,8 +103,11 @@ opendev(const char *path, int oflags, in errno = ENAMETOOLONG; } } - if (realpath) + if (realpath) { + if (fd == -1 && errno == ENOENT) + strlcpy(namebuf, path, sizeof(namebuf)); *realpath = namebuf; + } return (fd); } Index: sbin/tunefs/tunefs.c =================================================================== RCS file: /cvs/src/sbin/tunefs/tunefs.c,v retrieving revision 1.37 diff -u -p -r1.37 tunefs.c --- sbin/tunefs/tunefs.c 7 Feb 2015 02:09:14 -0000 1.37 +++ sbin/tunefs/tunefs.c 29 Aug 2015 11:52:30 -0000 @@ -309,21 +309,14 @@ bread(daddr_t blk, char *buffer, int cnt static int openpartition(char *name, int flags, char **devicep) { - char rawspec[PATH_MAX], *p; + char *p; struct fstab *fs; - int fd; fs = getfsfile(name); if (fs) { - if ((p = strrchr(fs->fs_spec, '/')) != NULL) { - snprintf(rawspec, sizeof(rawspec), "%.*s/r%s", - (int)(p - fs->fs_spec), fs->fs_spec, p + 1); - name = rawspec; - } else - name = fs->fs_spec; + name = fs->fs_spec; + if ((p = strrchr(name, '/')) != NULL) + name = p + 1; } - fd = opendev(name, flags, 0, devicep); - if (fd == -1 && errno == ENOENT) - devicep = &name; - return (fd); + return opendev(name, flags, 0, devicep); }