+2004-06-27 Tomas Ebenlendr <ebik@ucw.cz>
+
+ * fs/ext2.c (FILETYPE_INO_MASK, FILETYPE_INO_DIRECTORY)
+ (FILETYPE_INO_SYMLINK): New macros.
+ (grub_ext2_find_file): Check if the node is a directory using the
+ inode stat information instead of using the filetype in the
+ dirent. Exclude the first character of an absolute symlink.
+ (grub_ext2_dir): Mask out the filetype part of the mode member of
+ the inode.
+
2004-05-24 Marco Gerards <metgerards@student.han.nl>
Add support for UFS version 1 and 2. Add support for the minix
#define FILETYPE_DIRECTORY 2
#define FILETYPE_SYMLINK 7
+/* Filetype information as used in inodes. */
+#define FILETYPE_INO_MASK 0170000
+#define FILETYPE_INO_DIRECTORY 0040000
+#define FILETYPE_INO_SYMLINK 0120000
+
#include <grub/err.h>
#include <grub/file.h>
#include <grub/mm.h>
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)
+ & FILETYPE_INO_MASK) == FILETYPE_INO_SYMLINK)
{
/* XXX: Use malloc instead? */
char symlink[blocksize];
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. */
/* 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;
}
grub_free (bak);
}
}
-
+
fpos = 0;
break;
}
currinode = grub_le_to_cpu32 (dirent.inode);
name = next;
- if (dirent.filetype != FILETYPE_DIRECTORY)
+ if ((grub_le_to_cpu16 (data->inode.mode)
+ & FILETYPE_INO_MASK) != FILETYPE_INO_DIRECTORY)
{
grub_error (GRUB_ERR_BAD_FILE_TYPE,
"not a directory");
if (grub_errno)
goto fail;
- if (!(grub_le_to_cpu16 (data->inode.mode) & 040000))
+ if ((grub_le_to_cpu16 (data->inode.mode)
+ & FILETYPE_INO_MASK) != FILETYPE_INO_DIRECTORY)
{
grub_error (GRUB_ERR_BAD_FILE_TYPE, "not a directory");
goto fail;