From owner-freebsd-current@FreeBSD.ORG Tue Oct 19 21:13:16 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 D70ED16A4D8 for ; Tue, 19 Oct 2004 21:13:15 +0000 (GMT) Received: from mail6.speakeasy.net (mail6.speakeasy.net [216.254.0.206]) by mx1.FreeBSD.org (Postfix) with ESMTP id 86A5443D49 for ; Tue, 19 Oct 2004 21:13:15 +0000 (GMT) (envelope-from john@baldwin.cx) Received: (qmail 23359 invoked from network); 19 Oct 2004 21:13:15 -0000 Received: from dsl027-160-063.atl1.dsl.speakeasy.net (HELO server.baldwin.cx) ([216.27.160.63]) (envelope-sender ) encrypted SMTP for ; 19 Oct 2004 21:13:14 -0000 Received: from zion.baldwin.cx (zion.baldwin.cx [192.168.0.7]) by server.baldwin.cx (8.12.11/8.12.11) with ESMTP id i9JLDBQk050312; Tue, 19 Oct 2004 17:13:11 -0400 (EDT) (envelope-from john@baldwin.cx) Received: from zion.baldwin.cx (localhost [127.0.0.1]) by zion.baldwin.cx (8.12.10/8.12.10) with ESMTP id i9JLDB8h005710; Tue, 19 Oct 2004 17:13:11 -0400 (EDT) (envelope-from john@zion.baldwin.cx) Received: from localhost (localhost [[UNIX: localhost]]) by zion.baldwin.cx (8.12.10/8.12.10/Submit) id i9JLDAC6005709; Tue, 19 Oct 2004 17:13:10 -0400 (EDT) (envelope-from john) From: John Baldwin To: freebsd-current@freebsd.org Date: Tue, 19 Oct 2004 16:53:51 -0400 User-Agent: KMail/1.6 References: <20041016064414.GC66090@ip.net.ua> In-Reply-To: <20041016064414.GC66090@ip.net.ua> MIME-Version: 1.0 Content-Disposition: inline Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <200410191653.51979.jhb@FreeBSD.org> X-Spam-Checker-Version: SpamAssassin 2.63 (2004-01-11) on server.baldwin.cx cc: Sam 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: Tue, 19 Oct 2004 21:13:16 -0000 On Saturday 16 October 2004 02:44 am, Ruslan Ermilov wrote: > 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 > > > > One possible fix: > > > > 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 == 0) { > > disk = get_rootdisk(); > > } else { > > - if (stat(argv[0], &sb) == 0) { > > + disk = argv[0]; > > + if (stat(disk, &sb) == 0) { > > /* OK, full pathname given */ > > - disk = argv[0]; > > } else if (errno == ENOENT) { > > /* Try prepending "/dev" */ > > - asprintf(&disk, "%s%s", _PATH_DEV, argv[0]); > > - if (disk == NULL) > > - errx(1, "out of memory"); > > + if (strncmp(disk, _PATH_DEV, strlen(_PATH_DEV))) > > { + asprintf(&disk, "%s%s", _PATH_DEV, > > argv[0]); + if (disk == NULL) > > + errx(1, "out of memory"); > > + } > > } else { > > /* other stat error, let it fail below */ > > disk = argv[0]; > > Simpler: > > %%% > Index: fdisk.c > =================================================================== > 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) == 0) { > /* OK, full pathname given */ > disk = argv[0]; > - } else if (errno == ENOENT) { > + } else if (errno == ENOENT && argv[0][0] != '/') { > /* Try prepending "/dev" */ > asprintf(&disk, "%s%s", _PATH_DEV, argv[0]); > if (disk == NULL) > %%% > > > Cheers, Looks good to me, are you going to commit it? -- John Baldwin <>< http://www.FreeBSD.org/~jhb/ "Power Users Use the Power to Serve!" - http://www.FreeBSD.org/