Received: from list by lists.gnu.org with archive (Exim 4.71) id 1TMhog-0007Qb-Dx for mharc-grub-devel@gnu.org; Fri, 12 Oct 2012 12:10:26 -0400 Received: from eggs.gnu.org ([208.118.235.92]:56608) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TMhoZ-0007QF-3j for grub-devel@gnu.org; Fri, 12 Oct 2012 12:10:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TMhoX-0007bG-Pm for grub-devel@gnu.org; Fri, 12 Oct 2012 12:10:19 -0400 Received: from chiark.greenend.org.uk ([212.13.197.229]:58206) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TMhoX-0007av-KC for grub-devel@gnu.org; Fri, 12 Oct 2012 12:10:17 -0400 Received: from [172.20.153.9] (helo=riva.pelham.vpn.ucam.org) by chiark.greenend.org.uk (Debian Exim 4.72 #1) with esmtps (return-path cjwatson@ubuntu.com) id 1TMhoV-0002Du-T9 for grub-devel@gnu.org; Fri, 12 Oct 2012 17:10:15 +0100 Received: from localhost ([127.0.0.1] helo=sarantium.pelham.vpn.ucam.org) by riva.pelham.vpn.ucam.org with esmtp (Exim 4.72) (envelope-from ) id 1TMhoU-0003Ek-HR for grub-devel@gnu.org; Fri, 12 Oct 2012 17:10:14 +0100 Received: from riva.dynamic.greenend.org.uk (localhost [127.0.0.1]) by sarantium.pelham.vpn.ucam.org (Postfix) with ESMTPS id 950583E4054 for ; Fri, 12 Oct 2012 17:09:55 +0100 (BST) Date: Fri, 12 Oct 2012 17:09:54 +0100 From: Colin Watson To: grub-devel@gnu.org Subject: [PATCH] Ignore symlink traversal failures in grub-mount readdir Message-ID: <20121012160954.GH17188@riva.dynamic.greenend.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 212.13.197.229 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: The development of GNU GRUB List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 12 Oct 2012 16:10:25 -0000 This is very much a temporary hack, so I'm sending it here for discussion rather than just committing it even though it's quite simple. r3036.1.15 introduced support for filling in the attributes of files in fuse_readdir. However, symlinks to directories are passed to call_fill with info.dir unset; call_fill will then try to open them with grub_file_open, and get GRUB_ERR_BAD_FILE_TYPE because it's ultimately a directory not a regular file. It then causes the whole readdir call to fail. The net effect is that if you, for example, have a symlink anywhere in the top level of a filesystem, then the entire filesystem appears empty in grub-mount. This is the root cause of https://bugs.launchpad.net/bugs/1051306. I think that the proper solution is to pass the full grub_fshelp_filetype to dirhook functions, which would permit implementing true symlink support in grub-mount. That would be a fairly large change that I don't have time for at the moment. As a stopgap, I suggest that we ignore errors from individual grub_file_open calls during fuse_readdir. How does this patch look? 2012-10-12 Colin Watson === modified file 'util/grub-mount.c' --- util/grub-mount.c 2012-03-08 18:09:05 +0000 +++ util/grub-mount.c 2012-10-12 16:08:39 +0000 @@ -292,7 +292,20 @@ fuse_readdir (const char *path, void *bu file = grub_file_open (tmp); free (tmp); if (! file) - return translate_error (); + { + /* We cannot handle symlinks properly yet, and symlinks to + directories will cause us to reach here. Symlink loops or + dangling symlinks will also cause an error. For the + meantime, while treating these as zero-length files is wrong, + it's better than failing the whole readdir call by returning + translate_error (). + + Ultimately, we should be able to tell from the + grub_dirhook_info that this is a symlink, and fill in the + attributes of the symlink rather than its target. */ + grub_errno = GRUB_ERR_NONE; + return 0; + } st.st_size = file->size; grub_file_close (file); } Thanks, -- Colin Watson [cjwatson@ubuntu.com]