All of lore.kernel.org
 help / color / mirror / Atom feed
* ext2 find patch
@ 2004-06-01 12:17 Tomas Ebenlendr
  2004-06-01 20:13 ` Tomas Ebenlendr
  0 siblings, 1 reply; 25+ messages in thread
From: Tomas Ebenlendr @ 2004-06-01 12:17 UTC (permalink / raw)
  To: grub-devel


I don't understand the ext2 fs very well, but when I tried to install
grub2 on my computer, I had no access to files in subdirectories.

I installed bochs and tried to find what happened. And I found a strange
thing: newly created ext2 haven't this problem. So I use ext2resize to
get from real filesystem smaller image (1.44M floppy). It is ext2,
e2fsck tells it is clean, but dirent.filetype == 0 even for directories.
So I moved the directory check to another place, and changed it to test
inode.mode. Here is the patch (cvs diff -u):

----------------------------------------------------------------------------
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 12:12:19 -0000
@@ -422,6 +422,15 @@
       if (grub_errno)
    goto fail;
       
+      /* Check if it is directory */
+      /* NOTE: dirent.filetype==FILETYPE_DIRECTORY check sometimes fails,
+       * (I don't know why,) but this will not */
+      if (!(grub_le_to_cpu16 (inode->mode) & 040000))
+	{
+	   grub_error (GRUB_ERR_BAD_FILE_TYPE, "not a directory");
+	   goto fail;
+	}
+
       /* Search the file.  */
       while (fpos < grub_le_to_cpu32 (inode->size))
    {
@@ -526,12 +535,6 @@
	      currinode = grub_le_to_cpu32 (dirent.inode);
	      name = next;
 
-		      if (dirent.filetype != FILETYPE_DIRECTORY)
-			{
-			  grub_error (GRUB_ERR_BAD_FILE_TYPE,
-				      "not a directory");
-			  goto fail;
-			}
	      break;
	    }
	  else /* Found it!  */
----------------------------------------------------------------------------
-- 
                                 Tomas 'ebi' Ebenlendr
                                 http://get.to/ebik
                                 PF 2004.41690175319




^ permalink raw reply	[flat|nested] 25+ messages in thread

end of thread, other threads:[~2004-06-27 10:54 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-06-01 12:17 ext2 find patch Tomas Ebenlendr
2004-06-01 20:13 ` Tomas Ebenlendr
2004-06-01 20:47   ` Marco Gerards
2004-06-01 21:09     ` Jeroen Dekkers
     [not found]     ` <20040602100915.GA1629@artax.karlin.mff.cuni.cz>
     [not found]       ` <1086176188.40bdbbbc4d86d@webmail.han.nl>
2004-06-02 14:43         ` normal vs. rescue mode commands Tomas Ebenlendr
2004-06-02 15:11           ` Tomas Ebenlendr
2004-06-02 16:10             ` Marco Gerards
2004-06-03 11:12               ` Yoshinori K. Okuji
2004-06-03 11:55                 ` M. Gerards
2004-06-03 12:50                 ` Tomas Ebenlendr
2004-06-04 11:24                   ` Yoshinori K. Okuji
2004-06-06 10:55                     ` Tomas Ebenlendr
2004-06-09 11:19                       ` Yoshinori K. Okuji
2004-06-09 12:07                         ` Jeroen Dekkers
2004-06-09 12:25                           ` Yoshinori K. Okuji
2004-06-09 12:48                             ` Jeroen Dekkers
2004-06-09 13:12                               ` Yoshinori K. Okuji
2004-06-09 13:54                                 ` Jeroen Dekkers
2004-06-09 14:22                                   ` Yoshinori K. Okuji
2004-06-09 14:44                                     ` Jeroen Dekkers
2004-06-10 11:51                                       ` Yoshinori K. Okuji
2004-06-09 12:28                         ` Tomas Ebenlendr
2004-06-09 12:31                           ` Tomas Ebenlendr
2004-06-03 11:08           ` Yoshinori K. Okuji
2004-06-27 10:45   ` ext2 find patch Marco Gerards

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.