Commit 377202b5604e9e17074955538dc8081169a43137
Committed by
Tom Rini
1 parent
6152916a95
Exists in
master
and in
49 other branches
fs: don't pass NULL dev_desc to most filesystems
FAT and ext4 expect that the passed in block device descriptor not be NULL. This causes problems on sandbox, where get_device_and_partition() succeeds for the "host" device, yet passes back a NULL device descriptor. Add special handling for this situation, so that the generic filesystem commands operate as expected on sandbox. Signed-off-by: Stephen Warren <swarren@nvidia.com>
Showing 1 changed file with 16 additions and 0 deletions Side-by-side Diff
fs/fs.c
... | ... | @@ -64,6 +64,15 @@ |
64 | 64 | |
65 | 65 | struct fstype_info { |
66 | 66 | int fstype; |
67 | + /* | |
68 | + * Is it legal to pass NULL as .probe()'s fs_dev_desc parameter? This | |
69 | + * should be false in most cases. For "virtual" filesystems which | |
70 | + * aren't based on a U-Boot block device (e.g. sandbox), this can be | |
71 | + * set to true. This should also be true for the dumm entry at the end | |
72 | + * of fstypes[], since that is essentially a "virtual" (non-existent) | |
73 | + * filesystem. | |
74 | + */ | |
75 | + bool null_dev_desc_ok; | |
67 | 76 | int (*probe)(block_dev_desc_t *fs_dev_desc, |
68 | 77 | disk_partition_t *fs_partition); |
69 | 78 | int (*ls)(const char *dirname); |
... | ... | @@ -77,6 +86,7 @@ |
77 | 86 | #ifdef CONFIG_FS_FAT |
78 | 87 | { |
79 | 88 | .fstype = FS_TYPE_FAT, |
89 | + .null_dev_desc_ok = false, | |
80 | 90 | .probe = fat_set_blk_dev, |
81 | 91 | .close = fat_close, |
82 | 92 | .ls = file_fat_ls, |
... | ... | @@ -88,6 +98,7 @@ |
88 | 98 | #ifdef CONFIG_FS_EXT4 |
89 | 99 | { |
90 | 100 | .fstype = FS_TYPE_EXT, |
101 | + .null_dev_desc_ok = false, | |
91 | 102 | .probe = ext4fs_probe, |
92 | 103 | .close = ext4fs_close, |
93 | 104 | .ls = ext4fs_ls, |
... | ... | @@ -99,6 +110,7 @@ |
99 | 110 | #ifdef CONFIG_SANDBOX |
100 | 111 | { |
101 | 112 | .fstype = FS_TYPE_SANDBOX, |
113 | + .null_dev_desc_ok = true, | |
102 | 114 | .probe = sandbox_fs_set_blk_dev, |
103 | 115 | .close = sandbox_fs_close, |
104 | 116 | .ls = sandbox_fs_ls, |
... | ... | @@ -109,6 +121,7 @@ |
109 | 121 | #endif |
110 | 122 | { |
111 | 123 | .fstype = FS_TYPE_ANY, |
124 | + .null_dev_desc_ok = true, | |
112 | 125 | .probe = fs_probe_unsupported, |
113 | 126 | .close = fs_close_unsupported, |
114 | 127 | .ls = fs_ls_unsupported, |
... | ... | @@ -160,6 +173,9 @@ |
160 | 173 | for (i = 0, info = fstypes; i < ARRAY_SIZE(fstypes); i++, info++) { |
161 | 174 | if (fstype != FS_TYPE_ANY && info->fstype != FS_TYPE_ANY && |
162 | 175 | fstype != info->fstype) |
176 | + continue; | |
177 | + | |
178 | + if (!fs_dev_desc && !info->null_dev_desc_ok) | |
163 | 179 | continue; |
164 | 180 | |
165 | 181 | if (!info->probe(fs_dev_desc, &fs_partition)) { |