Date: Sat, 16 Oct 2004 09:44:14 +0300 From: Ruslan Ermilov <ru@FreeBSD.org> To: Sam <sah@softcardsystems.com> Cc: freebsd-current@FreeBSD.org Subject: Re: fdisk buglet Message-ID: <20041016064414.GC66090@ip.net.ua> In-Reply-To: <Pine.LNX.4.60.0410151632100.21014@athena> References: <Pine.LNX.4.60.0410151632100.21014@athena>
next in thread | previous in thread | raw e-mail | index | archive | help
--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--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20041016064414.GC66090>