Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 28 Jun 2000 17:30:00 +0800
From:      Clive Lin <clive@CirX.ORG>
To:        Bruce Evans <bde@zeta.org.au>
Cc:        Alexander Langer <alex@big.endian.de>, Clive Lin <clive@CirX.ORG>, FreeBSD current <current@FreeBSD.ORG>
Subject:   Re: let badsect recog IFCHR in 5.0-C
Message-ID:  <20000628172959.A3312@cartier.cirx.org>
In-Reply-To: <Pine.BSF.4.21.0006281129310.7042-100000@besplex.bde.org>; from bde@zeta.org.au on Wed, Jun 28, 2000 at 11:31:55AM %2B1000
References:  <20000627173821.A98097@cichlids.cichlids.com> <Pine.BSF.4.21.0006281129310.7042-100000@besplex.bde.org>

next in thread | previous in thread | raw e-mail | index | archive | help

--J2SCkAp4GZ/dPZZf
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

On Wed, Jun 28, 2000 at 11:31:55AM +1000, Bruce Evans wrote:
> 1) Don't "comment out" dead code.  Remove it.
> 2) Use only #if 0 to "comment out code.  Comments are unsuitable for
>    "commenting out" code in general, because the code might contain
>    comments, and they are harder to edit and read.
> 
> Bruce

Okay .. the style(9) may like the diff now :-)

Besides the original bogus style,
is there any side effect/potential risk along with the code ?

Regards,
Clive
-- 
CirX - This site doesnt' exist.
9c  k9o h9 s1bg s1f, 7v  .y xqx a  sj m8r ffg1 vg5 a6 asox tmul h38 .
ant sj m8r ob ? 1fj mwby a1 tao vg5. soq df v ' .a. CirX.

--J2SCkAp4GZ/dPZZf
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename=bdiff

--- badsect.c~	Tue Jun 27 22:30:57 2000
+++ badsect.c	Wed Jun 28 17:20:55 2000
@@ -118,11 +118,17 @@
 		err(3, "%s", name);
 	name_dir_end = name + strlen(name);
 	while ((dp = readdir(dirp)) != NULL) {
+		/*
+		 * Opening of a mounted on device is not allowed.
+		 * Attempt to open the raw device instead.
+		 */
+		if (dp->d_name[0] != 'r')
+			continue ; 
 		strcpy(name_dir_end, dp->d_name);
 		if (lstat(name, &devstat) < 0)
 			err(4, "%s", name);
 		if (stbuf.st_dev == devstat.st_rdev &&
-		    (devstat.st_mode & IFMT) == IFBLK)
+		    (devstat.st_mode & IFMT) == IFCHR)
 			break;
 	}
 	closedir(dirp);
@@ -131,12 +137,6 @@
 		    (u_long)stbuf.st_rdev, argv[1]);
 		exit(5);
 	}
-	/*
-	 * Opening of a mounted on device is not allowed.
-	 * Attempt to open the raw device instead.
-	 */
-	memcpy(name_dir_end + 1, name_dir_end, strlen(name_dir_end) + 1);
-	*name_dir_end = 'r';
 	if ((fsi = open(name, O_RDONLY)) < 0)
 		err(6, "%s", name);
 	fs = &sblock;

--J2SCkAp4GZ/dPZZf--


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20000628172959.A3312>