From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1JGIPN-0001C8-Nb for mharc-grub-devel@gnu.org; Sat, 19 Jan 2008 13:27:09 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JGIPM-0001Bu-3o for grub-devel@gnu.org; Sat, 19 Jan 2008 13:27:08 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JGIPL-0001Ba-Hl for grub-devel@gnu.org; Sat, 19 Jan 2008 13:27:07 -0500 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JGIPL-0001BX-B4 for grub-devel@gnu.org; Sat, 19 Jan 2008 13:27:07 -0500 Received: from main.gmane.org ([80.91.229.2] helo=ciao.gmane.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1JGIPK-0002m5-Qv for grub-devel@gnu.org; Sat, 19 Jan 2008 13:27:07 -0500 Received: from list by ciao.gmane.org with local (Exim 4.43) id 1JGIPI-0004yv-7r for grub-devel@gnu.org; Sat, 19 Jan 2008 18:27:04 +0000 Received: from adsl-69-234-194-107.dsl.irvnca.pacbell.net ([69.234.194.107]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 19 Jan 2008 18:27:04 +0000 Received: from wa1ter by adsl-69-234-194-107.dsl.irvnca.pacbell.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 19 Jan 2008 18:27:04 +0000 X-Injected-Via-Gmane: http://gmane.org/ To: grub-devel@gnu.org From: walt Date: Sat, 19 Jan 2008 10:27:20 -0800 Organization: none Message-ID: References: <20080119170105.GJ1341@kirkkit.kollasch.net> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------050504030004000700080406" X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: adsl-69-234-194-107.dsl.irvnca.pacbell.net User-Agent: Thunderbird 3.0a1pre (X11/2008011906) In-Reply-To: <20080119170105.GJ1341@kirkkit.kollasch.net> Sender: news X-detected-kernel: by monty-python.gnu.org: Linux 2.6, seldom 2.4 (older, 4) Subject: Re: UFS (FFS) support seems broken in grub2 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The development of GRUB 2 List-Id: The development of GRUB 2 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 19 Jan 2008 18:27:08 -0000 This is a multi-part message in MIME format. --------------050504030004000700080406 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit jakllsch@kollasch.net wrote: > Hi, > > The UFS (or FFS as it's known to NetBSD) > support in grub2 does not seem to work for me. There was an interesting but strangely incomplete discussion of UFS back in April 2007. Hitoshi Ozeki posted the attached patch, which lets me list UFS filesystems but not read from them. If you can use his patch to devise a real fix, I'd be very happy. --------------050504030004000700080406 Content-Type: text/x-patch; name="ufs.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="ufs.patch" --- grub-1.95/fs/ufs.c 2006-06-04 17:55:56.000000000 +0900 +++ grub-1.95-new/fs/ufs.c 2007-04-12 08:05:09.698149332 +0900 @@ -394,16 +394,13 @@ static grub_err_t grub_ufs_find_file (struct grub_ufs_data *data, const char *path) { - char fpath[grub_strlen (path)]; - char *name = fpath; - char *next; + const char *name = path; + const char *next; unsigned int pos = 0; int dirino; - grub_strncpy (fpath, path, grub_strlen (path)); - /* Skip the first slash. */ - if (name[0] == '/') + if (*name == '/') { name++; if (!*name) @@ -412,17 +409,14 @@ /* Extract the actual part from the pathname. */ next = grub_strchr (name, '/'); - if (next) - { - next[0] = '\0'; - next++; - } + if (!next) + next = &name[grub_strlen(name)]; do { struct grub_ufs_dirent dirent; - if (grub_strlen (name) == 0) + if (next <= name) return GRUB_ERR_NONE; if (grub_ufs_read_file (data, 0, pos, sizeof (dirent), @@ -430,15 +424,13 @@ return grub_errno; { - char filename[dirent.namelen + 1]; + char filename[dirent.namelen]; if (grub_ufs_read_file (data, 0, pos + sizeof (dirent), dirent.namelen, filename) < 0) return grub_errno; - filename[dirent.namelen] = '\0'; - - if (!grub_strcmp (name, filename)) + if ((&name[dirent.namelen] == next) && !grub_strncmp (name, filename, dirent.namelen)) { dirino = data->ino; grub_ufs_read_inode (data, grub_le_to_cpu32 (dirent.ino)); @@ -450,18 +442,15 @@ return grub_errno; } - if (!next) + if (!*next) return 0; pos = 0; - name = next; - next = grub_strchr (name, '/'); - if (next) - { - next[0] = '\0'; - next++; - } + name = next + 1; + next = grub_strchr (name, '/'); + if (!next) + next = &name[grub_strlen(name)]; if (!(dirent.filetype & GRUB_UFS_FILETYPE_DIR)) return grub_error (GRUB_ERR_BAD_FILE_TYPE, "not a directory"); @@ -599,34 +588,43 @@ grub_ufs_open (struct grub_file *file, const char *name) { struct grub_ufs_data *data; + +#ifndef GRUB_UTIL + grub_dl_ref (my_mod); +#endif + data = grub_ufs_mount (file->device->disk); if (!data) return grub_errno; grub_ufs_read_inode (data, 2); if (grub_errno) - { - grub_free (data); - return grub_errno; - } + goto fail; if (!name || name[0] != '/') { grub_error (GRUB_ERR_BAD_FILENAME, "bad filename"); - return grub_errno; + goto fail; } grub_ufs_find_file (data, name); if (grub_errno) - { - grub_free (data); - return grub_errno; - } + goto fail; file->data = data; file->size = INODE_SIZE (data); return GRUB_ERR_NONE; + + fail: + + grub_free (data); + +#ifndef GRUB_UTIL + grub_dl_unref (my_mod); +#endif + + return grub_errno; } --------------050504030004000700080406--