[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: ext2 find patch
From: |
Tomas Ebenlendr |
Subject: |
Re: ext2 find patch |
Date: |
Tue, 1 Jun 2004 22:13:20 +0200 |
User-agent: |
Mutt/1.5.6i |
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
- ext2 find patch, Tomas Ebenlendr, 2004/06/01
- Re: ext2 find patch,
Tomas Ebenlendr <=
- Re: ext2 find patch, Marco Gerards, 2004/06/01
- Re: ext2 find patch, Jeroen Dekkers, 2004/06/01
- Message not available
- Message not available
- normal vs. rescue mode commands, Tomas Ebenlendr, 2004/06/02
- Re: normal vs. rescue mode commands, Tomas Ebenlendr, 2004/06/02
- Re: normal vs. rescue mode commands, Marco Gerards, 2004/06/02
- Re: normal vs. rescue mode commands, Yoshinori K. Okuji, 2004/06/03
- Re: normal vs. rescue mode commands, M. Gerards, 2004/06/03
- Re: normal vs. rescue mode commands, Tomas Ebenlendr, 2004/06/03
- Re: normal vs. rescue mode commands, Yoshinori K. Okuji, 2004/06/04
- Re: normal vs. rescue mode commands, Tomas Ebenlendr, 2004/06/06