From owner-freebsd-current@FreeBSD.ORG Sat Oct 16 06:44:32 2004 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id DE35A16A4CE for ; Sat, 16 Oct 2004 06:44:31 +0000 (GMT) Received: from tigra.ip.net.ua (tigra.ip.net.ua [82.193.96.10]) by mx1.FreeBSD.org (Postfix) with ESMTP id 1984443D48 for ; Sat, 16 Oct 2004 06:44:31 +0000 (GMT) (envelope-from ru@ip.net.ua) Received: from localhost (rocky.ip.net.ua [82.193.96.2]) by tigra.ip.net.ua (8.12.11/8.12.11) with ESMTP id i9G6iTso050749; Sat, 16 Oct 2004 09:44:29 +0300 (EEST) (envelope-from ru@ip.net.ua) Received: from tigra.ip.net.ua ([82.193.96.10]) by localhost (rocky.ipnet [82.193.96.2]) (amavisd-new, port 10024) with LMTP id 96670-19; Sat, 16 Oct 2004 09:44:29 +0300 (EEST) Received: from heffalump.ip.net.ua (heffalump.ip.net.ua [82.193.96.213]) by tigra.ip.net.ua (8.12.11/8.12.11) with ESMTP id i9G6iSEG050746; Sat, 16 Oct 2004 09:44:28 +0300 (EEST) (envelope-from ru@ip.net.ua) Received: (from ru@localhost) by heffalump.ip.net.ua (8.13.1/8.13.1) id i9G6iFLZ083029; Sat, 16 Oct 2004 09:44:15 +0300 (EEST) (envelope-from ru) Date: Sat, 16 Oct 2004 09:44:14 +0300 From: Ruslan Ermilov To: Sam Message-ID: <20041016064414.GC66090@ip.net.ua> References: Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="f+W+jCU1fRNres8c" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.6i X-Virus-Scanned: by amavisd-new at ip.net.ua cc: freebsd-current@FreeBSD.org Subject: Re: fdisk buglet X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 16 Oct 2004 06:44:32 -0000 --f+W+jCU1fRNres8c Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Oct 15, 2004 at 04:34:11PM -0500, Sam wrote: > fivethree% fdisk /dev/ad1 > fdisk: cannot open disk /dev//dev/ad1: No such file or directory >=20 > One possible fix: >=20 > fivethree% diff -upr src/sbin/fdisk src2/sbin/fdisk > diff -upr src/sbin/fdisk/fdisk.c src2/sbin/fdisk/fdisk.c > --- src/sbin/fdisk/fdisk.c Mon Jun 14 03:21:19 2004 > +++ src2/sbin/fdisk/fdisk.c Fri Oct 15 16:35:28 2004 > @@ -299,14 +299,16 @@ main(int argc, char *argv[]) > if (argc =3D=3D 0) { > disk =3D get_rootdisk(); > } else { > - if (stat(argv[0], &sb) =3D=3D 0) { > + disk =3D argv[0]; > + if (stat(disk, &sb) =3D=3D 0) { > /* OK, full pathname given */ > - disk =3D argv[0]; > } else if (errno =3D=3D ENOENT) { > /* Try prepending "/dev" */ > - asprintf(&disk, "%s%s", _PATH_DEV, argv[0]); > - if (disk =3D=3D NULL) > - errx(1, "out of memory"); > + if (strncmp(disk, _PATH_DEV, strlen(_PATH_DEV))) { > + asprintf(&disk, "%s%s", _PATH_DEV, argv[0= ]); > + if (disk =3D=3D NULL) > + errx(1, "out of memory"); > + } > } else { > /* other stat error, let it fail below */ > disk =3D argv[0]; >=20 Simpler: %%% Index: fdisk.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /home/ncvs/src/sbin/fdisk/fdisk.c,v retrieving revision 1.74 diff -u -r1.74 fdisk.c --- fdisk.c 14 Jun 2004 07:21:19 -0000 1.74 +++ fdisk.c 16 Oct 2004 06:43:16 -0000 @@ -302,7 +302,7 @@ if (stat(argv[0], &sb) =3D=3D 0) { /* OK, full pathname given */ disk =3D argv[0]; - } else if (errno =3D=3D ENOENT) { + } else if (errno =3D=3D ENOENT && argv[0][0] !=3D '/') { /* Try prepending "/dev" */ asprintf(&disk, "%s%s", _PATH_DEV, argv[0]); if (disk =3D=3D NULL) %%% Cheers, --=20 Ruslan Ermilov ru@FreeBSD.org FreeBSD committer --f+W+jCU1fRNres8c Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.6 (FreeBSD) iD8DBQFBcMM+qRfpzJluFF4RAqy5AJ9jlgp9l83c9Yq4iWoccIb3s2CeugCfRHSp tLT8r9qu63hXafhzlSGSIGE= =u9ge -----END PGP SIGNATURE----- --f+W+jCU1fRNres8c--