From owner-freebsd-current Wed Jun 28 2:30:48 2000 Delivered-To: freebsd-current@freebsd.org Received: from cartier.cirx.org (cartier.cirx.org [211.72.15.243]) by hub.freebsd.org (Postfix) with ESMTP id 4EDBA37C137 for ; Wed, 28 Jun 2000 02:30:37 -0700 (PDT) (envelope-from clive@cartier.cirx.org) Received: (from clive@localhost) by cartier.cirx.org (8.9.3/8.9.3) id RAA03405; Wed, 28 Jun 2000 17:30:00 +0800 (CST) (envelope-from clive) Date: Wed, 28 Jun 2000 17:30:00 +0800 From: Clive Lin To: Bruce Evans Cc: Alexander Langer , Clive Lin , FreeBSD current Subject: Re: let badsect recog IFCHR in 5.0-C Message-ID: <20000628172959.A3312@cartier.cirx.org> Reply-To: Clive Lin References: <20000627173821.A98097@cichlids.cichlids.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="J2SCkAp4GZ/dPZZf" Content-Disposition: inline User-Agent: Mutt/1.2i In-Reply-To: ; from bde@zeta.org.au on Wed, Jun 28, 2000 at 11:31:55AM +1000 Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG --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