From owner-freebsd-hackers@FreeBSD.ORG Sun Jun 22 03:26:52 2008 Return-Path: Delivered-To: hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 74B061065675 for ; Sun, 22 Jun 2008 03:26:52 +0000 (UTC) (envelope-from keramida@freebsd.org) Received: from igloo.linux.gr (igloo.linux.gr [62.1.205.36]) by mx1.freebsd.org (Postfix) with ESMTP id B45AA8FC0A for ; Sun, 22 Jun 2008 03:26:51 +0000 (UTC) (envelope-from keramida@freebsd.org) Received: from kobe.laptop (adsl15-211.kln.forthnet.gr [77.49.142.211]) (authenticated bits=128) by igloo.linux.gr (8.14.3/8.14.3/Debian-4) with ESMTP id m5M37cSk016702 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Sun, 22 Jun 2008 06:07:44 +0300 Received: from kobe.laptop (kobe.laptop [127.0.0.1]) by kobe.laptop (8.14.2/8.14.2) with ESMTP id m5M37cLZ008034; Sun, 22 Jun 2008 06:07:38 +0300 (EEST) (envelope-from keramida@freebsd.org) Received: (from keramida@localhost) by kobe.laptop (8.14.2/8.14.2/Submit) id m5M37bQh008033; Sun, 22 Jun 2008 06:07:37 +0300 (EEST) (envelope-from keramida@freebsd.org) From: Giorgos Keramidas To: "Garrett Cooper" References: <9C83A8B6-0C73-4A06-A60A-527D7B7BCCE5@gmail.com> <7d6fde3d0806162028l74172922t4ea47250e7634130@mail.gmail.com> Date: Sun, 22 Jun 2008 06:07:37 +0300 In-Reply-To: <7d6fde3d0806162028l74172922t4ea47250e7634130@mail.gmail.com> (Garrett Cooper's message of "Mon, 16 Jun 2008 20:28:08 -0700") Message-ID: <87lk0y416u.fsf_-_@kobe.laptop> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (berkeley-unix) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-MailScanner-ID: m5M37cSk016702 X-Hellug-MailScanner: Found to be clean X-Hellug-MailScanner-SpamCheck: not spam, SpamAssassin (not cached, score=-4.243, required 5, autolearn=not spam, ALL_TRUSTED -1.80, AWL 0.16, BAYES_00 -2.60) X-Hellug-MailScanner-From: keramida@freebsd.org X-Spam-Status: No Cc: hackers@freebsd.org, bug-followup@freebsd.org Subject: Re: bin/124409: fsck(8) requires exact entry for mountpoints when executing / bug by design in getfsfile(3) in .../lib/libc/gen/fstab.c X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 22 Jun 2008 03:26:52 -0000 On Mon, 16 Jun 2008 20:28:08 -0700, "Garrett Cooper" wrote: > On Tue, Jun 10, 2008 at 2:27 AM, Garrett Cooper wrote: >> Ok.... it appears I wasn't intelligent enough to post this in the right >> place last night. Comments please? >> >> Hi hackers, >> >> I have a question, pending a bug found in getfsfile(3) [1]. >> >> Is there any possibility where a mountpoint be any value other >> >> than a directory, a symlink, or "none", i.e. a flat file? >> >> Thanks, >> >> -Garrett >> >> References: >> >> http://www.freebsd.org/cgi/query-pr.cgi?pr=bin/124409 (not fully in PR >> >> database yet). > > Going once, going twice... Hi Garrett :-) When I wrote the original comment in that PR I had something like this in mind: %%% *** src.7789d2851415/lib/libc/gen/fstab.c Sun Jun 22 05:57:09 2008 --- /home/build/src/lib/libc/gen/fstab.c Sun Jun 22 05:56:48 2008 *************** struct fstab * *** 236,245 **** getfsfile(name) const char *name; { if (setfsent()) ! while (fstabscan()) ! if (!strcmp(_fs_fstab.fs_file, name)) return(&_fs_fstab); return((struct fstab *)NULL); } --- 236,256 ---- getfsfile(name) const char *name; { + char name_path[PATH_MAX]; + char fstab_path[PATH_MAX]; + + if (realpath(name, name_path) == NULL) + return((struct fstab *)NULL); if (setfsent()) ! while (fstabscan()) { ! if (strcmp(_fs_fstab.fs_file, name) == 0 || ! strcmp(_fs_fstab.fs_file, name_path) == 0) ! return(&_fs_fstab); ! if (realpath(_fs_fstab.fs_file, fstab_path) == NULL) ! return((struct fstab *)NULL); ! if (strcmp(fstab_path, name_path) == 0) return(&_fs_fstab); + } return((struct fstab *)NULL); } %%% I tried to avoid unnecessary realpath(3) calls as much as possible, but there is still the possibility for at least N+1 calls, where N is the number of entries in fstab... Can you test the above patch, and let me know if it looks ok, if you have a better fix in the works, etc.? It seems to pass the bug you originally reported when I run: % env LD_PRELOAD=/home/build/obj/home/build/src/lib/libc/libc.so.7 \ fsck ///cdrom/// fsck: exec fsck_cd9660 for /dev/acd0 in /sbin:/usr/sbin: No such file or directory The failure later is ok, because we don't have fsck_cd9660 for CD-ROMs.