summaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2012-02-27 09:30:11 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2012-03-18 15:03:31 +0100
commit3f637f7dc4fb8b20ef30acc212653ea51bdaa418 (patch)
treed381a1b1dc546f7a02376c28811097258ccb360a /fs
parentb5e5b06d8bf87908a5c4bec87e751ee2681cad4f (diff)
downloadbarebox-3f637f7dc4fb8b20ef30acc212653ea51bdaa418.tar.gz
barebox-3f637f7dc4fb8b20ef30acc212653ea51bdaa418.tar.xz
fs open: pass error from stat
We used to simply answer with -ENOENT in open() when the initial call to stat() failed. Instead, forward the error from stat(). Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'fs')
-rw-r--r--fs/fs.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/fs/fs.c b/fs/fs.c
index 8473f81aed..24ef25827a 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -480,20 +480,20 @@ int open(const char *pathname, int flags, ...)
struct fs_device_d *fsdev;
struct fs_driver_d *fsdrv;
FILE *f;
- int exist;
+ int exist_err;
struct stat s;
char *path = normalise_path(pathname);
char *freep = path;
- exist = (stat(path, &s) == 0) ? 1 : 0;
+ exist_err = stat(path, &s);
- if (exist && S_ISDIR(s.st_mode)) {
+ if (!exist_err && S_ISDIR(s.st_mode)) {
errno = -EISDIR;
goto out1;
}
- if (!exist && !(flags & O_CREAT)) {
- errno = -ENOENT;
+ if (exist_err && !(flags & O_CREAT)) {
+ errno = exist_err;
goto out1;
}
@@ -517,7 +517,7 @@ int open(const char *pathname, int flags, ...)
goto out;
}
- if (!exist) {
+ if (exist_err) {
if (NULL != fsdrv->create)
errno = fsdrv->create(&fsdev->dev, path,
S_IFREG | S_IRWXU | S_IRWXG | S_IRWXO);