Hi,

Below is a diff to avoid masking errno from DIOCMAP in opendev(3). The
intention of the existing code appears to be to try using path as a
device name rather than a DUID in case of failure, but as far as I can
tell, this is only desirable if DIOCMAP returns ENOENT anyway. Other
kinds of error indicate a problem with a valid DUID that the user will
likely want to know about and retry.

For example, consider running tunefs against a filesystem that is
currently mounted. DIOCMAP will return EBUSY, but resetting errno to
ENOENT will produce the confusing error message "No such file or
directory".

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       23 Aug 2015 07:27:40 -0000
@@ -79,7 +79,6 @@ opendev(const char *path, int oflags, in
                        if (ioctl(fd, DIOCMAP, &dm) == -1) {
                                close(fd);
                                fd = -1;
-                               errno = ENOENT;
                        }
                }
        }

Reply via email to