Date: Sun, 24 Mar 2013 02:47:09 GMT From: Eric van Gyzen <eric@vangyzen.net> To: freebsd-gnats-submit@FreeBSD.org Subject: misc/177328: [patch] libstand fails on ext2fs directories with more than one block Message-ID: <201303240247.r2O2l9hW013100@red.freebsd.org> Resent-Message-ID: <201303240250.r2O2o1bt022590@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 177328 >Category: misc >Synopsis: [patch] libstand fails on ext2fs directories with more than one block >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Sun Mar 24 02:50:00 UTC 2013 >Closed-Date: >Last-Modified: >Originator: Eric van Gyzen >Release: 8.1-RELEASE >Organization: Dell, Inc. >Environment: N/A >Description: When booting from an ext2fs file system, the loader skips the first 1k of a file if the directory entry for that file isn't in the first 1k of the directory of the root directory. >How-To-Repeat: Put several files in the boot directory, then add the kernel, to ensure that the kernel's directory entry isn't in the first block of the directory. >Fix: Port this fix from ufs.c (from 2004): http://svnweb.freebsd.org/base?view=revision&revision=134760 We've been running with the attached patch since August 2011. Patch attached with submission follows: diff --git a/src/lib/libstand/ext2fs.c b/src/lib/libstand/ext2fs.c index 53c4f56..40ce167 100644 --- a/src/lib/libstand/ext2fs.c +++ b/src/lib/libstand/ext2fs.c @@ -536,6 +536,17 @@ ext2fs_open(const char *upath, struct open_file *f) * Found terminal component. */ error = 0; + + // Reset the seek pointer to 0 when a file is successfully opened, + // since otherwise the initial seek offset will contain the directory + // offset of the filesystem block that contained its directory entry. + // This bug was mostly harmless because typically the directory is + // less than one filesystem block in size so the offset would be zero. + // It did however generally break loading a kernel from the (large) + // kernel compile directory. + // http://www.freebsd.org/cgi/cvsweb.cgi/src/lib/libstand/ufs.c#rev1.15 + fp->f_seekp = 0; + out: if (buf) free(buf); @@ -585,6 +596,16 @@ read_inode(ino_t inumber, struct open_file *f) fp->f_blkno[level] = -1; fp->f_buf_blkno = -1; + // Reset the seek pointer to 0 when a file is successfully opened, + // since otherwise the initial seek offset will contain the directory + // offset of the filesystem block that contained its directory entry. + // This bug was mostly harmless because typically the directory is + // less than one filesystem block in size so the offset would be zero. + // It did however generally break loading a kernel from the (large) + // kernel compile directory. + // http://www.freebsd.org/cgi/cvsweb.cgi/src/lib/libstand/ufs.c#rev1.15 + fp->f_seekp = 0; + out: free(buf); return (error); >Release-Note: >Audit-Trail: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201303240247.r2O2l9hW013100>