[PATCH 1/4] fs: fat: propagate actual error code when opening/creating files
Ahmad Fatoum
a.fatoum at pengutronix.de
Tue Aug 25 03:10:53 PDT 2026
We currently map all error codes to -EINVAL when opening or creating a
file, when the underlying functions are capable of returning more error
codes like -EISDIR or -EROFS.
Propagate the received error code to tell consumers more about what went
wrong.
Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
fs/fat/fat.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/fs/fat/fat.c b/fs/fat/fat.c
index 0402db1d945a..b17157d1ea34 100644
--- a/fs/fat/fat.c
+++ b/fs/fat/fat.c
@@ -89,7 +89,7 @@ static int fat_create(struct device *dev, const char *pathname, mode_t mode)
ret = f_open(&priv->fat, &f_file, pathname, FA_OPEN_ALWAYS);
if (ret)
- return -EINVAL;
+ return ret;
f_close(&f_file);
@@ -204,7 +204,7 @@ static int fat_open(struct device *dev, struct file *file, const char *filename)
ret = f_open(&priv->fat, f_file, filename, flags);
if (ret) {
free(f_file);
- return -EINVAL;
+ return ret;
}
if (file->f_flags & O_APPEND) {
@@ -212,7 +212,7 @@ static int fat_open(struct device *dev, struct file *file, const char *filename)
if (ret) {
f_close(f_file);
free(f_file);
- return -EINVAL;
+ return ret;
}
}
--
2.47.3
More information about the barebox
mailing list