]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
ext4: detect directories in ext4fs_exists()
authorHeinrich Schuchardt <heinrich.schuchardt@canonical.com>
Tue, 20 Feb 2024 11:54:23 +0000 (12:54 +0100)
committerTom Rini <trini@konsulko.com>
Mon, 4 Mar 2024 15:25:47 +0000 (10:25 -0500)
While fat_exists() reports directories and files as existing
ext4fs_exists() only recognizes files. This lead to errors
when using systemd-boot with an ext4 file-system.

Change ext4fs_exists() to find any type of inode:
files, directories, symbolic links.

Fixes: a1596438a689 ("ext4fs ls load support")
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
fs/ext4/ext4_common.c
fs/ext4/ext4_common.h
fs/ext4/ext4fs.c

index ea9b92298ba759f3cb7f13cf57e3c335a944808a..365c5147c4bf8a53b964e7fefd37dac451557b89 100644 (file)
@@ -2214,9 +2214,8 @@ static char *ext4fs_read_symlink(struct ext2fs_node *node)
        return symlink;
 }
 
-static int ext4fs_find_file1(const char *currpath,
-                            struct ext2fs_node *currroot,
-                            struct ext2fs_node **currfound, int *foundtype)
+int ext4fs_find_file1(const char *currpath, struct ext2fs_node *currroot,
+                     struct ext2fs_node **currfound, int *foundtype)
 {
        char fpath[strlen(currpath) + 1];
        char *name = fpath;
index 504c708b0647f1854436a49d27c790e08f6fa617..84500e990aa36e4babc8619b22e01722e0b27aad 100644 (file)
@@ -54,6 +54,8 @@ int ext4fs_read_file(struct ext2fs_node *node, loff_t pos, loff_t len,
                     char *buf, loff_t *actread);
 int ext4fs_find_file(const char *path, struct ext2fs_node *rootnode,
                        struct ext2fs_node **foundnode, int expecttype);
+int ext4fs_find_file1(const char *currpath, struct ext2fs_node *currroot,
+                     struct ext2fs_node **currfound, int *foundtype);
 int ext4fs_iterate_dir(struct ext2fs_node *dir, char *name,
                        struct ext2fs_node **fnode, int *ftype);
 
index 3b12ec54fa2dda0514551f0c569f8b3cf38c568e..33e200ffa3c5e1c7c5bc50aaeff1b8ec6a326d29 100644 (file)
@@ -208,11 +208,14 @@ int ext4fs_ls(const char *dirname)
 
 int ext4fs_exists(const char *filename)
 {
-       loff_t file_len;
-       int ret;
+       struct ext2fs_node *dirnode = NULL;
+       int filetype;
 
-       ret = ext4fs_open(filename, &file_len);
-       return ret == 0;
+       if (!filename)
+               return 0;
+
+       return ext4fs_find_file1(filename, &ext4fs_root->diropen, &dirnode,
+                                &filetype);
 }
 
 int ext4fs_size(const char *filename, loff_t *size)