mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH 4/8] fs open: pass error from stat
Date: Sun, 18 Mar 2012 15:26:40 +0100	[thread overview]
Message-ID: <1332080804-13132-5-git-send-email-s.hauer@pengutronix.de> (raw)
In-Reply-To: <1332080804-13132-1-git-send-email-s.hauer@pengutronix.de>

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>
---
 fs/fs.c |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/fs/fs.c b/fs/fs.c
index 8473f81..24ef258 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);
-- 
1.7.9.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  parent reply	other threads:[~2012-03-18 14:27 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-18 14:26 [PATCH] automount support Sascha Hauer
2012-03-18 14:26 ` [PATCH 1/8] fs: change get_fs_device_by_path prototype Sascha Hauer
2012-03-18 14:26 ` [PATCH 2/8] fs: drop struct mtab_entry Sascha Hauer
2012-03-18 14:26 ` [PATCH 3/8] Add automount support Sascha Hauer
2012-03-18 14:26 ` Sascha Hauer [this message]
2012-03-18 14:26 ` [PATCH 5/8] hush source: expand $PATH Sascha Hauer
2012-03-18 14:26 ` [PATCH 6/8] FAT: Fix error path Sascha Hauer
2012-03-18 14:26 ` [PATCH 7/8] usb command: by default scan only once for USB devices Sascha Hauer
2012-03-18 14:26 ` [PATCH 8/8] partition command: optionally do not automatically prepend the device name Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1332080804-13132-5-git-send-email-s.hauer@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox