Received: from mailman by lists.gnu.org with archive (Exim 4.33) id 1BVFdy-000080-BO for mharc-grub-devel@gnu.org; Tue, 01 Jun 2004 16:13:54 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.33) id 1BVFdv-0008Uj-JI for grub-devel@gnu.org; Tue, 01 Jun 2004 16:13:52 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.33) id 1BVFdt-0008SL-VG for grub-devel@gnu.org; Tue, 01 Jun 2004 16:13:50 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1BVFdt-0008RT-Qd for grub-devel@gnu.org; Tue, 01 Jun 2004 16:13:49 -0400 Received: from [195.113.31.125] (helo=artax.karlin.mff.cuni.cz) by monty-python.gnu.org with esmtp (Exim 4.34) id 1BVFdR-000285-Qx for grub-devel@gnu.org; Tue, 01 Jun 2004 16:13:22 -0400 Received: by artax.karlin.mff.cuni.cz (Postfix, from userid 17122) id CDE963F9F; Tue, 1 Jun 2004 22:13:20 +0200 (CEST) Date: Tue, 1 Jun 2004 22:13:20 +0200 To: grub-devel@gnu.org Message-ID: <20040601201320.GA10705@artax.karlin.mff.cuni.cz> References: <20040601121704.GA4680@artax.karlin.mff.cuni.cz> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20040601121704.GA4680@artax.karlin.mff.cuni.cz> User-Agent: Mutt/1.5.6i From: ebik@artax.karlin.mff.cuni.cz (Tomas Ebenlendr) Subject: Re: ext2 find patch X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.4 Precedence: list Reply-To: ebik@ucw.cz, 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: Tue, 01 Jun 2004 20:13:53 -0000 The same problem was with symlinks, so the new version of patch is here. It does stat every inode (and ignore the info in direntries). There is also small fix in absolute symlinks (chopping the initial '/') -------------------------------------------------------------------------- Index: fs/ext2.c =================================================================== RCS file: /cvsroot/grub/grub2/fs/ext2.c,v retrieving revision 1.6 diff -u -r1.6 ext2.c --- fs/ext2.c 4 Apr 2004 13:46:00 -0000 1.6 +++ fs/ext2.c 1 Jun 2004 20:11:28 -0000 @@ -401,6 +401,11 @@ if (name[grub_strlen (name) - 1] =='/') name[grub_strlen (name) - 1] = '\0'; + /* Open the file. */ + grub_ext2_read_inode (data, currinode, inode); + if (grub_errno) + goto fail; + while (*name) { unsigned int fpos = 0; @@ -417,11 +422,6 @@ namesize = grub_strlen (name); - /* Open the file. */ - grub_ext2_read_inode (data, currinode, inode); - if (grub_errno) - goto fail; - /* Search the file. */ while (fpos < grub_le_to_cpu32 (inode->size)) { @@ -451,8 +451,13 @@ if (dirent.namelen == namesize && !grub_strncmp (name, filename, namesize)) { + /* Stat the inode. */ + grub_ext2_read_inode (data, + grub_le_to_cpu32 (dirent.inode), + inode); + /* If this is a symlink, follow it. */ - if (dirent.filetype == FILETYPE_SYMLINK) + if ((grub_le_to_cpu16 (data->inode.mode) &0170000) == 0120000) { /* XXX: Use malloc instead? */ char symlink[blocksize]; @@ -464,11 +469,6 @@ goto fail; } - /* Read the symlink. */ - grub_ext2_read_inode (data, - grub_le_to_cpu32 (dirent.inode), - inode); - /* If the filesize of the symlink is bigger than 60 the symlink is stored in a separate block, otherwise it is stored in the inode. */ @@ -490,7 +490,7 @@ /* Check if the symlink is absolute or relative. */ if (symlink[0] == '/') { - grub_strncpy (fpath, symlink, EXT2_PATH_MAX); + grub_strncpy (fpath, symlink + 1, EXT2_PATH_MAX); name = fpath; currinode = 2; } @@ -517,6 +517,11 @@ } } + /* Open the file. */ + grub_ext2_read_inode (data, currinode, inode); + if (grub_errno) + goto fail; + fpos = 0; break; } @@ -526,7 +531,7 @@ currinode = grub_le_to_cpu32 (dirent.inode); name = next; - if (dirent.filetype != FILETYPE_DIRECTORY) + if ((grub_le_to_cpu16 (data->inode.mode) &0170000) != 040000) { grub_error (GRUB_ERR_BAD_FILE_TYPE, "not a directory"); @@ -653,7 +658,7 @@ if (grub_errno) goto fail; - if (!(grub_le_to_cpu16 (data->inode.mode) & 040000)) + if ((grub_le_to_cpu16 (data->inode.mode) &0170000) != 040000) { grub_error (GRUB_ERR_BAD_FILE_TYPE, "not a directory"); goto fail; -------------------------------------------------------------------------- -- Tomas 'ebi' Ebenlendr http://get.to/ebik PF 2004.41770257792