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 <[email protected]>
---
 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


Reply via email to