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 1/8] fs: change get_fs_device_by_path prototype
Date: Sun, 18 Mar 2012 15:26:37 +0100	[thread overview]
Message-ID: <1332080804-13132-2-git-send-email-s.hauer@pengutronix.de> (raw)
In-Reply-To: <1332080804-13132-1-git-send-email-s.hauer@pengutronix.de>

get_fs_device_by_path returns a struct device_d instead of what the
name suggests a struct fs_device_d. Also it returns the rootpath
of the corresponding fs_device. This patch changes the name of
this function to get_fs_device_and_root_path to better reflect what
the function does and changes the return type to struct fs_device_d.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 fs/fs.c |   65 ++++++++++++++++++++++++++++++--------------------------------
 1 files changed, 31 insertions(+), 34 deletions(-)

diff --git a/fs/fs.c b/fs/fs.c
index a31a4ce..93a0f80 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -216,9 +216,8 @@ static int check_fd(int fd)
 	return 0;
 }
 
-static struct device_d *get_fs_device_by_path(char **path)
+static struct fs_device_d *get_fs_device_and_root_path(char **path)
 {
-	struct device_d *dev;
 	struct mtab_entry *e;
 
 	e = get_mtab_entry_by_path(*path);
@@ -227,9 +226,7 @@ static struct device_d *get_fs_device_by_path(char **path)
 	if (e != mtab_root)
 		*path += strlen(e->path);
 
-	dev = e->dev;
-
-	return dev;
+	return dev_to_fs_device(e->dev);
 }
 
 static int dir_is_empty(const char *pathname)
@@ -336,7 +333,7 @@ EXPORT_SYMBOL(chdir);
 
 int unlink(const char *pathname)
 {
-	struct device_d *dev;
+	struct fs_device_d *fsdev;
 	struct fs_driver_d *fsdrv;
 	char *p = normalise_path(pathname);
 	char *freep = p;
@@ -344,17 +341,17 @@ int unlink(const char *pathname)
 	if (path_check_prereq(pathname, S_IFREG))
 		goto out;
 
-	dev = get_fs_device_by_path(&p);
-	if (!dev)
+	fsdev = get_fs_device_and_root_path(&p);
+	if (!fsdev)
 		goto out;
-	fsdrv = dev_to_fs_driver(dev);
+	fsdrv = fsdev->driver;
 
 	if (!fsdrv->unlink) {
 		errno = -ENOSYS;
 		goto out;
 	}
 
-	errno = fsdrv->unlink(dev, p);
+	errno = fsdrv->unlink(&fsdev->dev, p);
 out:
 	free(freep);
 	return errno;
@@ -363,7 +360,7 @@ EXPORT_SYMBOL(unlink);
 
 int open(const char *pathname, int flags, ...)
 {
-	struct device_d *dev;
+	struct fs_device_d *fsdev;
 	struct fs_driver_d *fsdrv;
 	FILE *f;
 	int exist;
@@ -389,13 +386,13 @@ int open(const char *pathname, int flags, ...)
 		goto out1;
 	}
 
-	dev = get_fs_device_by_path(&path);
-	if (!dev)
+	fsdev = get_fs_device_and_root_path(&path);
+	if (!fsdev)
 		goto out;
 
-	fsdrv = dev_to_fs_driver(dev);
+	fsdrv = fsdev->driver;
 
-	f->dev = dev;
+	f->dev = &fsdev->dev;
 	f->flags = flags;
 
 	if ((flags & O_ACCMODE) && !fsdrv->write) {
@@ -405,20 +402,20 @@ int open(const char *pathname, int flags, ...)
 
 	if (!exist) {
 		if (NULL != fsdrv->create)
-			errno = fsdrv->create(dev, path,
+			errno = fsdrv->create(&fsdev->dev, path,
 					S_IFREG | S_IRWXU | S_IRWXG | S_IRWXO);
 		else
 			errno = -EROFS;
 		if (errno)
 			goto out;
 	}
-	errno = fsdrv->open(dev, f, path);
+	errno = fsdrv->open(&fsdev->dev, f, path);
 	if (errno)
 		goto out;
 
 
 	if (flags & O_TRUNC) {
-		errno = fsdrv->truncate(dev, f, 0);
+		errno = fsdrv->truncate(&fsdev->dev, f, 0);
 		f->size = 0;
 		if (errno)
 			goto out;
@@ -867,7 +864,7 @@ EXPORT_SYMBOL(umount);
 DIR *opendir(const char *pathname)
 {
 	DIR *dir = NULL;
-	struct device_d *dev;
+	struct fs_device_d *fsdev;
 	struct fs_driver_d *fsdrv;
 	char *p = normalise_path(pathname);
 	char *freep = p;
@@ -875,16 +872,16 @@ DIR *opendir(const char *pathname)
 	if (path_check_prereq(pathname, S_IFDIR))
 		goto out;
 
-	dev = get_fs_device_by_path(&p);
-	if (!dev)
+	fsdev = get_fs_device_and_root_path(&p);
+	if (!fsdev)
 		goto out;
-	fsdrv = dev_to_fs_driver(dev);
+	fsdrv = fsdev->driver;
 
 	debug("opendir: fsdrv: %p\n",fsdrv);
 
-	dir = fsdrv->opendir(dev, p);
+	dir = fsdrv->opendir(&fsdev->dev, p);
 	if (dir) {
-		dir->dev = dev;
+		dir->dev = &fsdev->dev;
 		dir->fsdrv = fsdrv;
 	}
 
@@ -951,20 +948,20 @@ EXPORT_SYMBOL(stat);
 int mkdir (const char *pathname, mode_t mode)
 {
 	struct fs_driver_d *fsdrv;
-	struct device_d *dev;
+	struct fs_device_d *fsdev;
 	char *p = normalise_path(pathname);
 	char *freep = p;
 
 	if (path_check_prereq(pathname, S_UB_DOES_NOT_EXIST))
 		goto out;
 
-	dev = get_fs_device_by_path(&p);
-	if (!dev)
+	fsdev = get_fs_device_and_root_path(&p);
+	if (!fsdev)
 		goto out;
-	fsdrv = dev_to_fs_driver(dev);
+	fsdrv = fsdev->driver;
 
 	if (fsdrv->mkdir) {
-		errno = fsdrv->mkdir(dev, p);
+		errno = fsdrv->mkdir(&fsdev->dev, p);
 		goto out;
 	}
 
@@ -978,20 +975,20 @@ EXPORT_SYMBOL(mkdir);
 int rmdir (const char *pathname)
 {
 	struct fs_driver_d *fsdrv;
-	struct device_d *dev;
+	struct fs_device_d *fsdev;
 	char *p = normalise_path(pathname);
 	char *freep = p;
 
 	if (path_check_prereq(pathname, S_IFDIR | S_UB_IS_EMPTY))
 		goto out;
 
-	dev = get_fs_device_by_path(&p);
-	if (!dev)
+	fsdev = get_fs_device_and_root_path(&p);
+	if (!fsdev)
 		goto out;
-	fsdrv = dev_to_fs_driver(dev);
+	fsdrv = fsdev->driver;
 
 	if (fsdrv->rmdir) {
-		errno = fsdrv->rmdir(dev, p);
+		errno = fsdrv->rmdir(&fsdev->dev, p);
 		goto out;
 	}
 
-- 
1.7.9.1


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

  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 ` Sascha Hauer [this message]
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 ` [PATCH 4/8] fs open: pass error from stat Sascha Hauer
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-2-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