On Jul 13 11:54:11, Alexander Hall wrote: > On 07/12/12 22:55, Alexander Hall wrote: > > On 07/11/12 23:43, Jan Stary wrote: > >> On Jul 11 19:18:21, Alexander Hall wrote: > >>> This adds DUID support to ncheck_ffs. > >>> Testers? ok? > >> > >> This indeed enables ncheck_ffs for DUIDs, > >> but breaks ncheck_ffs for /dev/wd0x > >> > >> My fstab says > >> > >> 5d2ade1fc5a8d569.n /tmp ffs rw,softdep,nodev,nosuid 1 2 > >> > >> With your diff I can do 'ncheck_ffs /tmp', > >> which previously said > >> > >> 5d2ade1fc5a8d569.n: no such file or directory > >> > >> But I can no longer do 'ncheck_ffs /dev/wd0n' > >> which worked before this diff, but now says > >> > >> ncheck_ffs: cannot open /dev/wd0n: Device busy > >> > >> 'ncheck_ffs /dev/rwd0n' works though. > > > > Indeed, thanks. > > > > Another try follows, with less entangled diff. Does it work better? > Bah, fix indendation from spaces to tabs. > Comments? OK?
Now all of the following work: ncheck_ffs /dev/wd0n ncheck_ffs /dev/rwd0n ncheck_ffs 5d2ade1fc5a8d569.n ncheck_ffs /tmp Jan > Index: Makefile > =================================================================== > RCS file: /data/openbsd/cvs/src/sbin/ncheck_ffs/Makefile,v > retrieving revision 1.3 > diff -u -p -r1.3 Makefile > --- Makefile 29 Jun 1996 19:25:09 -0000 1.3 > +++ Makefile 11 Jul 2012 13:54:01 -0000 > @@ -1,6 +1,8 @@ > # $OpenBSD: Makefile,v 1.3 1996/06/29 19:25:09 mickey Exp $ > > PROG= ncheck_ffs > +LDADD= -lutil > +DPADD= ${LIBUTIL} > MAN= ncheck_ffs.8 > > LINKS= ${BINDIR}/ncheck_ffs ${BINDIR}/ncheck > Index: ncheck_ffs.c > =================================================================== > RCS file: /data/openbsd/cvs/src/sbin/ncheck_ffs/ncheck_ffs.c,v > retrieving revision 1.35 > diff -u -p -r1.35 ncheck_ffs.c > --- ncheck_ffs.c 27 Oct 2009 23:59:33 -0000 1.35 > +++ ncheck_ffs.c 13 Jul 2012 09:34:40 -0000 > @@ -542,24 +542,34 @@ main(int argc, char *argv[]) > if (optind != argc - 1 || (mflag && format)) > usage(); > > - odisk = argv[optind]; > - if (realpath(odisk, rdisk) == NULL) > + disk = argv[optind]; > + if ((diskfd = opendev(disk, O_RDONLY, 0, NULL)) >= 0) { > + if (fstat(diskfd, &stblock)) > + err(1, "cannot stat %s", disk); > + if (S_ISCHR(stblock.st_mode)) > + goto gotdev; > + close(diskfd); > + } > + > + if (realpath(disk, rdisk) == NULL) > err(1, "cannot find real path for %s", odisk); > disk = rdisk; > > if (stat(disk, &stblock) < 0) > err(1, "cannot stat %s", disk); > > - if (S_ISBLK(stblock.st_mode)) { > + if (S_ISBLK(stblock.st_mode)) { > disk = rawname(disk); > } else if (!S_ISCHR(stblock.st_mode)) { > if ((fsp = getfsfile(disk)) == NULL) > err(1, "could not find file system %s", disk); > - disk = rawname(fsp->fs_spec); > - } > + disk = rawname(fsp->fs_spec); > + } > > - if ((diskfd = open(disk, O_RDONLY)) < 0) > + if ((diskfd = opendev(disk, O_RDONLY, 0, NULL)) < 0) > err(1, "cannot open %s", disk); > + > +gotdev: > sblock = (struct fs *)sblock_buf; > for (i = 0; sblock_try[i] != -1; i++) { > n = pread(diskfd, sblock, SBLOCKSIZE, (off_t)sblock_try[i]);