summaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2011-10-19 11:52:46 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2011-10-19 11:53:22 +0200
commitdac6e90115de9b47295fc5289a26f686bcae4d35 (patch)
tree3b0dcbc859979d20ac6cb99ff879533570c8cb43 /fs
parenta76e310abf6a82154dd6a1161a1883c031ec9652 (diff)
downloadbarebox-dac6e90115de9b47295fc5289a26f686bcae4d35.tar.gz
barebox-dac6e90115de9b47295fc5289a26f686bcae4d35.tar.xz
fix bug introduced with fixing path_check_prereq()
This fixes a bug introduced with: commit 74c36329c3531acf59d76a09cd0c4cf11ce6b6a0 Author: Antony Pavlov <antonynpavlov@gmail.com> Date: Tue Oct 18 13:48:44 2011 +0400 fs: fix path_check_prereq() This patch makes impossible the situations than path_check_prereq() can make 'return 0' without changing errno. Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> path_check_prereq is supposed to return 0 when a file does not exist and S_UB_DOES_NOT_EXIST is given. stat() changes errno, so we have to set errno back to 0 before returning. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'fs')
-rw-r--r--fs/fs.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/fs/fs.c b/fs/fs.c
index f42ca36078..51a7411b69 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -296,8 +296,10 @@ static int path_check_prereq(const char *path, unsigned int flags)
errno = 0;
if (stat(path, &s)) {
- if (flags & S_UB_DOES_NOT_EXIST)
+ if (flags & S_UB_DOES_NOT_EXIST) {
+ errno = 0;
goto out;
+ }
errno = -ENOENT;
goto out;
}
@@ -307,8 +309,10 @@ static int path_check_prereq(const char *path, unsigned int flags)
goto out;
}
- if (flags == S_UB_EXISTS)
+ if (flags == S_UB_EXISTS) {
+ errno = 0;
goto out;
+ }
m = s.st_mode;