summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAntony Pavlov <antonynpavlov@gmail.com>2011-10-18 13:48:44 +0400
committerSascha Hauer <s.hauer@pengutronix.de>2011-10-18 12:12:43 +0200
commit74c36329c3531acf59d76a09cd0c4cf11ce6b6a0 (patch)
treedd8218c4c6c7c97d34da1e7a06eda4e88f1838aa
parent3808cb7a451a032c9181e6b3ed3f88b62eb46ee7 (diff)
downloadbarebox-74c36329c3531acf59d76a09cd0c4cf11ce6b6a0.tar.gz
barebox-74c36329c3531acf59d76a09cd0c4cf11ce6b6a0.tar.xz
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>
-rw-r--r--fs/fs.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/fs/fs.c b/fs/fs.c
index 7d65ec819b..714fc9bcd2 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -293,9 +293,11 @@ static int path_check_prereq(const char *path, unsigned int flags)
struct stat s;
unsigned int m;
+ errno = 0;
+
if (stat(path, &s)) {
if (flags & S_UB_DOES_NOT_EXIST)
- return 0;
+ goto out;
errno = -ENOENT;
goto out;
}
@@ -306,7 +308,7 @@ static int path_check_prereq(const char *path, unsigned int flags)
}
if (flags == S_UB_EXISTS)
- return 0;
+ goto out;
m = s.st_mode;
@@ -325,7 +327,6 @@ static int path_check_prereq(const char *path, unsigned int flags)
goto out;
}
- errno = 0;
out:
return errno;
}