Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 22 Nov 1996 19:03:47 -0800 (PST)
From:      John-Mark Gurney <jmg@nike.efn.org>
To:        FreeBSD Current <freebsd-current@freebsd.org>
Subject:   my fsck patch (revision 1.4 of src/sbin/fsck/preen.c)
Message-ID:  <Pine.NEB.3.95.961122185357.16460E-100000@nike>

next in thread | raw e-mail | index | archive | help
I just relized that there is a time that this will fail to operate like it
was suppose to...  say you have a /etc/fstab like:
/dev/sd0a               /                       ufs     rw 1 1
/dev/sd0s1f             /usr                    ufs     rw 1 2
/dev/cd2a               /usr/anon/pub/cdrom2    cd9660  ro,noauto 0 0

but the cdrom was a ufs file system....  you boot single user mode and
try: fsck /usr/anon/pub/cdrom2  fsck won't resolve it because the patch
expects it to return a directory...  most chances are you won't have a
/usr/anon/pub/cdrom2 on your /... it's probably in /usr...  (I know this
may be bas fs design but it's possible)...  so I was thinking something
like this patch:

Index: preen.c
===================================================================
RCS file: /usr/cvs/src/sbin/fsck/preen.c,v
retrieving revision 1.5
diff -c -r1.5 preen.c
*** preen.c	1996/10/27 18:28:39	1.5
--- preen.c	1996/11/23 02:58:07
***************
*** 304,312 ****
  	}
  retry:
  	if (stat(name, &stblock) < 0) {
! 		perror(name);
! 		printf("Can't stat %s\n", name);
! 		return (0);
  	}
  	if ((stblock.st_mode & S_IFMT) == S_IFBLK) {
  		if (stslash.st_dev == stblock.st_rdev)
--- 304,310 ----
  	}
  retry:
  	if (stat(name, &stblock) < 0) {
! 		goto trydir;
  	}
  	if ((stblock.st_mode & S_IFMT) == S_IFBLK) {
  		if (stslash.st_dev == stblock.st_rdev)
***************
*** 328,333 ****
--- 326,332 ----
  		retried++;
  		goto retry;
  	} else if ((stblock.st_mode & S_IFMT) == S_IFDIR && !retried) {
+ trydir:
  		l = strlen(name) - 1;
  		if (l > 0 && name[l] == '/')
  			/* remove trailing slash */

the other way would be to duplicate the code (which I would prefere)...  I
detest goto :)...  but there is already goto used in this function...  so
I'm not as leary about using it... thanks for your ideas... ttyl..

John-Mark

gurney_j@efn.org
http://resnet.uoregon.edu/~gurney_j/
Modem/FAX: (541) 683-6954   (FreeBSD Box)

Live in Peace, destroy Micro$oft, support free software, run FreeBSD (unix)




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.NEB.3.95.961122185357.16460E-100000>