Sorry, this slipped through and I forgot until tonight.

On Tue, Aug 30, 2011 at 15:15, Kenneth R Westerback
<[email protected]> wrote:
> I think that the logic to recognize '/dev/sd0a' as being in fstab
> whether literally or as a DUID would be required.

Fair enough; it's certainly convenient. I've used a similar approach
as proposed earlier [1] for umount.

To pre-empt breakage as mentioned in that thread, I added the check on
realdev to make sure oneof() doesn't choke on an erroneous entry in
fstab. This way, it works fine for me (amd64) for both DUIDs and
/dev/sd0a, etc. while not choking on erroneous arguments.

Admittedly, I didn't test on sgi, as mentioned later in that thread.
Trying with non-existent devices did not give me any issues (neither
in fstab nor on the command line).


> This would appear to require moving the opendev() to above the getfsent()
> loop and adding a check for "argnum = oneof(realpath, argv, argc)". And of
> course moving the associated close().

Besides deriving the realpath for DUIDs, I still think the opendev()
in chquota() would be needed (for the preen '-a' case), though.

Since multiple filesystem arguments can be provided, I'd say the
opendev() will need to be part of the loop and not outside (that's
what I assume you meant by "above").

Diff below, but also available online [2] in case it gets mangled.

Regards,

Rogier


Refrences:
1. MARC tech@ archive - "Making umount DUID capable"
http://marc.info/?l=openbsd-tech&m=130464844400579&w=2
2. Pastebin - Quotacheck(8) and DUID
http://pastebin.com/ft2Wvk8P


Index: Makefile
===================================================================
RCS file: /cvs/src/sbin/quotacheck/Makefile,v
retrieving revision 1.6
diff -u -r1.6 Makefile
--- Makefile    21 Sep 1997 11:37:57 -0000      1.6
+++ Makefile    9 Sep 2011 02:19:44 -0000
@@ -6,4 +6,7 @@
 MAN=   quotacheck.8
 .PATH: ${.CURDIR}/../fsck

+LDADD+=-lutil
+DPADD+=${LIBUTIL}
+
 .include <bsd.prog.mk>
Index: quotacheck.c
===================================================================
RCS file: /cvs/src/sbin/quotacheck/quotacheck.c,v
retrieving revision 1.25
diff -u -r1.25 quotacheck.c
--- quotacheck.c        27 Oct 2009 23:59:34 -0000      1.25
+++ quotacheck.c        9 Sep 2011 02:19:44 -0000
@@ -50,6 +50,7 @@
 #include <grp.h>
 #include <errno.h>
 #include <unistd.h>
+#include <util.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -187,9 +188,17 @@
        if (setfsent() == 0)
                err(1, "%s: can't open", FSTAB);
        while ((fs = getfsent()) != NULL) {
+               char *realdev;
+               if (fi = opendev(fs->fs_spec, O_RDONLY, 0, &realdev) >= 0) {
+                       close(fi);
+                       unrawname(realdev);
+               }
+               else
+                       realdev = NULL; /* no realdev, opendev() failed */
                if (((argnum = oneof(fs->fs_file, argv, argc)) >= 0 ||
-                   (argnum = oneof(fs->fs_spec, argv, argc)) >= 0) &&
-                   (auxdata = needchk(fs)) &&
+                   (argnum = oneof(fs->fs_spec, argv, argc)) >= 0 ||
+                   (realdev && (argnum = oneof(realdev, argv, argc)) >= 0))
+                   && (auxdata = needchk(fs)) &&
                    (name = blockcheck(fs->fs_spec))) {
                        done |= 1 << argnum;
                        errs += chkquota(fs->fs_vfstype, name,
@@ -269,7 +278,7 @@
                warn("fork");
                return 1;
        case 0:         /* child */
-               if ((fi = open(fsname, O_RDONLY, 0)) < 0)
+               if ((fi = opendev(fsname, O_RDONLY, 0, NULL)) < 0)
                        err(1, "%s", fsname);
                sync();
                dev_bsize = 1;

Reply via email to