mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 00/18] fs: add symlink and readlink support
@ 2012-08-24  4:46 Jean-Christophe PLAGNIOL-VILLARD
  2012-08-24  4:50 ` [PATCH 01/18] fs: add " Jean-Christophe PLAGNIOL-VILLARD
  0 siblings, 1 reply; 38+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-08-24  4:46 UTC (permalink / raw)
  To: barebox

HI,

please pull
The following changes since commit b77300ac6c6bbbc7eac774ff0076c7c05d39735f:

  command/mount: add autodetection support (2012-08-21 18:53:00 +0800)

are available in the git repository at:

  git://git.jcrosoft.org/barebox.git tags/fs-symlink

for you to fetch changes up to 64adf688f4f8cc6c0b7e1f3c4da29e881524c5f0:

  defautenv: add support of symlink (2012-08-23 21:31:57 +0800)

----------------------------------------------------------------
fs: add symlink and readlink support

This patch series introduce the support of symlink and readlink at

1) vfs level

2) libc API
 - symlink
 - readlink

3) commands
 - ln
 - readlink

3) filesystem
 - ramfs
 - nfs
 - envfs

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>

----------------------------------------------------------------
Jean-Christophe PLAGNIOL-VILLARD (18):
      fs: add readlink support
      fs: rename stat to lstat as we implement lstat
      fs: add symlink support
      fs: implement stat
      fs: open: add symlink support
      fs: introduce get_mounted_path to get the path where a file is mounted
      ramfs: add symlink and readlink support
      nfs: add readlink support
      test: add -L support to test if it's a symbolic link
      commands: add readlink support
      command: add ln support
      ls: add symlink support to -l
      dirname: add -V option to return only path related to the mountpoint
      recursive_action: add ACTION_FOLLOWLINKS support
      evnfs: introduce major and minor
      envfs: add support of variable inode size
      envfs: add support of symlink
      defautenv: add support of symlink

 commands/Kconfig       |   10 ++++++++
 commands/Makefile      |    2 ++
 commands/dirname.c     |   24 +++++++++++++++---
 commands/ln.c          |   51 +++++++++++++++++++++++++++++++++++++
 commands/ls.c          |   29 +++++++++++++--------
 commands/readlink.c    |   78 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 commands/test.c        |   11 ++++++--
 common/Makefile        |    2 +-
 common/environment.c   |  150 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------------------
 fs/fs.c                |  234 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-----
 fs/nfs.c               |   93 +++++++++++++++++++++++++++++++++++++++++++++++--------------------
 fs/ramfs.c             |   53 +++++++++++++++++++++++++++++++++-----
 include/envfs.h        |   15 +++++++++--
 include/fs.h           |   13 ++++++++++
 include/libbb.h        |    2 +-
 lib/recursive_action.c |    7 ++++-
 scripts/bareboxenv.c   |    2 +-
 17 files changed, 675 insertions(+), 101 deletions(-)
 create mode 100644 commands/ln.c
 create mode 100644 commands/readlink.c

Best Regards,
J.

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

^ permalink raw reply	[flat|nested] 38+ messages in thread

* [PATCH 01/18] fs: add readlink support
  2012-08-24  4:46 [PATCH 00/18] fs: add symlink and readlink support Jean-Christophe PLAGNIOL-VILLARD
@ 2012-08-24  4:50 ` Jean-Christophe PLAGNIOL-VILLARD
  2012-08-24  4:50   ` [PATCH 02/18] fs: rename stat to lstat as we implement lstat Jean-Christophe PLAGNIOL-VILLARD
                     ` (17 more replies)
  0 siblings, 18 replies; 38+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-08-24  4:50 UTC (permalink / raw)
  To: barebox

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
 fs/fs.c      |   59 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 include/fs.h |    5 +++++
 2 files changed, 64 insertions(+)

diff --git a/fs/fs.c b/fs/fs.c
index 8ab1a3a..64a0d94 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -890,6 +890,65 @@ int close(int fd)
 }
 EXPORT_SYMBOL(close);
 
+ssize_t readlink(const char *pathname, char *buf, size_t bufsiz)
+{
+	struct fs_driver_d *fsdrv;
+	struct fs_device_d *fsdev;
+	char *p = normalise_path(pathname);
+	char *freep = p;
+	int ret;
+	size_t len = 0;
+	char tmp[PATH_MAX];
+
+	tmp[0] = 0;
+	buf[0] = 0;
+
+	ret = path_check_prereq(pathname, S_IFLNK);
+	if (ret)
+		goto out;
+
+	fsdev = get_fs_device_and_root_path(&p);
+	if (!fsdev) {
+		ret = -ENODEV;
+		goto out;
+	}
+	fsdrv = fsdev->driver;
+
+	len = min(bufsiz, (size_t)PATH_MAX);
+	if (fsdrv->readlink) {
+		ret = fsdrv->readlink(&fsdev->dev, p, tmp, len);
+	} else {
+		ret = -EROFS;
+		goto out;
+	}
+
+	if (ret)
+		goto out;
+
+	if (tmp[0] == '/') {
+		int l = strlen(fsdev->path);
+
+		if (fsdev->path[l - 1] == '/')
+			l--;
+
+		if (l) {
+			len -= l;
+			strncat(buf, fsdev->path, l);
+		}
+	}
+
+	strncat(buf, tmp, len);
+
+out:
+	free(freep);
+
+	if (ret)
+		errno = -ret;
+
+	return ret;
+}
+EXPORT_SYMBOL(readlink);
+
 static int fs_match(struct device_d *dev, struct driver_d *drv)
 {
 	return strcmp(dev->name, drv->name) ? -1 : 0;
diff --git a/include/fs.h b/include/fs.h
index 22470e6..4c5a444 100644
--- a/include/fs.h
+++ b/include/fs.h
@@ -51,6 +51,9 @@ struct fs_driver_d {
 	/* Truncate a file to given size */
 	int (*truncate)(struct device_d *dev, FILE *f, ulong size);
 
+	int (*readlink)(struct device_d *dev, const char *pathname, char *name,
+			size_t size);
+
 	int (*open)(struct device_d *dev, FILE *f, const char *pathname);
 	int (*close)(struct device_d *dev, FILE *f);
 	int (*read)(struct device_d *dev, FILE *f, void *buf, size_t size);
@@ -129,6 +132,8 @@ DIR *opendir(const char *pathname);
 struct dirent *readdir(DIR *dir);
 int closedir(DIR *dir);
 
+ssize_t readlink(const char *path, char *buf, size_t bufsiz);
+
 int mount (const char *device, const char *fsname, const char *path);
 int umount(const char *pathname);
 
-- 
1.7.10.4


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

^ permalink raw reply	[flat|nested] 38+ messages in thread

* [PATCH 02/18] fs: rename stat to lstat as we implement lstat
  2012-08-24  4:50 ` [PATCH 01/18] fs: add " Jean-Christophe PLAGNIOL-VILLARD
@ 2012-08-24  4:50   ` Jean-Christophe PLAGNIOL-VILLARD
  2012-08-24  4:50   ` [PATCH 03/18] fs: add symlink support Jean-Christophe PLAGNIOL-VILLARD
                     ` (16 subsequent siblings)
  17 siblings, 0 replies; 38+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-08-24  4:50 UTC (permalink / raw)
  To: barebox

For compatibility put a inline on lstat for stat until we have the symlink
support.

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
 fs/fs.c      |   10 +++++-----
 include/fs.h |    6 +++++-
 2 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/fs/fs.c b/fs/fs.c
index 64a0d94..c950054 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -392,7 +392,7 @@ static int path_check_prereq(const char *path, unsigned int flags)
 	unsigned int m;
 	int ret = 0;
 
-	if (stat(path, &s)) {
+	if (lstat(path, &s)) {
 		if (flags & S_UB_DOES_NOT_EXIST)
 			goto out;
 		ret = -ENOENT;
@@ -434,7 +434,7 @@ static int parent_check_directory(const char *path)
 	int ret;
 	char *dir = dirname(xstrdup(path));
 
-	ret = stat(dir, &s);
+	ret = lstat(dir, &s);
 
 	free(dir);
 
@@ -523,7 +523,7 @@ int open(const char *pathname, int flags, ...)
 	char *freep = path;
 	int ret;
 
-	exist_err = stat(path, &s);
+	exist_err = lstat(path, &s);
 
 	if (!exist_err && S_ISDIR(s.st_mode)) {
 		ret = -EISDIR;
@@ -1217,7 +1217,7 @@ int closedir(DIR *dir)
 }
 EXPORT_SYMBOL(closedir);
 
-int stat(const char *filename, struct stat *s)
+int lstat(const char *filename, struct stat *s)
 {
 	struct device_d *dev;
 	struct fs_driver_d *fsdrv;
@@ -1256,7 +1256,7 @@ out:
 
 	return ret;
 }
-EXPORT_SYMBOL(stat);
+EXPORT_SYMBOL(lstat);
 
 int mkdir (const char *pathname, mode_t mode)
 {
diff --git a/include/fs.h b/include/fs.h
index 4c5a444..52e0f4f 100644
--- a/include/fs.h
+++ b/include/fs.h
@@ -109,7 +109,11 @@ int creat(const char *pathname, mode_t mode);
 int unlink(const char *pathname);
 int close(int fd);
 int flush(int fd);
-int stat(const char *filename, struct stat *s);
+int lstat(const char *filename, struct stat *s);
+static inline int stat(const char *filename, struct stat *s)
+{
+	return lstat(filename, s);
+}
 int read(int fd, void *buf, size_t count);
 int ioctl(int fd, int request, void *buf);
 ssize_t write(int fd, const void *buf, size_t count);
-- 
1.7.10.4


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

^ permalink raw reply	[flat|nested] 38+ messages in thread

* [PATCH 03/18] fs: add symlink support
  2012-08-24  4:50 ` [PATCH 01/18] fs: add " Jean-Christophe PLAGNIOL-VILLARD
  2012-08-24  4:50   ` [PATCH 02/18] fs: rename stat to lstat as we implement lstat Jean-Christophe PLAGNIOL-VILLARD
@ 2012-08-24  4:50   ` Jean-Christophe PLAGNIOL-VILLARD
  2012-08-27 13:35     ` Sascha Hauer
  2012-08-24  4:50   ` [PATCH 04/18] fs: implement stat Jean-Christophe PLAGNIOL-VILLARD
                     ` (15 subsequent siblings)
  17 siblings, 1 reply; 38+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-08-24  4:50 UTC (permalink / raw)
  To: barebox

Limit it's support to existing file only

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
 fs/fs.c      |   43 +++++++++++++++++++++++++++++++++++++++++++
 include/fs.h |    4 ++++
 2 files changed, 47 insertions(+)

diff --git a/fs/fs.c b/fs/fs.c
index c950054..a19e1f4 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -949,6 +949,49 @@ out:
 }
 EXPORT_SYMBOL(readlink);
 
+int symlink(const char *pathname, const char *newpath)
+{
+	struct fs_driver_d *fsdrv;
+	struct fs_device_d *fsdev;
+	char *p = normalise_path(pathname);
+	int ret;
+	struct stat s;
+
+	if (!stat(p, &s) && S_ISDIR(s.st_mode)) {
+		ret = -ENOSYS;
+		goto out;
+	}
+
+	free(p);
+	p = normalise_path(newpath);
+
+	ret = stat(p, &s);
+	if (!ret) {
+		ret = -EEXIST;
+		goto out;
+	}
+
+	fsdev = get_fs_device_and_root_path(&p);
+	if (!fsdev) {
+		ret = -ENODEV;
+		goto out;
+	}
+	fsdrv = fsdev->driver;
+
+	if (fsdrv->symlink) {
+		ret = fsdrv->symlink(&fsdev->dev, pathname, p);
+	} else {
+		ret = -EROFS;
+	}
+
+out:
+	if (ret)
+		errno = -ret;
+
+	return ret;
+}
+EXPORT_SYMBOL(symlink);
+
 static int fs_match(struct device_d *dev, struct driver_d *drv)
 {
 	return strcmp(dev->name, drv->name) ? -1 : 0;
diff --git a/include/fs.h b/include/fs.h
index 52e0f4f..d652ade 100644
--- a/include/fs.h
+++ b/include/fs.h
@@ -51,6 +51,8 @@ struct fs_driver_d {
 	/* Truncate a file to given size */
 	int (*truncate)(struct device_d *dev, FILE *f, ulong size);
 
+	int (*symlink)(struct device_d *dev, const char *pathname,
+		       const char *newpath);
 	int (*readlink)(struct device_d *dev, const char *pathname, char *name,
 			size_t size);
 
@@ -136,6 +138,8 @@ DIR *opendir(const char *pathname);
 struct dirent *readdir(DIR *dir);
 int closedir(DIR *dir);
 
+
+int symlink(const char *pathname, const char *newpath);
 ssize_t readlink(const char *path, char *buf, size_t bufsiz);
 
 int mount (const char *device, const char *fsname, const char *path);
-- 
1.7.10.4


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

^ permalink raw reply	[flat|nested] 38+ messages in thread

* [PATCH 04/18] fs: implement stat
  2012-08-24  4:50 ` [PATCH 01/18] fs: add " Jean-Christophe PLAGNIOL-VILLARD
  2012-08-24  4:50   ` [PATCH 02/18] fs: rename stat to lstat as we implement lstat Jean-Christophe PLAGNIOL-VILLARD
  2012-08-24  4:50   ` [PATCH 03/18] fs: add symlink support Jean-Christophe PLAGNIOL-VILLARD
@ 2012-08-24  4:50   ` Jean-Christophe PLAGNIOL-VILLARD
  2012-08-24  9:25     ` Roberto Nibali
  2012-08-27 13:52     ` Sascha Hauer
  2012-08-24  4:50   ` [PATCH 05/18] fs: open: add symlink support Jean-Christophe PLAGNIOL-VILLARD
                     ` (14 subsequent siblings)
  17 siblings, 2 replies; 38+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-08-24  4:50 UTC (permalink / raw)
  To: barebox

stat() stats the file pointed to by path and fills in buf.

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
 fs/fs.c      |  102 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 include/fs.h |    6 ++--
 2 files changed, 104 insertions(+), 4 deletions(-)

diff --git a/fs/fs.c b/fs/fs.c
index a19e1f4..9f2e82c 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -26,6 +26,7 @@
 #include <errno.h>
 #include <malloc.h>
 #include <linux/stat.h>
+#include <linux/err.h>
 #include <fcntl.h>
 #include <xfuncs.h>
 #include <init.h>
@@ -111,6 +112,60 @@ static int init_cwd(void)
 
 postcore_initcall(init_cwd);
 
+char *normalise_link(const char *pathname, const char* symlink)
+{
+	const char *buf = symlink;
+	char *path_free, *path;
+	char *absolute_path;
+	int point = 0;
+	int dir = 1;
+	int len;
+
+	if (symlink[0] == '/')
+		return strdup(symlink);
+
+	path = path_free = strdup(pathname);
+
+	while (*buf == '.' || *buf == '/') {
+		if (*buf == '.') {
+			point++;
+		} else if (*buf == '/') {
+			point = 0;
+			dir++;
+		}
+		if (point > 2) {
+			buf -= 2;
+			break;
+		}
+		buf++;
+	}
+
+	if (dir) {
+		while(dir) {
+			path = dirname(path);
+			dir--;
+		}
+	}
+
+	len = strlen(buf) + strlen(path) + 1;
+	if (buf[0] != '/')
+		len++;
+
+	absolute_path = calloc(sizeof(char), len);
+
+	if(!absolute_path)
+		return NULL;
+
+	strcat(absolute_path, path);
+	if (buf[0] != '/')
+		strcat(absolute_path, "/");
+	strcat(absolute_path, buf);
+
+	free(path_free);
+
+	return absolute_path;
+}
+
 char *normalise_path(const char *pathname)
 {
 	char *path = xzalloc(strlen(pathname) + strlen(cwd) + 2);
@@ -512,6 +567,40 @@ out:
 }
 EXPORT_SYMBOL(unlink);
 
+static char* realfile(const char *pathname, struct stat *s)
+{
+	char *path = normalise_path(pathname);
+	int ret;
+
+	ret = lstat(path, s);
+	if (ret)
+		goto out;
+
+	if (S_ISLNK(s->st_mode)) {
+		char tmp[PATH_MAX];
+		char *new_path;
+
+		ret = readlink(path, tmp, PATH_MAX);
+		if (ret < 0)
+			goto out;
+
+		new_path = normalise_link(path, tmp);
+		free(path);
+		if (!new_path)
+			return ERR_PTR(-ENOMEM);
+		path = new_path;
+
+		ret = lstat(path, s);
+	}
+
+	if (!ret)
+		return path;
+
+out:
+	free(path);
+	return ERR_PTR(ret);
+}
+
 int open(const char *pathname, int flags, ...)
 {
 	struct fs_device_d *fsdev;
@@ -1260,6 +1349,19 @@ int closedir(DIR *dir)
 }
 EXPORT_SYMBOL(closedir);
 
+int stat(const char *filename, struct stat *s)
+{
+	char *f;
+
+	f = realfile(filename, s);
+	if (IS_ERR(f))
+		return PTR_ERR(f);
+
+	free(f);
+	return 0;
+}
+EXPORT_SYMBOL(stat);
+
 int lstat(const char *filename, struct stat *s)
 {
 	struct device_d *dev;
diff --git a/include/fs.h b/include/fs.h
index d652ade..263823a 100644
--- a/include/fs.h
+++ b/include/fs.h
@@ -112,10 +112,7 @@ int unlink(const char *pathname);
 int close(int fd);
 int flush(int fd);
 int lstat(const char *filename, struct stat *s);
-static inline int stat(const char *filename, struct stat *s)
-{
-	return lstat(filename, s);
-}
+int stat(const char *filename, struct stat *s);
 int read(int fd, void *buf, size_t count);
 int ioctl(int fd, int request, void *buf);
 ssize_t write(int fd, const void *buf, size_t count);
@@ -175,6 +172,7 @@ void *read_file(const char *filename, size_t *size);
  * of "..", "." and double slashes. The returned string must be freed wit free().
  */
 char *normalise_path(const char *path);
+char *normalise_link(const char *pathname, const char* symlink);
 
 /* Register a new filesystem driver */
 int register_fs_driver(struct fs_driver_d *fsdrv);
-- 
1.7.10.4


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

^ permalink raw reply	[flat|nested] 38+ messages in thread

* [PATCH 05/18] fs: open: add symlink support
  2012-08-24  4:50 ` [PATCH 01/18] fs: add " Jean-Christophe PLAGNIOL-VILLARD
                     ` (2 preceding siblings ...)
  2012-08-24  4:50   ` [PATCH 04/18] fs: implement stat Jean-Christophe PLAGNIOL-VILLARD
@ 2012-08-24  4:50   ` Jean-Christophe PLAGNIOL-VILLARD
  2012-08-24  4:50   ` [PATCH 06/18] fs: introduce get_mounted_path to get the path where a file is mounted Jean-Christophe PLAGNIOL-VILLARD
                     ` (13 subsequent siblings)
  17 siblings, 0 replies; 38+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-08-24  4:50 UTC (permalink / raw)
  To: barebox

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
 fs/fs.c |   15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/fs/fs.c b/fs/fs.c
index 9f2e82c..ca6340c 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -606,13 +606,20 @@ int open(const char *pathname, int flags, ...)
 	struct fs_device_d *fsdev;
 	struct fs_driver_d *fsdrv;
 	FILE *f;
-	int exist_err;
+	int exist_err = 0;
 	struct stat s;
-	char *path = normalise_path(pathname);
-	char *freep = path;
+	char *path;
+	char *freep;
 	int ret;
 
-	exist_err = lstat(path, &s);
+	path = realfile(pathname, &s);
+
+	if (IS_ERR(path)) {
+		exist_err = PTR_ERR(path);
+		path = normalise_path(pathname);
+	}
+
+	freep = path;
 
 	if (!exist_err && S_ISDIR(s.st_mode)) {
 		ret = -EISDIR;
-- 
1.7.10.4


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

^ permalink raw reply	[flat|nested] 38+ messages in thread

* [PATCH 06/18] fs: introduce get_mounted_path to get the path where a file is mounted
  2012-08-24  4:50 ` [PATCH 01/18] fs: add " Jean-Christophe PLAGNIOL-VILLARD
                     ` (3 preceding siblings ...)
  2012-08-24  4:50   ` [PATCH 05/18] fs: open: add symlink support Jean-Christophe PLAGNIOL-VILLARD
@ 2012-08-24  4:50   ` Jean-Christophe PLAGNIOL-VILLARD
  2012-08-27 13:53     ` Sascha Hauer
  2012-08-24  4:50   ` [PATCH 07/18] ramfs: add symlink and readlink support Jean-Christophe PLAGNIOL-VILLARD
                     ` (12 subsequent siblings)
  17 siblings, 1 reply; 38+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-08-24  4:50 UTC (permalink / raw)
  To: barebox

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
 fs/fs.c      |    9 +++++++++
 include/fs.h |    2 ++
 2 files changed, 11 insertions(+)

diff --git a/fs/fs.c b/fs/fs.c
index ca6340c..8ec368c 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -242,6 +242,15 @@ static struct fs_device_d *get_fsdevice_by_path(const char *path)
 	return fs_dev_root;
 }
 
+char* get_mounted_path(const char *path)
+{
+	struct fs_device_d *fdev;
+
+	fdev = get_fsdevice_by_path(path);
+
+	return fdev->path;
+}
+
 static FILE files[MAX_FILES];
 
 static FILE *get_file(void)
diff --git a/include/fs.h b/include/fs.h
index 263823a..19b4418 100644
--- a/include/fs.h
+++ b/include/fs.h
@@ -174,6 +174,8 @@ void *read_file(const char *filename, size_t *size);
 char *normalise_path(const char *path);
 char *normalise_link(const char *pathname, const char* symlink);
 
+char* get_mounted_path(const char *path);
+
 /* Register a new filesystem driver */
 int register_fs_driver(struct fs_driver_d *fsdrv);
 
-- 
1.7.10.4


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

^ permalink raw reply	[flat|nested] 38+ messages in thread

* [PATCH 07/18] ramfs: add symlink and readlink support
  2012-08-24  4:50 ` [PATCH 01/18] fs: add " Jean-Christophe PLAGNIOL-VILLARD
                     ` (4 preceding siblings ...)
  2012-08-24  4:50   ` [PATCH 06/18] fs: introduce get_mounted_path to get the path where a file is mounted Jean-Christophe PLAGNIOL-VILLARD
@ 2012-08-24  4:50   ` Jean-Christophe PLAGNIOL-VILLARD
  2012-08-27 13:59     ` Sascha Hauer
  2012-08-24  4:50   ` [PATCH 08/18] nfs: add " Jean-Christophe PLAGNIOL-VILLARD
                     ` (11 subsequent siblings)
  17 siblings, 1 reply; 38+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-08-24  4:50 UTC (permalink / raw)
  To: barebox

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
 fs/ramfs.c |   53 ++++++++++++++++++++++++++++++++++++++++++++++-------
 1 file changed, 46 insertions(+), 7 deletions(-)

diff --git a/fs/ramfs.c b/fs/ramfs.c
index 91d06b8..38da593 100644
--- a/fs/ramfs.c
+++ b/fs/ramfs.c
@@ -42,6 +42,7 @@ struct ramfs_inode {
 	struct ramfs_inode *parent;
 	struct ramfs_inode *next;
 	struct ramfs_inode *child;
+	char *symlink;
 	ulong mode;
 
 	struct handle_d *handle;
@@ -176,6 +177,7 @@ static void ramfs_put_inode(struct ramfs_inode *node)
 		data = tmp;
 	}
 
+	free(node->symlink);
 	free(node->name);
 	free(node);
 }
@@ -212,18 +214,28 @@ static struct ramfs_inode* node_insert(struct ramfs_inode *parent_node, const ch
 
 /* ---------------------------------------------------------------*/
 
-static int ramfs_create(struct device_d *dev, const char *pathname, mode_t mode)
+static int __ramfs_create(struct device_d *dev, const char *pathname,
+			  mode_t mode, const char *symlink)
 {
 	struct ramfs_priv *priv = dev->priv;
 	struct ramfs_inode *node;
 	char *file;
 
 	node = rlookup_parent(priv, pathname, &file);
-	if (node) {
-		node_insert(node, file, mode);
-		return 0;
-	}
-	return -ENOENT;
+	if (!node)
+		return -ENOENT;
+
+	node = node_insert(node, file, mode);
+	if (!node)
+		return -ENOMEM;
+	node->symlink = strdup(symlink);
+
+	return 0;
+}
+
+static int ramfs_create(struct device_d *dev, const char *pathname, mode_t mode)
+{
+	return __ramfs_create(dev, pathname, mode, NULL);
 }
 
 static int ramfs_unlink(struct device_d *dev, const char *pathname)
@@ -532,12 +544,37 @@ static int ramfs_stat(struct device_d *dev, const char *filename, struct stat *s
 	if (!node)
 		return -ENOENT;
 
-	s->st_size = node->size;
+	s->st_size = node->symlink ? strlen(node->symlink) : node->size;
 	s->st_mode = node->mode;
 
 	return 0;
 }
 
+static int ramfs_symlink(struct device_d *dev, const char *pathname,
+		       const char *newpath)
+{
+	mode_t mode = S_IFLNK | S_IRWXU | S_IRWXG | S_IRWXO;
+
+	return __ramfs_create(dev, newpath, mode, pathname);
+}
+
+static int ramfs_readlink(struct device_d *dev, const char *pathname,
+			char *buf, size_t bufsiz)
+{
+	struct ramfs_priv *priv = dev->priv;
+	struct ramfs_inode *node = rlookup(priv, pathname);
+	int len;
+
+	if (!node || !node->symlink)
+		return -ENOENT;
+
+	len = min(bufsiz, strlen(node->symlink));
+
+	strncat(buf, node->symlink, len);
+
+	return 0;
+}
+
 static int ramfs_probe(struct device_d *dev)
 {
 	struct ramfs_inode *n;
@@ -584,6 +621,8 @@ static struct fs_driver_d ramfs_driver = {
 	.readdir   = ramfs_readdir,
 	.closedir  = ramfs_closedir,
 	.stat      = ramfs_stat,
+	.symlink   = ramfs_symlink,
+	.readlink  = ramfs_readlink,
 	.flags     = FS_DRIVER_NO_DEV,
 	.drv = {
 		.probe  = ramfs_probe,
-- 
1.7.10.4


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

^ permalink raw reply	[flat|nested] 38+ messages in thread

* [PATCH 08/18] nfs: add readlink support
  2012-08-24  4:50 ` [PATCH 01/18] fs: add " Jean-Christophe PLAGNIOL-VILLARD
                     ` (5 preceding siblings ...)
  2012-08-24  4:50   ` [PATCH 07/18] ramfs: add symlink and readlink support Jean-Christophe PLAGNIOL-VILLARD
@ 2012-08-24  4:50   ` Jean-Christophe PLAGNIOL-VILLARD
  2012-08-27 14:04     ` Sascha Hauer
  2012-08-24  4:50   ` [PATCH 09/18] test: add -L support to test if it's a symbolic link Jean-Christophe PLAGNIOL-VILLARD
                     ` (10 subsequent siblings)
  17 siblings, 1 reply; 38+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-08-24  4:50 UTC (permalink / raw)
  To: barebox

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
 fs/nfs.c |   93 +++++++++++++++++++++++++++++++++++++++++++-------------------
 1 file changed, 65 insertions(+), 28 deletions(-)

diff --git a/fs/nfs.c b/fs/nfs.c
index 79e667f..a4e1f91 100644
--- a/fs/nfs.c
+++ b/fs/nfs.c
@@ -605,34 +605,6 @@ static int nfs_read_req(struct file_priv *priv, int offset, int readlen)
 	return 0;
 }
 
-#if 0
-static int nfs_readlink_reply(unsigned char *pkt, unsigned len)
-{
-	uint32_t *data;
-	char *path;
-	int rlen;
-//	int ret;
-
-	data = (uint32_t *)(pkt + sizeof(struct rpc_reply));
-
-	data++;
-
-	rlen = ntohl(net_read_uint32(data)); /* new path length */
-
-	data++;
-	path = (char *)data;
-
-	if (*path != '/') {
-		strcat(nfs_path, "/");
-		strncat(nfs_path, path, rlen);
-	} else {
-		memcpy(nfs_path, path, rlen);
-		nfs_path[rlen] = 0;
-	}
-	return 0;
-}
-#endif
-
 static void nfs_handler(void *ctx, char *packet, unsigned len)
 {
 	char *pkt = net_eth_to_udp_payload(packet);
@@ -742,6 +714,70 @@ static struct file_priv *nfs_do_stat(struct device_d *dev, const char *filename,
 	return priv;
 }
 
+static int nfs_readlink_req(struct file_priv *priv, char* buf, size_t size)
+{
+	uint32_t data[1024];
+	uint32_t *p;
+	int len;
+	int ret;
+	char *path;
+	uint32_t *filedata;
+
+	p = &(data[0]);
+	p = rpc_add_credentials(p);
+
+	memcpy(p, priv->filefh, NFS_FHSIZE);
+	p += (NFS_FHSIZE / 4);
+
+	len = p - &(data[0]);
+
+	ret = rpc_req(priv->npriv, PROG_NFS, NFS_READLINK, data, len);
+	if (ret)
+		return ret;
+
+	filedata = nfs_packet + sizeof(struct rpc_reply);
+	filedata++;
+
+	len = ntohl(net_read_uint32(filedata)); /* new path length */
+	filedata++;
+
+	path = (char *)filedata;
+
+	if (len > size)
+		len = size;
+
+	memcpy(buf, path, len);
+	buf[len] = 0;
+
+	return 0;
+}
+
+static int nfs_readlink(struct device_d *dev, const char *filename,
+			char *realname, size_t size)
+{
+	struct file_priv *priv;
+	int ret;
+	struct stat s;
+
+	priv = nfs_do_stat(dev, filename, &s);
+	if (IS_ERR(priv))
+		return PTR_ERR(priv);
+
+
+	if (S_ISDIR(s.st_mode))
+		strcat(realname, filename);
+	else
+		strcat(realname, dirname((char*)filename));
+
+	ret = nfs_readlink_req(priv, realname, size);
+	if (ret) {
+		nfs_do_close(priv);
+		return ret;
+	}
+
+	return 0;
+}
+
 static int nfs_open(struct device_d *dev, FILE *file, const char *filename)
 {
 	struct file_priv *priv;
@@ -1039,6 +1075,7 @@ static struct fs_driver_d nfs_driver = {
 	.rmdir     = nfs_rmdir,
 	.write     = nfs_write,
 	.truncate  = nfs_truncate,
+	.readlink  = nfs_readlink,
 	.flags     = 0,
 	.drv = {
 		.probe  = nfs_probe,
-- 
1.7.10.4


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

^ permalink raw reply	[flat|nested] 38+ messages in thread

* [PATCH 09/18] test: add -L support to test if it's a symbolic link
  2012-08-24  4:50 ` [PATCH 01/18] fs: add " Jean-Christophe PLAGNIOL-VILLARD
                     ` (6 preceding siblings ...)
  2012-08-24  4:50   ` [PATCH 08/18] nfs: add " Jean-Christophe PLAGNIOL-VILLARD
@ 2012-08-24  4:50   ` Jean-Christophe PLAGNIOL-VILLARD
  2012-08-24  4:50   ` [PATCH 10/18] commands: add readlink support Jean-Christophe PLAGNIOL-VILLARD
                     ` (9 subsequent siblings)
  17 siblings, 0 replies; 38+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-08-24  4:50 UTC (permalink / raw)
  To: barebox

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
 commands/test.c |   11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/commands/test.c b/commands/test.c
index 9ffa892..56e8c52 100644
--- a/commands/test.c
+++ b/commands/test.c
@@ -44,6 +44,7 @@ typedef enum {
 	OPT_FILE,
 	OPT_EXISTS,
 	OPT_MAX,
+	OPT_SYMBOLIC_LINK,
 } test_opts;
 
 static char *test_options[] = {
@@ -62,6 +63,7 @@ static char *test_options[] = {
 	[OPT_FILE]			= "-f",
 	[OPT_DIRECTORY]			= "-d",
 	[OPT_EXISTS]			= "-e",
+	[OPT_SYMBOLIC_LINK]		= "-L",
 };
 
 static int parse_opt(const char *opt)
@@ -140,9 +142,10 @@ static int do_test(int argc, char *argv[])
 		case OPT_FILE:
 		case OPT_DIRECTORY:
 		case OPT_EXISTS:
+		case OPT_SYMBOLIC_LINK:
 			adv = 2;
 			if (ap[1] && *ap[1] != ']' && strlen(ap[1])) {
-				expr = stat(ap[1], &statbuf);
+				expr = (opt == OPT_SYMBOLIC_LINK ? lstat : stat)(ap[1], &statbuf);
 				if (expr < 0) {
 					expr = 0;
 					break;
@@ -160,6 +163,10 @@ static int do_test(int argc, char *argv[])
 					expr = 1;
 					break;
 				}
+				if (opt == OPT_SYMBOLIC_LINK && S_ISLNK(statbuf.st_mode)) {
+					expr = 1;
+					break;
+				}
 			}
 			break;
 
@@ -224,7 +231,7 @@ static const char *test_aliases[] = { "[", NULL};
 
 static const __maybe_unused char cmd_test_help[] =
 "Usage: test [OPTIONS]\n"
-"options: !, =, !=, -eq, -ne, -ge, -gt, -le, -lt, -o, -a, -z, -n, -d, -e, -f\n"
+"options: !, =, !=, -eq, -ne, -ge, -gt, -le, -lt, -o, -a, -z, -n, -d, -e, -f, -L\n"
 "see 'man test' on your PC for more information.\n";
 
 static const __maybe_unused char cmd_test_usage[] = "minimal test like /bin/sh";
-- 
1.7.10.4


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

^ permalink raw reply	[flat|nested] 38+ messages in thread

* [PATCH 10/18] commands: add readlink support
  2012-08-24  4:50 ` [PATCH 01/18] fs: add " Jean-Christophe PLAGNIOL-VILLARD
                     ` (7 preceding siblings ...)
  2012-08-24  4:50   ` [PATCH 09/18] test: add -L support to test if it's a symbolic link Jean-Christophe PLAGNIOL-VILLARD
@ 2012-08-24  4:50   ` Jean-Christophe PLAGNIOL-VILLARD
  2012-08-24  9:31     ` Roberto Nibali
  2012-08-24  4:50   ` [PATCH 11/18] command: add ln support Jean-Christophe PLAGNIOL-VILLARD
                     ` (8 subsequent siblings)
  17 siblings, 1 reply; 38+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-08-24  4:50 UTC (permalink / raw)
  To: barebox

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
 commands/Kconfig    |    6 ++++
 commands/Makefile   |    1 +
 commands/readlink.c |   78 +++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 85 insertions(+)
 create mode 100644 commands/readlink.c

diff --git a/commands/Kconfig b/commands/Kconfig
index 92a8152..876f2f8 100644
--- a/commands/Kconfig
+++ b/commands/Kconfig
@@ -220,6 +220,12 @@ config CMD_DIRNAME
 	  Strip last component of file name and store the result in a
 	  environment variable
 
+config CMD_READLINK
+	tristate
+	prompt "readlink"
+	help
+	  read value of a symbolic link
+
 endmenu
 
 menu "console                       "
diff --git a/commands/Makefile b/commands/Makefile
index e9157bf..ab6c7ea 100644
--- a/commands/Makefile
+++ b/commands/Makefile
@@ -72,3 +72,4 @@ obj-$(CONFIG_CMD_AUTOMOUNT)	+= automount.o
 obj-$(CONFIG_CMD_GLOBAL)	+= global.o
 obj-$(CONFIG_CMD_BASENAME)	+= basename.o
 obj-$(CONFIG_CMD_DIRNAME)	+= dirname.o
+obj-$(CONFIG_CMD_READLINK)	+= readlink.o
diff --git a/commands/readlink.c b/commands/readlink.c
new file mode 100644
index 0000000..72cea18
--- /dev/null
+++ b/commands/readlink.c
@@ -0,0 +1,78 @@
+/*
+ * readlink.c - read value of a symbolic link
+ *
+ * Copyright (c) 2012 Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#include <common.h>
+#include <command.h>
+#include <libgen.h>
+#include <environment.h>
+#include <fs.h>
+#include <malloc.h>
+#include <getopt.h>
+
+static int do_readlink(int argc, char *argv[])
+{
+	char realname[PATH_MAX];
+	int canonicalize = 0;
+	int opt;
+
+	while ((opt = getopt(argc, argv, "f")) > 0) {
+		switch (opt) {
+		case 'f':
+			canonicalize = 1;
+			break;
+		}
+	}
+
+	if (argc < optind + 2)
+		return COMMAND_ERROR_USAGE;
+
+	if (readlink(argv[optind], realname, PATH_MAX) < 0)
+		goto err;
+
+	if (canonicalize) {
+		char *buf = normalise_link(argv[optind], realname);
+
+		if (!buf)
+			goto err;
+		setenv(argv[optind + 1], buf);
+		free(buf);
+	} else {
+		setenv(argv[optind + 1], realname);
+	}
+
+	return 0;
+err:
+	setenv(argv[optind + 1], "");
+	return 1;
+}
+
+BAREBOX_CMD_HELP_START(readlink)
+BAREBOX_CMD_HELP_USAGE("readlink [-f] FILE REALNAME\n")
+BAREBOX_CMD_HELP_SHORT("read value of a symbolic link and store into $REALNAME\n")
+BAREBOX_CMD_HELP_SHORT("-f canonicalize by following first symlink");
+BAREBOX_CMD_HELP_END
+
+BAREBOX_CMD_START(readlink)
+	.cmd		= do_readlink,
+	.usage		= "read value of a symbolic link",
+	BAREBOX_CMD_HELP(cmd_readlink_help)
+BAREBOX_CMD_END
-- 
1.7.10.4


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

^ permalink raw reply	[flat|nested] 38+ messages in thread

* [PATCH 11/18] command: add ln support
  2012-08-24  4:50 ` [PATCH 01/18] fs: add " Jean-Christophe PLAGNIOL-VILLARD
                     ` (8 preceding siblings ...)
  2012-08-24  4:50   ` [PATCH 10/18] commands: add readlink support Jean-Christophe PLAGNIOL-VILLARD
@ 2012-08-24  4:50   ` Jean-Christophe PLAGNIOL-VILLARD
  2012-08-24  4:50   ` [PATCH 12/18] ls: add symlink support to -l Jean-Christophe PLAGNIOL-VILLARD
                     ` (7 subsequent siblings)
  17 siblings, 0 replies; 38+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-08-24  4:50 UTC (permalink / raw)
  To: barebox

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
 commands/Kconfig  |    4 ++++
 commands/Makefile |    1 +
 commands/ln.c     |   51 +++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 56 insertions(+)
 create mode 100644 commands/ln.c

diff --git a/commands/Kconfig b/commands/Kconfig
index 876f2f8..337f545 100644
--- a/commands/Kconfig
+++ b/commands/Kconfig
@@ -57,6 +57,10 @@ config CMD_READLINE
 	tristate
 	prompt "readline"
 
+config CMD_LN
+	tristate
+	prompt "ln"
+
 config CMD_TRUE
 	tristate
 	default y
diff --git a/commands/Makefile b/commands/Makefile
index ab6c7ea..ccebd7f 100644
--- a/commands/Makefile
+++ b/commands/Makefile
@@ -73,3 +73,4 @@ obj-$(CONFIG_CMD_GLOBAL)	+= global.o
 obj-$(CONFIG_CMD_BASENAME)	+= basename.o
 obj-$(CONFIG_CMD_DIRNAME)	+= dirname.o
 obj-$(CONFIG_CMD_READLINK)	+= readlink.o
+obj-$(CONFIG_CMD_LN)		+= ln.o
diff --git a/commands/ln.c b/commands/ln.c
new file mode 100644
index 0000000..0237447
--- /dev/null
+++ b/commands/ln.c
@@ -0,0 +1,51 @@
+/*
+ * ln.c - make links between files
+ *
+ * Copyright (c) 2012 Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#include <common.h>
+#include <command.h>
+#include <libgen.h>
+#include <environment.h>
+#include <fs.h>
+#include <errno.h>
+
+static int do_ln(int argc, char *argv[])
+{
+	if (argc != 3)
+		return COMMAND_ERROR_USAGE;
+
+	if (symlink(argv[1], argv[2]) < 0) {
+		perror("ln");
+		return 1;
+	}
+	return 0;
+}
+
+BAREBOX_CMD_HELP_START(ln)
+BAREBOX_CMD_HELP_USAGE("ln SRC DEST\n")
+BAREBOX_CMD_HELP_SHORT("symlink - make a new name for a file\n")
+BAREBOX_CMD_HELP_END
+
+BAREBOX_CMD_START(ln)
+	.cmd		= do_ln,
+	.usage		= "symlink - make a new name for a file",
+	BAREBOX_CMD_HELP(cmd_ln_help)
+BAREBOX_CMD_END
-- 
1.7.10.4


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

^ permalink raw reply	[flat|nested] 38+ messages in thread

* [PATCH 12/18] ls: add symlink support to -l
  2012-08-24  4:50 ` [PATCH 01/18] fs: add " Jean-Christophe PLAGNIOL-VILLARD
                     ` (9 preceding siblings ...)
  2012-08-24  4:50   ` [PATCH 11/18] command: add ln support Jean-Christophe PLAGNIOL-VILLARD
@ 2012-08-24  4:50   ` Jean-Christophe PLAGNIOL-VILLARD
  2012-08-24  4:50   ` [PATCH 13/18] dirname: add -V option to return only path related to the mountpoint Jean-Christophe PLAGNIOL-VILLARD
                     ` (6 subsequent siblings)
  17 siblings, 0 replies; 38+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-08-24  4:50 UTC (permalink / raw)
  To: barebox

barebox:/ ls -l /env/init.d/
drwxrwxrwx          0 .
drwxrwxrwx          0 ..
lrwxrwxrwx         11 net -> ../boot/net

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
 commands/ls.c |   29 +++++++++++++++++++----------
 1 file changed, 19 insertions(+), 10 deletions(-)

diff --git a/commands/ls.c b/commands/ls.c
index fbcbadc..8c14cd1 100644
--- a/commands/ls.c
+++ b/commands/ls.c
@@ -29,13 +29,22 @@
 #include <getopt.h>
 #include <stringlist.h>
 
-static void ls_one(const char *path, struct stat *s)
+static void ls_one(const char *path, const char* fullname, struct stat *s)
 {
 	char modestr[11];
 	unsigned int namelen = strlen(path);
 
 	mkmodestr(s->st_mode, modestr);
-	printf("%s %10llu %*.*s\n", modestr, s->st_size, namelen, namelen, path);
+	printf("%s %10llu %*.*s", modestr, s->st_size, namelen, namelen, path);
+
+	if (S_ISLNK(s->st_mode)) {
+		char realname[PATH_MAX];
+
+		if (readlink(fullname, realname, PATH_MAX) >= 0)
+			printf(" -> %s", realname);
+	}
+
+	puts("\n");
 }
 
 int ls(const char *path, ulong flags)
@@ -48,14 +57,14 @@ int ls(const char *path, ulong flags)
 
 	string_list_init(&sl);
 
-	if (stat(path, &s))
+	if (lstat(path, &s))
 		return -errno;
 
 	if (flags & LS_SHOWARG && s.st_mode & S_IFDIR)
 		printf("%s:\n", path);
 
 	if (!(s.st_mode & S_IFDIR)) {
-		ls_one(path, &s);
+		ls_one(path, path, &s);
 		return 0;
 	}
 
@@ -65,12 +74,12 @@ int ls(const char *path, ulong flags)
 
 	while ((d = readdir(dir))) {
 		sprintf(tmp, "%s/%s", path, d->d_name);
-		if (stat(tmp, &s))
+		if (lstat(tmp, &s))
 			goto out;
 		if (flags & LS_COLUMN)
 			string_list_add_sorted(&sl, d->d_name);
 		else
-			ls_one(d->d_name, &s);
+			ls_one(d->d_name, tmp, &s);
 	}
 
 	closedir(dir);
@@ -97,7 +106,7 @@ int ls(const char *path, ulong flags)
 			continue;
 		sprintf(tmp, "%s/%s", path, d->d_name);
 
-		if (stat(tmp, &s))
+		if (lstat(tmp, &s))
 			goto out;
 		if (s.st_mode & S_IFDIR) {
 			char *norm = normalise_path(tmp);
@@ -146,7 +155,7 @@ static int do_ls(int argc, char *argv[])
 
 	/* first pass: all files */
 	while (o < argc) {
-		ret = stat(argv[o], &s);
+		ret = lstat(argv[o], &s);
 		if (ret) {
 			printf("%s: %s: %s\n", argv[0],
 					argv[o], errno_str());
@@ -158,7 +167,7 @@ static int do_ls(int argc, char *argv[])
 			if (flags & LS_COLUMN)
 				string_list_add_sorted(&sl, argv[o]);
 			else
-				ls_one(argv[o], &s);
+				ls_one(argv[o], argv[o], &s);
 		}
 
 		o++;
@@ -173,7 +182,7 @@ static int do_ls(int argc, char *argv[])
 
 	/* second pass: directories */
 	while (o < argc) {
-		ret = stat(argv[o], &s);
+		ret = lstat(argv[o], &s);
 		if (ret) {
 			o++;
 			continue;
-- 
1.7.10.4


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

^ permalink raw reply	[flat|nested] 38+ messages in thread

* [PATCH 13/18] dirname: add -V option to return only path related to the mountpoint
  2012-08-24  4:50 ` [PATCH 01/18] fs: add " Jean-Christophe PLAGNIOL-VILLARD
                     ` (10 preceding siblings ...)
  2012-08-24  4:50   ` [PATCH 12/18] ls: add symlink support to -l Jean-Christophe PLAGNIOL-VILLARD
@ 2012-08-24  4:50   ` Jean-Christophe PLAGNIOL-VILLARD
  2012-08-24  4:50   ` [PATCH 14/18] recursive_action: add ACTION_FOLLOWLINKS support Jean-Christophe PLAGNIOL-VILLARD
                     ` (5 subsequent siblings)
  17 siblings, 0 replies; 38+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-08-24  4:50 UTC (permalink / raw)
  To: barebox

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
 commands/dirname.c |   24 +++++++++++++++++++++---
 1 file changed, 21 insertions(+), 3 deletions(-)

diff --git a/commands/dirname.c b/commands/dirname.c
index cf1d0a0..f34d88d 100644
--- a/commands/dirname.c
+++ b/commands/dirname.c
@@ -24,20 +24,38 @@
 #include <command.h>
 #include <libgen.h>
 #include <environment.h>
+#include <fs.h>
+#include <getopt.h>
 
 static int do_dirname(int argc, char *argv[])
 {
-	if (argc != 3)
+	int opt;
+	int path_fs = 0;
+	int len = 0;
+
+	while ((opt = getopt(argc, argv, "V")) > 0) {
+		switch (opt) {
+		case 'V':
+			path_fs = 1;
+			break;
+		}
+	}
+
+	if (argc < optind + 2)
 		return COMMAND_ERROR_USAGE;
 
-	setenv(argv[2], dirname(argv[1]));
+	if (path_fs)
+		len = strlen(get_mounted_path(argv[optind]));
+
+	setenv(argv[optind + 1], dirname(argv[optind]) + len);
 
 	return 0;
 }
 
 BAREBOX_CMD_HELP_START(dirname)
-BAREBOX_CMD_HELP_USAGE("dirname NAME DIRNAME\n")
+BAREBOX_CMD_HELP_USAGE("dirname [-V] NAME DIRNAME\n")
 BAREBOX_CMD_HELP_SHORT("strip last componext of NAME and store into $DIRNAME\n")
+BAREBOX_CMD_HELP_SHORT("-V return the path relative to the mountpoint.\n")
 BAREBOX_CMD_HELP_END
 
 BAREBOX_CMD_START(dirname)
-- 
1.7.10.4


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

^ permalink raw reply	[flat|nested] 38+ messages in thread

* [PATCH 14/18] recursive_action: add ACTION_FOLLOWLINKS support
  2012-08-24  4:50 ` [PATCH 01/18] fs: add " Jean-Christophe PLAGNIOL-VILLARD
                     ` (11 preceding siblings ...)
  2012-08-24  4:50   ` [PATCH 13/18] dirname: add -V option to return only path related to the mountpoint Jean-Christophe PLAGNIOL-VILLARD
@ 2012-08-24  4:50   ` Jean-Christophe PLAGNIOL-VILLARD
  2012-08-24  4:50   ` [PATCH 15/18] evnfs: introduce major and minor Jean-Christophe PLAGNIOL-VILLARD
                     ` (4 subsequent siblings)
  17 siblings, 0 replies; 38+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-08-24  4:50 UTC (permalink / raw)
  To: barebox

this is need to support symlink in envfs

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
 include/libbb.h        |    2 +-
 lib/recursive_action.c |    7 ++++++-
 scripts/bareboxenv.c   |    2 +-
 3 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/include/libbb.h b/include/libbb.h
index 110e8ec..47b2e08 100644
--- a/include/libbb.h
+++ b/include/libbb.h
@@ -14,7 +14,7 @@ char* last_char_is(const char *s, int c);
 
 enum {
 	ACTION_RECURSE     = (1 << 0),
-	/* ACTION_FOLLOWLINKS = (1 << 1), - unused */
+	ACTION_FOLLOWLINKS    = (1 << 1),
 	ACTION_DEPTHFIRST  = (1 << 2),
 	/*ACTION_REVERSE   = (1 << 3), - unused */
 };
diff --git a/lib/recursive_action.c b/lib/recursive_action.c
index 1ef758d..5bc2595 100644
--- a/lib/recursive_action.c
+++ b/lib/recursive_action.c
@@ -54,14 +54,19 @@ int recursive_action(const char *fileName,
 		const unsigned depth)
 {
 	struct stat statbuf;
+	unsigned follow;
 	int status;
 	DIR *dir;
 	struct dirent *next;
 
 	if (!fileAction) fileAction = true_action;
 	if (!dirAction) dirAction = true_action;
-	status = stat(fileName, &statbuf);
 
+	follow = ACTION_FOLLOWLINKS;
+	if (depth == 0)
+		follow = ACTION_FOLLOWLINKS;
+	follow &= flags;
+	status = (follow ? stat : lstat)(fileName, &statbuf);
 	if (status < 0) {
 #ifdef DEBUG_RECURS_ACTION
 		bb_error_msg("status=%d followLinks=%d TRUE=%d",
diff --git a/scripts/bareboxenv.c b/scripts/bareboxenv.c
index 866e345..f7f5351 100644
--- a/scripts/bareboxenv.c
+++ b/scripts/bareboxenv.c
@@ -73,7 +73,7 @@ char* last_char_is(const char *s, int c)
 
 enum {
 	ACTION_RECURSE     = (1 << 0),
-	/* ACTION_FOLLOWLINKS = (1 << 1), - unused */
+	ACTION_FOLLOWLINKS = (1 << 1),
 	ACTION_DEPTHFIRST  = (1 << 2),
 	/*ACTION_REVERSE   = (1 << 3), - unused */
 };
-- 
1.7.10.4


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

^ permalink raw reply	[flat|nested] 38+ messages in thread

* [PATCH 15/18] evnfs: introduce major and minor
  2012-08-24  4:50 ` [PATCH 01/18] fs: add " Jean-Christophe PLAGNIOL-VILLARD
                     ` (12 preceding siblings ...)
  2012-08-24  4:50   ` [PATCH 14/18] recursive_action: add ACTION_FOLLOWLINKS support Jean-Christophe PLAGNIOL-VILLARD
@ 2012-08-24  4:50   ` Jean-Christophe PLAGNIOL-VILLARD
  2012-08-27 14:12     ` Sascha Hauer
  2012-08-24  4:50   ` [PATCH 16/18] envfs: add support of variable inode size Jean-Christophe PLAGNIOL-VILLARD
                     ` (3 subsequent siblings)
  17 siblings, 1 reply; 38+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-08-24  4:50 UTC (permalink / raw)
  To: barebox

they are store in the super block at byte 16th and 17th.

set the verison at 0.1

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
 common/environment.c |    2 ++
 include/envfs.h      |    7 ++++++-
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/common/environment.c b/common/environment.c
index 52ce0de..257f35f 100644
--- a/common/environment.c
+++ b/common/environment.c
@@ -125,6 +125,8 @@ int envfs_save(char *filename, char *dirname)
 
 	super = (struct envfs_super *)buf;
 	super->magic = ENVFS_32(ENVFS_MAGIC);
+	super->major = ENVFS_32(ENVFS_MAJOR);
+	super->minor = ENVFS_32(ENVFS_MINOR);
 	super->size = ENVFS_32(size);
 
 	/* second pass: copy files to buffer */
diff --git a/include/envfs.h b/include/envfs.h
index ba976d6..c6df8c5 100644
--- a/include/envfs.h
+++ b/include/envfs.h
@@ -5,6 +5,9 @@
 #include <asm/byteorder.h>
 #endif
 
+#define ENVFS_MAJOR		0
+#define ENVFS_MINOR		1
+
 #define ENVFS_MAGIC		    0x798fba79	/* some random number */
 #define ENVFS_INODE_MAGIC	0x67a8c78d
 #define ENVFS_END_MAGIC		0x6a87d6cd
@@ -29,8 +32,10 @@ struct envfs_super {
 	uint32_t priority;
 	uint32_t crc;			/* crc for the data */
 	uint32_t size;			/* size of data */
+	uint8_t major;			/* major */
+	uint8_t minor;			/* minor */
+	uint16_t future;		/* reserved for future use */
 	uint32_t flags;			/* feature flags */
-	uint32_t future;		/* reserved for future use */
 	uint32_t sb_crc;		/* crc for the superblock */
 };
 
-- 
1.7.10.4


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

^ permalink raw reply	[flat|nested] 38+ messages in thread

* [PATCH 16/18] envfs: add support of variable inode size
  2012-08-24  4:50 ` [PATCH 01/18] fs: add " Jean-Christophe PLAGNIOL-VILLARD
                     ` (13 preceding siblings ...)
  2012-08-24  4:50   ` [PATCH 15/18] evnfs: introduce major and minor Jean-Christophe PLAGNIOL-VILLARD
@ 2012-08-24  4:50   ` Jean-Christophe PLAGNIOL-VILLARD
  2012-08-24  4:50   ` [PATCH 17/18] envfs: add support of symlink Jean-Christophe PLAGNIOL-VILLARD
                     ` (2 subsequent siblings)
  17 siblings, 0 replies; 38+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-08-24  4:50 UTC (permalink / raw)
  To: barebox

Introduce a struct envfs_inode_end with more data.
Today this will just containt the file mode to be able to add the symlink
support.

But this is compatible with the previous envfs version as they will do not
care about the extra as the previous version is just reading the filename and
then consume the extra data without using them.

Increase the envfs version to 1.0

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
 common/environment.c |   53 ++++++++++++++++++++++++++++++++++++++------------
 include/envfs.h      |   12 +++++++++---
 2 files changed, 50 insertions(+), 15 deletions(-)

diff --git a/common/environment.c b/common/environment.c
index 257f35f..7cdb83a 100644
--- a/common/environment.c
+++ b/common/environment.c
@@ -53,6 +53,7 @@ int file_size_action(const char *filename, struct stat *statbuf,
 
 	data->writep += sizeof(struct envfs_inode);
 	data->writep += PAD4(strlen(filename) + 1 - strlen(data->base));
+	data->writep += sizeof(struct envfs_inode_end);
 	data->writep += PAD4(statbuf->st_size);
 	return 1;
 }
@@ -62,6 +63,7 @@ int file_save_action(const char *filename, struct stat *statbuf,
 {
 	struct action_data *data = userdata;
 	struct envfs_inode *inode;
+	struct envfs_inode_end *inode_end;
 	int fd;
 	int namelen = strlen(filename) + 1 - strlen(data->base);
 
@@ -70,12 +72,16 @@ int file_save_action(const char *filename, struct stat *statbuf,
 
 	inode = (struct envfs_inode*)data->writep;
 	inode->magic = ENVFS_32(ENVFS_INODE_MAGIC);
-	inode->namelen = ENVFS_32(namelen);
+	inode->headerlen = ENVFS_32(PAD4(namelen + sizeof(struct envfs_inode_end)));
 	inode->size = ENVFS_32(statbuf->st_size);
 	data->writep += sizeof(struct envfs_inode);
 
 	strcpy(data->writep, filename + strlen(data->base));
 	data->writep += PAD4(namelen);
+	inode_end = (struct envfs_inode_end*)data->writep;
+	data->writep += sizeof(struct envfs_inode_end);
+	inode_end->magic = ENVFS_32(ENVFS_INODE_END_MAGIC);
+	inode_end->mode = ENVFS_32(S_IRWXU | S_IRWXG | S_IRWXO);
 
 	fd = open(filename, O_RDONLY);
 	if (fd < 0) {
@@ -176,8 +182,13 @@ int envfs_load(char *filename, char *dir)
 	int envfd;
 	int fd, ret = 0;
 	char *str, *tmp;
-	int namelen_full;
+	int headerlen_full;
 	unsigned long size;
+	/* for envfs < 1.0 */
+	struct envfs_inode_end inode_end_dummy;
+
+	inode_end_dummy.mode = ENVFS_32(S_IRWXU | S_IRWXG | S_IRWXO);
+	inode_end_dummy.magic = ENVFS_32(ENVFS_INODE_END_MAGIC);
 
 	envfd = open(filename, O_RDONLY);
 	if (envfd < 0) {
@@ -223,11 +234,18 @@ int envfs_load(char *filename, char *dir)
 		goto out;
 	}
 
+	if (ENVFS_32(super.major) < ENVFS_MAJOR)
+		printf("envfs version %d.%d loaded into %d.%d\n",
+			ENVFS_32(super.major), ENVFS_32(super.minor),
+			ENVFS_MAJOR, ENVFS_MINOR);
+
 	while (size) {
 		struct envfs_inode *inode;
-		uint32_t inode_size, inode_namelen;
+		struct envfs_inode_end *inode_end;
+		uint32_t inode_size, inode_headerlen, namelen;
 
 		inode = (struct envfs_inode *)buf;
+		buf += sizeof(struct envfs_inode);
 
 		if (ENVFS_32(inode->magic) != ENVFS_INODE_MAGIC) {
 			printf("envfs: wrong magic on %s\n", filename);
@@ -235,16 +253,30 @@ int envfs_load(char *filename, char *dir)
 			goto out;
 		}
 		inode_size = ENVFS_32(inode->size);
-		inode_namelen = ENVFS_32(inode->namelen);
+		inode_headerlen = ENVFS_32(inode->headerlen);
+		namelen = strlen(inode->data) + 1;
+		if (ENVFS_32(super.major) < 1)
+			inode_end = &inode_end_dummy;
+		else
+			inode_end = (struct envfs_inode_end *)(buf + PAD4(namelen));
 
-		debug("loading %s size %d namelen %d\n", inode->data,
-			inode_size, inode_namelen);
+		debug("loading %s size %d namelen %d headerlen %d\n", inode->data,
+			inode_size, namelen, inode_headerlen);
 
 		str = concat_path_file(dir, inode->data);
 		tmp = strdup(str);
 		make_directory(dirname(tmp));
 		free(tmp);
 
+		headerlen_full = PAD4(inode_headerlen);
+		buf += headerlen_full;
+
+		if (ENVFS_32(inode_end->magic) != ENVFS_INODE_END_MAGIC) {
+			printf("envfs: wrong inode_end_magic on %s\n", filename);
+			ret = -EIO;
+			goto out;
+		}
+
 		fd = open(str, O_WRONLY | O_CREAT | O_TRUNC, 0644);
 		free(str);
 		if (fd < 0) {
@@ -253,9 +285,7 @@ int envfs_load(char *filename, char *dir)
 			goto out;
 		}
 
-		namelen_full = PAD4(inode_namelen);
-		ret = write(fd, buf + namelen_full + sizeof(struct envfs_inode),
-				inode_size);
+		ret = write(fd, buf, inode_size);
 		if (ret < inode_size) {
 			perror("write");
 			ret = -errno;
@@ -264,9 +294,8 @@ int envfs_load(char *filename, char *dir)
 		}
 		close(fd);
 
-		buf += PAD4(inode_namelen) + PAD4(inode_size) +
-				sizeof(struct envfs_inode);
-		size -= PAD4(inode_namelen) + PAD4(inode_size) +
+		buf += PAD4(inode_size);
+		size -= headerlen_full + PAD4(inode_size) +
 				sizeof(struct envfs_inode);
 	}
 
diff --git a/include/envfs.h b/include/envfs.h
index c6df8c5..3d14fcb 100644
--- a/include/envfs.h
+++ b/include/envfs.h
@@ -5,18 +5,19 @@
 #include <asm/byteorder.h>
 #endif
 
-#define ENVFS_MAJOR		0
-#define ENVFS_MINOR		1
+#define ENVFS_MAJOR		1
+#define ENVFS_MINOR		0
 
 #define ENVFS_MAGIC		    0x798fba79	/* some random number */
 #define ENVFS_INODE_MAGIC	0x67a8c78d
+#define ENVFS_INODE_END_MAGIC	0x68a8c78d
 #define ENVFS_END_MAGIC		0x6a87d6cd
 #define ENVFS_SIGNATURE	"barebox envfs"
 
 struct envfs_inode {
 	uint32_t magic;	/* ENVFS_INODE_MAGIC */
 	uint32_t size;	/* data size in bytes  */
-	uint32_t namelen; /* The length of the filename _including_ a trailing 0 */
+	uint32_t headerlen; /* The length of the filename _including_ a trailing 0 */
 	char data[0];	/* The filename (zero terminated) + padding to 4 byte boundary
 			 * followed by the data for this inode.
 			 * The next inode follows after the data + padding to 4 byte
@@ -24,6 +25,11 @@ struct envfs_inode {
 			 */
 };
 
+struct envfs_inode_end {
+	uint32_t magic;	/* ENVFS_INODE_END_MAGIC */
+	uint32_t mode;	/* file mode */
+};
+
 /*
  * Superblock information at the beginning of the FS.
  */
-- 
1.7.10.4


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

^ permalink raw reply	[flat|nested] 38+ messages in thread

* [PATCH 17/18] envfs: add support of symlink
  2012-08-24  4:50 ` [PATCH 01/18] fs: add " Jean-Christophe PLAGNIOL-VILLARD
                     ` (14 preceding siblings ...)
  2012-08-24  4:50   ` [PATCH 16/18] envfs: add support of variable inode size Jean-Christophe PLAGNIOL-VILLARD
@ 2012-08-24  4:50   ` Jean-Christophe PLAGNIOL-VILLARD
  2012-08-24  4:50   ` [PATCH 18/18] defautenv: " Jean-Christophe PLAGNIOL-VILLARD
  2012-08-27 13:25   ` [PATCH 01/18] fs: add readlink support Sascha Hauer
  17 siblings, 0 replies; 38+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-08-24  4:50 UTC (permalink / raw)
  To: barebox

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
 common/environment.c |  103 +++++++++++++++++++++++++++++++++++---------------
 1 file changed, 73 insertions(+), 30 deletions(-)

diff --git a/common/environment.c b/common/environment.c
index 7cdb83a..5b9ed15 100644
--- a/common/environment.c
+++ b/common/environment.c
@@ -54,7 +54,20 @@ int file_size_action(const char *filename, struct stat *statbuf,
 	data->writep += sizeof(struct envfs_inode);
 	data->writep += PAD4(strlen(filename) + 1 - strlen(data->base));
 	data->writep += sizeof(struct envfs_inode_end);
-	data->writep += PAD4(statbuf->st_size);
+	if (S_ISLNK(statbuf->st_mode)) {
+		char path[PATH_MAX];
+
+		memset(path, 0, PATH_MAX);
+
+		if (readlink(filename, path, PATH_MAX) < 0) {
+			perror("read");
+			return 0;
+		}
+		data->writep += PAD4(strlen(path) + 1);
+	} else {
+		data->writep += PAD4(statbuf->st_size);
+	}
+
 	return 1;
 }
 
@@ -67,13 +80,9 @@ int file_save_action(const char *filename, struct stat *statbuf,
 	int fd;
 	int namelen = strlen(filename) + 1 - strlen(data->base);
 
-	debug("handling file %s size %ld namelen %d\n", filename + strlen(data->base),
-		statbuf->st_size, namelen);
-
 	inode = (struct envfs_inode*)data->writep;
 	inode->magic = ENVFS_32(ENVFS_INODE_MAGIC);
 	inode->headerlen = ENVFS_32(PAD4(namelen + sizeof(struct envfs_inode_end)));
-	inode->size = ENVFS_32(statbuf->st_size);
 	data->writep += sizeof(struct envfs_inode);
 
 	strcpy(data->writep, filename + strlen(data->base));
@@ -83,19 +92,44 @@ int file_save_action(const char *filename, struct stat *statbuf,
 	inode_end->magic = ENVFS_32(ENVFS_INODE_END_MAGIC);
 	inode_end->mode = ENVFS_32(S_IRWXU | S_IRWXG | S_IRWXO);
 
-	fd = open(filename, O_RDONLY);
-	if (fd < 0) {
-		printf("Open %s %s\n", filename, errno_str());
-		goto out;
-	}
+	if (S_ISLNK(statbuf->st_mode)) {
+		char path[PATH_MAX];
+		int len;
 
-	if (read(fd, data->writep, statbuf->st_size) < statbuf->st_size) {
-		perror("read");
-		goto out;
-	}
-	close(fd);
+		memset(path, 0, PATH_MAX);
+
+		if (readlink(filename, path, PATH_MAX) < 0) {
+			perror("read");
+			goto out;
+		}
+		len = strlen(path) + 1;
+
+		inode_end->mode |= ENVFS_32(S_IFLNK);
 
-	data->writep += PAD4(statbuf->st_size);
+		memcpy(data->writep, path, len);
+		inode->size = ENVFS_32(len);
+		data->writep += PAD4(len);
+		debug("handling symlink %s size %ld namelen %d headerlen %d\n", filename + strlen(data->base),
+			len, namelen, ENVFS_32(inode->headerlen));
+	} else {
+		debug("handling file %s size %ld namelen %d headerlen %d\n", filename + strlen(data->base),
+			statbuf->st_size, namelen, ENVFS_32(inode->headerlen));
+
+		inode->size = ENVFS_32(statbuf->st_size);
+		fd = open(filename, O_RDONLY);
+		if (fd < 0) {
+			printf("Open %s %s\n", filename, errno_str());
+			goto out;
+		}
+
+		if (read(fd, data->writep, statbuf->st_size) < statbuf->st_size) {
+			perror("read");
+			goto out;
+		}
+		close(fd);
+
+		data->writep += PAD4(statbuf->st_size);
+	}
 
 out:
 	return 1;
@@ -277,22 +311,31 @@ int envfs_load(char *filename, char *dir)
 			goto out;
 		}
 
-		fd = open(str, O_WRONLY | O_CREAT | O_TRUNC, 0644);
-		free(str);
-		if (fd < 0) {
-			printf("Open %s\n", errno_str());
-			ret = fd;
-			goto out;
-		}
-
-		ret = write(fd, buf, inode_size);
-		if (ret < inode_size) {
-			perror("write");
-			ret = -errno;
+		if (S_ISLNK(ENVFS_32(inode_end->mode))) {
+			debug("symlink: %s -> %s\n", str, (char*)buf);
+			if (symlink((char*)buf, str) < 0) {
+				printf("symlink: %s -> %s :", str, (char*)buf);
+				perror("");
+			}
+			free(str);
+		} else {
+			fd = open(str, O_WRONLY | O_CREAT | O_TRUNC, 0644);
+			free(str);
+			if (fd < 0) {
+				printf("Open %s\n", errno_str());
+				ret = fd;
+				goto out;
+			}
+
+			ret = write(fd, buf, inode_size);
+			if (ret < inode_size) {
+				perror("write");
+				ret = -errno;
+				close(fd);
+				goto out;
+			}
 			close(fd);
-			goto out;
 		}
-		close(fd);
 
 		buf += PAD4(inode_size);
 		size -= headerlen_full + PAD4(inode_size) +
-- 
1.7.10.4


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

^ permalink raw reply	[flat|nested] 38+ messages in thread

* [PATCH 18/18] defautenv: add support of symlink
  2012-08-24  4:50 ` [PATCH 01/18] fs: add " Jean-Christophe PLAGNIOL-VILLARD
                     ` (15 preceding siblings ...)
  2012-08-24  4:50   ` [PATCH 17/18] envfs: add support of symlink Jean-Christophe PLAGNIOL-VILLARD
@ 2012-08-24  4:50   ` Jean-Christophe PLAGNIOL-VILLARD
  2012-08-27 13:25   ` [PATCH 01/18] fs: add readlink support Sascha Hauer
  17 siblings, 0 replies; 38+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-08-24  4:50 UTC (permalink / raw)
  To: barebox

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
 common/Makefile |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/Makefile b/common/Makefile
index d74dffb..df9f301 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -58,7 +58,7 @@ ifneq ($(CONFIG_DEFAULT_ENVIRONMENT_PATH),"")
 DEFAULT_ENVIRONMENT_PATH += $(CONFIG_DEFAULT_ENVIRONMENT_PATH)
 endif
 
-ENV_FILES := $(shell cd $(srctree); for i in $(DEFAULT_ENVIRONMENT_PATH); do find $${i} -type f -exec readlink -f '{}' \;; done)
+ENV_FILES := $(shell cd $(srctree); for i in $(DEFAULT_ENVIRONMENT_PATH); do find $${i} -type f ; done)
 
 endif # ifdef CONFIG_DEFAULT_ENVIRONMENT
 
-- 
1.7.10.4


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

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH 04/18] fs: implement stat
  2012-08-24  4:50   ` [PATCH 04/18] fs: implement stat Jean-Christophe PLAGNIOL-VILLARD
@ 2012-08-24  9:25     ` Roberto Nibali
  2012-08-24 18:47       ` Jean-Christophe PLAGNIOL-VILLARD
  2012-08-27 13:52     ` Sascha Hauer
  1 sibling, 1 reply; 38+ messages in thread
From: Roberto Nibali @ 2012-08-24  9:25 UTC (permalink / raw)
  To: Jean-Christophe PLAGNIOL-VILLARD; +Cc: barebox

Hi

> diff --git a/fs/fs.c b/fs/fs.c
> index a19e1f4..9f2e82c 100644
> --- a/fs/fs.c
> +++ b/fs/fs.c
> @@ -26,6 +26,7 @@
>  #include <errno.h>
>  #include <malloc.h>
>  #include <linux/stat.h>
> +#include <linux/err.h>
>  #include <fcntl.h>
>  #include <xfuncs.h>
>  #include <init.h>
> @@ -111,6 +112,60 @@ static int init_cwd(void)
>
>  postcore_initcall(init_cwd);
>
> +char *normalise_link(const char *pathname, const char* symlink)
> +{
> +       const char *buf = symlink;
> +       char *path_free, *path;
> +       char *absolute_path;
> +       int point = 0;
> +       int dir = 1;
> +       int len;
> +
> +       if (symlink[0] == '/')
> +               return strdup(symlink);
> +
> +       path = path_free = strdup(pathname);
> +
> +       while (*buf == '.' || *buf == '/') {
> +               if (*buf == '.') {
> +                       point++;
> +               } else if (*buf == '/') {
> +                       point = 0;
> +                       dir++;
> +               }
> +               if (point > 2) {
> +                       buf -= 2;
> +                       break;
> +               }
> +               buf++;
> +       }
> +
> +       if (dir) {
> +               while(dir) {
> +                       path = dirname(path);
> +                       dir--;
> +               }
> +       }
> +
> +       len = strlen(buf) + strlen(path) + 1;
> +       if (buf[0] != '/')
> +               len++;
> +
> +       absolute_path = calloc(sizeof(char), len);
> +
> +       if(!absolute_path)
> +               return NULL;
> +
> +       strcat(absolute_path, path);
> +       if (buf[0] != '/')
> +               strcat(absolute_path, "/");
> +       strcat(absolute_path, buf);

Not that it matters hugely here, but how about strlcat(3) and checking
the return value?

Cheers
Roberto

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

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH 10/18] commands: add readlink support
  2012-08-24  4:50   ` [PATCH 10/18] commands: add readlink support Jean-Christophe PLAGNIOL-VILLARD
@ 2012-08-24  9:31     ` Roberto Nibali
  2012-08-24 18:46       ` Jean-Christophe PLAGNIOL-VILLARD
  0 siblings, 1 reply; 38+ messages in thread
From: Roberto Nibali @ 2012-08-24  9:31 UTC (permalink / raw)
  To: Jean-Christophe PLAGNIOL-VILLARD; +Cc: barebox

Hi Jean-Christophe

Btw, congrats on such a good and lean work on the symlink implementation!

> ---
>  commands/Kconfig    |    6 ++++
>  commands/Makefile   |    1 +
>  commands/readlink.c |   78 +++++++++++++++++++++++++++++++++++++++++++++++++++
>  3 files changed, 85 insertions(+)
>  create mode 100644 commands/readlink.c
>
> diff --git a/commands/Kconfig b/commands/Kconfig
> index 92a8152..876f2f8 100644
> --- a/commands/Kconfig
> +++ b/commands/Kconfig
> @@ -220,6 +220,12 @@ config CMD_DIRNAME
>           Strip last component of file name and store the result in a
>           environment variable
>
> +config CMD_READLINK
> +       tristate
> +       prompt "readlink"
> +       help
> +         read value of a symbolic link
> +

Just a general two cents comment: how about generally rephrasing the
"read value of a symbolic link" to "display file status of a symbolic
link"?

Cheers
Roberto

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

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH 10/18] commands: add readlink support
  2012-08-24  9:31     ` Roberto Nibali
@ 2012-08-24 18:46       ` Jean-Christophe PLAGNIOL-VILLARD
  0 siblings, 0 replies; 38+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-08-24 18:46 UTC (permalink / raw)
  To: Roberto Nibali; +Cc: barebox

On 11:31 Fri 24 Aug     , Roberto Nibali wrote:
> Hi Jean-Christophe
> 
> Btw, congrats on such a good and lean work on the symlink implementation!
> 
> > ---
> >  commands/Kconfig    |    6 ++++
> >  commands/Makefile   |    1 +
> >  commands/readlink.c |   78 +++++++++++++++++++++++++++++++++++++++++++++++++++
> >  3 files changed, 85 insertions(+)
> >  create mode 100644 commands/readlink.c
> >
> > diff --git a/commands/Kconfig b/commands/Kconfig
> > index 92a8152..876f2f8 100644
> > --- a/commands/Kconfig
> > +++ b/commands/Kconfig
> > @@ -220,6 +220,12 @@ config CMD_DIRNAME
> >           Strip last component of file name and store the result in a
> >           environment variable
> >
> > +config CMD_READLINK
> > +       tristate
> > +       prompt "readlink"
> > +       help
> > +         read value of a symbolic link
> > +
> 
> Just a general two cents comment: how about generally rephrasing the
> "read value of a symbolic link" to "display file status of a symbolic
> link"?
no barebox read the value and not display it

Best Regards,
J.

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

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH 04/18] fs: implement stat
  2012-08-24  9:25     ` Roberto Nibali
@ 2012-08-24 18:47       ` Jean-Christophe PLAGNIOL-VILLARD
  0 siblings, 0 replies; 38+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-08-24 18:47 UTC (permalink / raw)
  To: Roberto Nibali; +Cc: barebox

On 11:25 Fri 24 Aug     , Roberto Nibali wrote:
> Hi
> 
> > diff --git a/fs/fs.c b/fs/fs.c
> > index a19e1f4..9f2e82c 100644
> > --- a/fs/fs.c
> > +++ b/fs/fs.c
> > @@ -26,6 +26,7 @@
> >  #include <errno.h>
> >  #include <malloc.h>
> >  #include <linux/stat.h>
> > +#include <linux/err.h>
> >  #include <fcntl.h>
> >  #include <xfuncs.h>
> >  #include <init.h>
> > @@ -111,6 +112,60 @@ static int init_cwd(void)
> >
> >  postcore_initcall(init_cwd);
> >
> > +char *normalise_link(const char *pathname, const char* symlink)
> > +{
> > +       const char *buf = symlink;
> > +       char *path_free, *path;
> > +       char *absolute_path;
> > +       int point = 0;
> > +       int dir = 1;
> > +       int len;
> > +
> > +       if (symlink[0] == '/')
> > +               return strdup(symlink);
> > +
> > +       path = path_free = strdup(pathname);
> > +
> > +       while (*buf == '.' || *buf == '/') {
> > +               if (*buf == '.') {
> > +                       point++;
> > +               } else if (*buf == '/') {
> > +                       point = 0;
> > +                       dir++;
> > +               }
> > +               if (point > 2) {
> > +                       buf -= 2;
> > +                       break;
> > +               }
> > +               buf++;
> > +       }
> > +
> > +       if (dir) {
> > +               while(dir) {
> > +                       path = dirname(path);
> > +                       dir--;
> > +               }
> > +       }
> > +
> > +       len = strlen(buf) + strlen(path) + 1;
> > +       if (buf[0] != '/')
> > +               len++;
> > +
> > +       absolute_path = calloc(sizeof(char), len);
> > +
> > +       if(!absolute_path)
> > +               return NULL;
> > +
> > +       strcat(absolute_path, path);
> > +       if (buf[0] != '/')
> > +               strcat(absolute_path, "/");
> > +       strcat(absolute_path, buf);
> 
> Not that it matters hugely here, but how about strlcat(3) and checking
> the return value?

not need to check as we check it before
and strlcat does not exist on barebox

Best Regards,
J.

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

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH 01/18] fs: add readlink support
  2012-08-24  4:50 ` [PATCH 01/18] fs: add " Jean-Christophe PLAGNIOL-VILLARD
                     ` (16 preceding siblings ...)
  2012-08-24  4:50   ` [PATCH 18/18] defautenv: " Jean-Christophe PLAGNIOL-VILLARD
@ 2012-08-27 13:25   ` Sascha Hauer
  2012-09-01 10:50     ` Jean-Christophe PLAGNIOL-VILLARD
  17 siblings, 1 reply; 38+ messages in thread
From: Sascha Hauer @ 2012-08-27 13:25 UTC (permalink / raw)
  To: Jean-Christophe PLAGNIOL-VILLARD; +Cc: barebox

On Fri, Aug 24, 2012 at 06:50:01AM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
> Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
> ---
>  fs/fs.c      |   59 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  include/fs.h |    5 +++++
>  2 files changed, 64 insertions(+)
> 
> diff --git a/fs/fs.c b/fs/fs.c
> index 8ab1a3a..64a0d94 100644
> --- a/fs/fs.c
> +++ b/fs/fs.c
> @@ -890,6 +890,65 @@ int close(int fd)
>  }
>  EXPORT_SYMBOL(close);
>  
> +ssize_t readlink(const char *pathname, char *buf, size_t bufsiz)

man 2 readlink says:

> On  success,  readlink()  returns  the number of bytes placed in buf.
> On error, -1 is returned and errno is set to indicate the error.

This function instead returns 0 for success and a negative error value.
This is ok, but if the meaning of the return value is different, then it
does not make sense to try to match the function prototype with the libc
function.
Make the return type int.

> +{
> +	struct fs_driver_d *fsdrv;
> +	struct fs_device_d *fsdev;
> +	char *p = normalise_path(pathname);
> +	char *freep = p;
> +	int ret;
> +	size_t len = 0;
> +	char tmp[PATH_MAX];
> +
> +	tmp[0] = 0;
> +	buf[0] = 0;
> +
> +	ret = path_check_prereq(pathname, S_IFLNK);
> +	if (ret)
> +		goto out;
> +
> +	fsdev = get_fs_device_and_root_path(&p);
> +	if (!fsdev) {
> +		ret = -ENODEV;
> +		goto out;
> +	}
> +	fsdrv = fsdev->driver;
> +
> +	len = min(bufsiz, (size_t)PATH_MAX);
> +	if (fsdrv->readlink) {
> +		ret = fsdrv->readlink(&fsdev->dev, p, tmp, len);
> +	} else {
> +		ret = -EROFS;

EROFS is a strange error code here.

> +		goto out;

This is not needed

> +	}
> +
> +	if (ret)
> +		goto out;
> +
> +	if (tmp[0] == '/') {
> +		int l = strlen(fsdev->path);
> +
> +		if (fsdev->path[l - 1] == '/')
> +			l--;
> +
> +		if (l) {
> +			len -= l;
> +			strncat(buf, fsdev->path, l);
> +		}
> +	}

I don't understand why you manipulate the link target when the link target
is an absolute path. This means that if mount a fatfs to fat and put a
link there:

/fat/somelink -> /env/bla

Then readlink will return /fat/env/bla, which is not what you want.

Sascha


-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

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

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH 03/18] fs: add symlink support
  2012-08-24  4:50   ` [PATCH 03/18] fs: add symlink support Jean-Christophe PLAGNIOL-VILLARD
@ 2012-08-27 13:35     ` Sascha Hauer
  2012-09-01 10:42       ` Jean-Christophe PLAGNIOL-VILLARD
  0 siblings, 1 reply; 38+ messages in thread
From: Sascha Hauer @ 2012-08-27 13:35 UTC (permalink / raw)
  To: Jean-Christophe PLAGNIOL-VILLARD; +Cc: barebox

On Fri, Aug 24, 2012 at 06:50:03AM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
> Limit it's support to existing file only
> 
> Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
> ---
>  fs/fs.c      |   43 +++++++++++++++++++++++++++++++++++++++++++
>  include/fs.h |    4 ++++
>  2 files changed, 47 insertions(+)
> 
> diff --git a/fs/fs.c b/fs/fs.c
> index c950054..a19e1f4 100644
> --- a/fs/fs.c
> +++ b/fs/fs.c
> @@ -949,6 +949,49 @@ out:
>  }
>  EXPORT_SYMBOL(readlink);
>  
> +int symlink(const char *pathname, const char *newpath)
> +{
> +	struct fs_driver_d *fsdrv;
> +	struct fs_device_d *fsdev;
> +	char *p = normalise_path(pathname);
> +	int ret;
> +	struct stat s;
> +
> +	if (!stat(p, &s) && S_ISDIR(s.st_mode)) {
> +		ret = -ENOSYS;
> +		goto out;

You lose the memory allocated in normalise_path here.

> +	}
> +
> +	free(p);
> +	p = normalise_path(newpath);

p is never freed again.

> +
> +	ret = stat(p, &s);
> +	if (!ret) {
> +		ret = -EEXIST;
> +		goto out;
> +	}
> +
> +	fsdev = get_fs_device_and_root_path(&p);
> +	if (!fsdev) {
> +		ret = -ENODEV;
> +		goto out;
> +	}
> +	fsdrv = fsdev->driver;
> +
> +	if (fsdrv->symlink) {
> +		ret = fsdrv->symlink(&fsdev->dev, pathname, p);
> +	} else {
> +		ret = -EROFS;

Better:

EPERM  The file system containing newpath does not support the creation of symbolic links.

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

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

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH 04/18] fs: implement stat
  2012-08-24  4:50   ` [PATCH 04/18] fs: implement stat Jean-Christophe PLAGNIOL-VILLARD
  2012-08-24  9:25     ` Roberto Nibali
@ 2012-08-27 13:52     ` Sascha Hauer
  2012-09-01 10:39       ` Jean-Christophe PLAGNIOL-VILLARD
  1 sibling, 1 reply; 38+ messages in thread
From: Sascha Hauer @ 2012-08-27 13:52 UTC (permalink / raw)
  To: Jean-Christophe PLAGNIOL-VILLARD; +Cc: barebox

On Fri, Aug 24, 2012 at 06:50:04AM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
> stat() stats the file pointed to by path and fills in buf.
> 
> Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
> ---
>  fs/fs.c      |  102 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  include/fs.h |    6 ++--
>  2 files changed, 104 insertions(+), 4 deletions(-)
> 
> diff --git a/fs/fs.c b/fs/fs.c
> index a19e1f4..9f2e82c 100644
> --- a/fs/fs.c
> +++ b/fs/fs.c
> @@ -26,6 +26,7 @@
>  #include <errno.h>
>  #include <malloc.h>
>  #include <linux/stat.h>
> +#include <linux/err.h>
>  #include <fcntl.h>
>  #include <xfuncs.h>
>  #include <init.h>
> @@ -111,6 +112,60 @@ static int init_cwd(void)
>  
>  postcore_initcall(init_cwd);
>  
> +char *normalise_link(const char *pathname, const char* symlink)

like this instead: const char *symlink

> +{
> +	const char *buf = symlink;
> +	char *path_free, *path;
> +	char *absolute_path;
> +	int point = 0;
> +	int dir = 1;
> +	int len;
> +
> +	if (symlink[0] == '/')
> +		return strdup(symlink);
> +
> +	path = path_free = strdup(pathname);
> +
> +	while (*buf == '.' || *buf == '/') {
> +		if (*buf == '.') {
> +			point++;
> +		} else if (*buf == '/') {
> +			point = 0;
> +			dir++;
> +		}
> +		if (point > 2) {
> +			buf -= 2;
> +			break;
> +		}
> +		buf++;
> +	}
> +
> +	if (dir) {

This is always true. Even if not, this would be covered by while (dir)
below.

> +		while(dir) {
> +			path = dirname(path);
> +			dir--;
> +		}
> +	}
> +
> +	len = strlen(buf) + strlen(path) + 1;
> +	if (buf[0] != '/')
> +		len++;
> +
> +	absolute_path = calloc(sizeof(char), len);
> +
> +	if(!absolute_path)

if (

> +		return NULL;
> +
> +	strcat(absolute_path, path);
> +	if (buf[0] != '/')
> +		strcat(absolute_path, "/");
> +	strcat(absolute_path, buf);
> +
> +	free(path_free);
> +
> +	return absolute_path;
> +}
> +
>  char *normalise_path(const char *pathname)
>  {
>  	char *path = xzalloc(strlen(pathname) + strlen(cwd) + 2);
> @@ -512,6 +567,40 @@ out:
>  }
>  EXPORT_SYMBOL(unlink);
>  
> +static char* realfile(const char *pathname, struct stat *s)

static char *realfile

> +{
> +	char *path = normalise_path(pathname);
> +	int ret;
> +
> +	ret = lstat(path, s);
> +	if (ret)
> +		goto out;
> +
> +	if (S_ISLNK(s->st_mode)) {
> +		char tmp[PATH_MAX];
> +		char *new_path;
> +
> +		ret = readlink(path, tmp, PATH_MAX);
> +		if (ret < 0)
> +			goto out;
> +
> +		new_path = normalise_link(path, tmp);
> +		free(path);
> +		if (!new_path)
> +			return ERR_PTR(-ENOMEM);
> +		path = new_path;
> +
> +		ret = lstat(path, s);
> +	}

I see no code handling multiple link levels. I think this should be
here?

Sascha


-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

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

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH 06/18] fs: introduce get_mounted_path to get the path where a file is mounted
  2012-08-24  4:50   ` [PATCH 06/18] fs: introduce get_mounted_path to get the path where a file is mounted Jean-Christophe PLAGNIOL-VILLARD
@ 2012-08-27 13:53     ` Sascha Hauer
  2012-09-01 10:37       ` Jean-Christophe PLAGNIOL-VILLARD
  0 siblings, 1 reply; 38+ messages in thread
From: Sascha Hauer @ 2012-08-27 13:53 UTC (permalink / raw)
  To: Jean-Christophe PLAGNIOL-VILLARD; +Cc: barebox

On Fri, Aug 24, 2012 at 06:50:06AM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
> Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
> ---
>  fs/fs.c      |    9 +++++++++
>  include/fs.h |    2 ++
>  2 files changed, 11 insertions(+)
> 
> diff --git a/fs/fs.c b/fs/fs.c
> index ca6340c..8ec368c 100644
> --- a/fs/fs.c
> +++ b/fs/fs.c
> @@ -242,6 +242,15 @@ static struct fs_device_d *get_fsdevice_by_path(const char *path)
>  	return fs_dev_root;
>  }
>  
> +char* get_mounted_path(const char *path)

char *get_mounted_path

> +{
> +	struct fs_device_d *fdev;
> +
> +	fdev = get_fsdevice_by_path(path);
> +
> +	return fdev->path;
> +}
> +
>  static FILE files[MAX_FILES];
>  
>  static FILE *get_file(void)
> diff --git a/include/fs.h b/include/fs.h
> index 263823a..19b4418 100644
> --- a/include/fs.h
> +++ b/include/fs.h
> @@ -174,6 +174,8 @@ void *read_file(const char *filename, size_t *size);
>  char *normalise_path(const char *path);
>  char *normalise_link(const char *pathname, const char* symlink);
>  
> +char* get_mounted_path(const char *path);

char *get_mounted_path

> +
>  /* Register a new filesystem driver */
>  int register_fs_driver(struct fs_driver_d *fsdrv);
>  
> -- 
> 1.7.10.4
> 
> 
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

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

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH 07/18] ramfs: add symlink and readlink support
  2012-08-24  4:50   ` [PATCH 07/18] ramfs: add symlink and readlink support Jean-Christophe PLAGNIOL-VILLARD
@ 2012-08-27 13:59     ` Sascha Hauer
  2012-08-29  5:21       ` Jean-Christophe PLAGNIOL-VILLARD
  0 siblings, 1 reply; 38+ messages in thread
From: Sascha Hauer @ 2012-08-27 13:59 UTC (permalink / raw)
  To: Jean-Christophe PLAGNIOL-VILLARD; +Cc: barebox

On Fri, Aug 24, 2012 at 06:50:07AM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
> Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
> ---
>  fs/ramfs.c |   53 ++++++++++++++++++++++++++++++++++++++++++++++-------
>  1 file changed, 46 insertions(+), 7 deletions(-)
> 
> diff --git a/fs/ramfs.c b/fs/ramfs.c
> index 91d06b8..38da593 100644
> --- a/fs/ramfs.c
> +++ b/fs/ramfs.c
> @@ -42,6 +42,7 @@ struct ramfs_inode {
>  	struct ramfs_inode *parent;
>  	struct ramfs_inode *next;
>  	struct ramfs_inode *child;
> +	char *symlink;
>  	ulong mode;
>  
>  	struct handle_d *handle;
> @@ -176,6 +177,7 @@ static void ramfs_put_inode(struct ramfs_inode *node)
>  		data = tmp;
>  	}
>  
> +	free(node->symlink);
>  	free(node->name);
>  	free(node);
>  }
> @@ -212,18 +214,28 @@ static struct ramfs_inode* node_insert(struct ramfs_inode *parent_node, const ch
>  
>  /* ---------------------------------------------------------------*/
>  
> -static int ramfs_create(struct device_d *dev, const char *pathname, mode_t mode)
> +static int __ramfs_create(struct device_d *dev, const char *pathname,
> +			  mode_t mode, const char *symlink)
>  {
>  	struct ramfs_priv *priv = dev->priv;
>  	struct ramfs_inode *node;
>  	char *file;
>  
>  	node = rlookup_parent(priv, pathname, &file);
> -	if (node) {
> -		node_insert(node, file, mode);
> -		return 0;
> -	}
> -	return -ENOENT;
> +	if (!node)
> +		return -ENOENT;
> +
> +	node = node_insert(node, file, mode);
> +	if (!node)
> +		return -ENOMEM;
> +	node->symlink = strdup(symlink);

Either check for errors or use xstrdup.

> +
> +	return 0;
> +}
> +
> +static int ramfs_create(struct device_d *dev, const char *pathname, mode_t mode)
> +{
> +	return __ramfs_create(dev, pathname, mode, NULL);
>  }
>  
>  static int ramfs_unlink(struct device_d *dev, const char *pathname)
> @@ -532,12 +544,37 @@ static int ramfs_stat(struct device_d *dev, const char *filename, struct stat *s
>  	if (!node)
>  		return -ENOENT;
>  
> -	s->st_size = node->size;
> +	s->st_size = node->symlink ? strlen(node->symlink) : node->size;
>  	s->st_mode = node->mode;
>  
>  	return 0;
>  }
>  
> +static int ramfs_symlink(struct device_d *dev, const char *pathname,
> +		       const char *newpath)
> +{
> +	mode_t mode = S_IFLNK | S_IRWXU | S_IRWXG | S_IRWXO;
> +
> +	return __ramfs_create(dev, newpath, mode, pathname);
> +}
> +
> +static int ramfs_readlink(struct device_d *dev, const char *pathname,
> +			char *buf, size_t bufsiz)
> +{
> +	struct ramfs_priv *priv = dev->priv;
> +	struct ramfs_inode *node = rlookup(priv, pathname);
> +	int len;
> +
> +	if (!node || !node->symlink)
> +		return -ENOENT;
> +
> +	len = min(bufsiz, strlen(node->symlink));
> +
> +	strncat(buf, node->symlink, len);

You append to buf? What do you expect to be in there? I think memcpy
would be more appropriate here.

I see no code freeing node->symlink in this patch.

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

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

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH 08/18] nfs: add readlink support
  2012-08-24  4:50   ` [PATCH 08/18] nfs: add " Jean-Christophe PLAGNIOL-VILLARD
@ 2012-08-27 14:04     ` Sascha Hauer
  0 siblings, 0 replies; 38+ messages in thread
From: Sascha Hauer @ 2012-08-27 14:04 UTC (permalink / raw)
  To: Jean-Christophe PLAGNIOL-VILLARD; +Cc: barebox

On Fri, Aug 24, 2012 at 06:50:08AM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
> Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
> ---
>  fs/nfs.c |   93 +++++++++++++++++++++++++++++++++++++++++++-------------------
>  1 file changed, 65 insertions(+), 28 deletions(-)
> 
> diff --git a/fs/nfs.c b/fs/nfs.c
> index 79e667f..a4e1f91 100644
> --- a/fs/nfs.c
> +++ b/fs/nfs.c
> @@ -605,34 +605,6 @@ static int nfs_read_req(struct file_priv *priv, int offset, int readlen)
>  	return 0;
>  }
>  
> @@ -742,6 +714,70 @@ static struct file_priv *nfs_do_stat(struct device_d *dev, const char *filename,
>  	return priv;
>  }
>  
> +static int nfs_readlink_req(struct file_priv *priv, char* buf, size_t size)
> +{
> +	uint32_t data[1024];
> +	uint32_t *p;
> +	int len;
> +	int ret;
> +	char *path;
> +	uint32_t *filedata;
> +
> +	p = &(data[0]);
> +	p = rpc_add_credentials(p);
> +
> +	memcpy(p, priv->filefh, NFS_FHSIZE);
> +	p += (NFS_FHSIZE / 4);
> +
> +	len = p - &(data[0]);
> +
> +	ret = rpc_req(priv->npriv, PROG_NFS, NFS_READLINK, data, len);
> +	if (ret)
> +		return ret;
> +
> +	filedata = nfs_packet + sizeof(struct rpc_reply);
> +	filedata++;
> +
> +	len = ntohl(net_read_uint32(filedata)); /* new path length */
> +	filedata++;
> +
> +	path = (char *)filedata;
> +
> +	if (len > size)
> +		len = size;
> +
> +	memcpy(buf, path, len);
> +	buf[len] = 0;

You write past the buffer here.

> +
> +	return 0;
> +}
> +
> +static int nfs_readlink(struct device_d *dev, const char *filename,
> +			char *realname, size_t size)
> +{
> +	struct file_priv *priv;
> +	int ret;
> +	struct stat s;
> +
> +	priv = nfs_do_stat(dev, filename, &s);
> +	if (IS_ERR(priv))
> +		return PTR_ERR(priv);
> +
> +

unnecessary blank line.

> +	if (S_ISDIR(s.st_mode))
> +		strcat(realname, filename);
> +	else
> +		strcat(realname, dirname((char*)filename));

What do you expect to be in realname?

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

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

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH 15/18] evnfs: introduce major and minor
  2012-08-24  4:50   ` [PATCH 15/18] evnfs: introduce major and minor Jean-Christophe PLAGNIOL-VILLARD
@ 2012-08-27 14:12     ` Sascha Hauer
  2012-08-29  5:23       ` Jean-Christophe PLAGNIOL-VILLARD
  0 siblings, 1 reply; 38+ messages in thread
From: Sascha Hauer @ 2012-08-27 14:12 UTC (permalink / raw)
  To: Jean-Christophe PLAGNIOL-VILLARD; +Cc: barebox

On Fri, Aug 24, 2012 at 06:50:15AM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
> they are store in the super block at byte 16th and 17th.
> 
> set the verison at 0.1

Only this little comment makes clear that with major and minor you mean
a version. I first thought about device nodes...

> 
> Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
> ---
>  common/environment.c |    2 ++
>  include/envfs.h      |    7 ++++++-
>  2 files changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/common/environment.c b/common/environment.c
> index 52ce0de..257f35f 100644
> --- a/common/environment.c
> +++ b/common/environment.c
> @@ -125,6 +125,8 @@ int envfs_save(char *filename, char *dirname)
>  
>  	super = (struct envfs_super *)buf;
>  	super->magic = ENVFS_32(ENVFS_MAGIC);
> +	super->major = ENVFS_32(ENVFS_MAJOR);
> +	super->minor = ENVFS_32(ENVFS_MINOR);

major and minor are 8bit wide but you read 32?

>  	super->size = ENVFS_32(size);
>  
>  	/* second pass: copy files to buffer */
> diff --git a/include/envfs.h b/include/envfs.h
> index ba976d6..c6df8c5 100644
> --- a/include/envfs.h
> +++ b/include/envfs.h
> @@ -5,6 +5,9 @@
>  #include <asm/byteorder.h>
>  #endif
>  
> +#define ENVFS_MAJOR		0
> +#define ENVFS_MINOR		1
> +
>  #define ENVFS_MAGIC		    0x798fba79	/* some random number */
>  #define ENVFS_INODE_MAGIC	0x67a8c78d
>  #define ENVFS_END_MAGIC		0x6a87d6cd
> @@ -29,8 +32,10 @@ struct envfs_super {
>  	uint32_t priority;
>  	uint32_t crc;			/* crc for the data */
>  	uint32_t size;			/* size of data */
> +	uint8_t major;			/* major */
> +	uint8_t minor;			/* minor */
> +	uint16_t future;		/* reserved for future use */
>  	uint32_t flags;			/* feature flags */
> -	uint32_t future;		/* reserved for future use */

Why do you move the position of the flags field in envfs_super?

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

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

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH 07/18] ramfs: add symlink and readlink support
  2012-08-27 13:59     ` Sascha Hauer
@ 2012-08-29  5:21       ` Jean-Christophe PLAGNIOL-VILLARD
  0 siblings, 0 replies; 38+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-08-29  5:21 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: barebox

On 15:59 Mon 27 Aug     , Sascha Hauer wrote:
> On Fri, Aug 24, 2012 at 06:50:07AM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
> > ---
> >  fs/ramfs.c |   53 ++++++++++++++++++++++++++++++++++++++++++++++-------
> >  1 file changed, 46 insertions(+), 7 deletions(-)
> > 
> > diff --git a/fs/ramfs.c b/fs/ramfs.c
> > index 91d06b8..38da593 100644
> > --- a/fs/ramfs.c
> > +++ b/fs/ramfs.c
> > @@ -42,6 +42,7 @@ struct ramfs_inode {
> >  	struct ramfs_inode *parent;
> >  	struct ramfs_inode *next;
> >  	struct ramfs_inode *child;
> > +	char *symlink;
> >  	ulong mode;
> >  
> >  	struct handle_d *handle;
> > @@ -176,6 +177,7 @@ static void ramfs_put_inode(struct ramfs_inode *node)
> >  		data = tmp;
> >  	}
> >  
> > +	free(node->symlink);
free here
> >  	free(node->name);
> >  	free(node);
> >  }
> > @@ -212,18 +214,28 @@ static struct ramfs_inode* node_insert(struct ramfs_inode *parent_node, const ch
> >  
> >  /* ---------------------------------------------------------------*/
> >  
> > -static int ramfs_create(struct device_d *dev, const char *pathname, mode_t mode)
> > +static int __ramfs_create(struct device_d *dev, const char *pathname,
> > +			  mode_t mode, const char *symlink)
> >  {
> >  	struct ramfs_priv *priv = dev->priv;
> >  	struct ramfs_inode *node;
> >  	char *file;
> >  
> >  	node = rlookup_parent(priv, pathname, &file);
> > -	if (node) {
> > -		node_insert(node, file, mode);
> > -		return 0;
> > -	}
> > -	return -ENOENT;
> > +	if (!node)
> > +		return -ENOENT;
> > +
> > +	node = node_insert(node, file, mode);
> > +	if (!node)
> > +		return -ENOMEM;
> > +	node->symlink = strdup(symlink);
> 
> Either check for errors or use xstrdup.
no I do not want to use x... stuff on ramfs
it need to work evenof no memory
> 
> > +
> > +	return 0;
> > +}
> > +
> > +static int ramfs_create(struct device_d *dev, const char *pathname, mode_t mode)
> > +{
> > +	return __ramfs_create(dev, pathname, mode, NULL);
> >  }
> >  
> >  static int ramfs_unlink(struct device_d *dev, const char *pathname)
> > @@ -532,12 +544,37 @@ static int ramfs_stat(struct device_d *dev, const char *filename, struct stat *s
> >  	if (!node)
> >  		return -ENOENT;
> >  
> > -	s->st_size = node->size;
> > +	s->st_size = node->symlink ? strlen(node->symlink) : node->size;
> >  	s->st_mode = node->mode;
> >  
> >  	return 0;
> >  }
> >  
> > +static int ramfs_symlink(struct device_d *dev, const char *pathname,
> > +		       const char *newpath)
> > +{
> > +	mode_t mode = S_IFLNK | S_IRWXU | S_IRWXG | S_IRWXO;
> > +
> > +	return __ramfs_create(dev, newpath, mode, pathname);
> > +}
> > +
> > +static int ramfs_readlink(struct device_d *dev, const char *pathname,
> > +			char *buf, size_t bufsiz)
> > +{
> > +	struct ramfs_priv *priv = dev->priv;
> > +	struct ramfs_inode *node = rlookup(priv, pathname);
> > +	int len;
> > +
> > +	if (!node || !node->symlink)
> > +		return -ENOENT;
> > +
> > +	len = min(bufsiz, strlen(node->symlink));
> > +
> > +	strncat(buf, node->symlink, len);
> 
> You append to buf? What do you expect to be in there? I think memcpy
> would be more appropriate here.
yeap we can use memcpy
> 
> I see no code freeing node->symlink in this patch.
upper

Best Regards,
J.
> 
> Sascha
> 
> -- 
> Pengutronix e.K.                           |                             |
> Industrial Linux Solutions                 | http://www.pengutronix.de/  |
> Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
> Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

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

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH 15/18] evnfs: introduce major and minor
  2012-08-27 14:12     ` Sascha Hauer
@ 2012-08-29  5:23       ` Jean-Christophe PLAGNIOL-VILLARD
  0 siblings, 0 replies; 38+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-08-29  5:23 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: barebox

On 16:12 Mon 27 Aug     , Sascha Hauer wrote:
> On Fri, Aug 24, 2012 at 06:50:15AM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > they are store in the super block at byte 16th and 17th.
> > 
> > set the verison at 0.1
> 
> Only this little comment makes clear that with major and minor you mean
> a version. I first thought about device nodes...
> 
> > 
> > Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
> > ---
> >  common/environment.c |    2 ++
> >  include/envfs.h      |    7 ++++++-
> >  2 files changed, 8 insertions(+), 1 deletion(-)
> > 
> > diff --git a/common/environment.c b/common/environment.c
> > index 52ce0de..257f35f 100644
> > --- a/common/environment.c
> > +++ b/common/environment.c
> > @@ -125,6 +125,8 @@ int envfs_save(char *filename, char *dirname)
> >  
> >  	super = (struct envfs_super *)buf;
> >  	super->magic = ENVFS_32(ENVFS_MAGIC);
> > +	super->major = ENVFS_32(ENVFS_MAJOR);
> > +	super->minor = ENVFS_32(ENVFS_MINOR);
> 
> major and minor are 8bit wide but you read 32?
yep
> 
> >  	super->size = ENVFS_32(size);
> >  
> >  	/* second pass: copy files to buffer */
> > diff --git a/include/envfs.h b/include/envfs.h
> > index ba976d6..c6df8c5 100644
> > --- a/include/envfs.h
> > +++ b/include/envfs.h
> > @@ -5,6 +5,9 @@
> >  #include <asm/byteorder.h>
> >  #endif
> >  
> > +#define ENVFS_MAJOR		0
> > +#define ENVFS_MINOR		1
> > +
> >  #define ENVFS_MAGIC		    0x798fba79	/* some random number */
> >  #define ENVFS_INODE_MAGIC	0x67a8c78d
> >  #define ENVFS_END_MAGIC		0x6a87d6cd
> > @@ -29,8 +32,10 @@ struct envfs_super {
> >  	uint32_t priority;
> >  	uint32_t crc;			/* crc for the data */
> >  	uint32_t size;			/* size of data */
> > +	uint8_t major;			/* major */
> > +	uint8_t minor;			/* minor */
> > +	uint16_t future;		/* reserved for future use */
> >  	uint32_t flags;			/* feature flags */
> > -	uint32_t future;		/* reserved for future use */
> 
> Why do you move the position of the flags field in envfs_super?
keep all non-use data together flags not used too

Best Regards,
J.

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

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH 06/18] fs: introduce get_mounted_path to get the path where a file is mounted
  2012-08-27 13:53     ` Sascha Hauer
@ 2012-09-01 10:37       ` Jean-Christophe PLAGNIOL-VILLARD
  0 siblings, 0 replies; 38+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-09-01 10:37 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: barebox

On 15:53 Mon 27 Aug     , Sascha Hauer wrote:
> On Fri, Aug 24, 2012 at 06:50:06AM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
> > ---
> >  fs/fs.c      |    9 +++++++++
> >  include/fs.h |    2 ++
> >  2 files changed, 11 insertions(+)
> > 
> > diff --git a/fs/fs.c b/fs/fs.c
> > index ca6340c..8ec368c 100644
> > --- a/fs/fs.c
> > +++ b/fs/fs.c
> > @@ -242,6 +242,15 @@ static struct fs_device_d *get_fsdevice_by_path(const char *path)
> >  	return fs_dev_root;
> >  }
> >  
> > +char* get_mounted_path(const char *path)
> 
> char *get_mounted_path
yeap

Best Regards,
J.

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

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH 04/18] fs: implement stat
  2012-08-27 13:52     ` Sascha Hauer
@ 2012-09-01 10:39       ` Jean-Christophe PLAGNIOL-VILLARD
  0 siblings, 0 replies; 38+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-09-01 10:39 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: barebox

On 15:52 Mon 27 Aug     , Sascha Hauer wrote:
> On Fri, Aug 24, 2012 at 06:50:04AM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > stat() stats the file pointed to by path and fills in buf.
> > 
> > Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
> > ---
> >  fs/fs.c      |  102 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> >  include/fs.h |    6 ++--
> >  2 files changed, 104 insertions(+), 4 deletions(-)
> > 
> > diff --git a/fs/fs.c b/fs/fs.c
> > index a19e1f4..9f2e82c 100644
> > --- a/fs/fs.c
> > +++ b/fs/fs.c
> > @@ -26,6 +26,7 @@
> >  #include <errno.h>
> >  #include <malloc.h>
> >  #include <linux/stat.h>
> > +#include <linux/err.h>
> >  #include <fcntl.h>
> >  #include <xfuncs.h>
> >  #include <init.h>
> > @@ -111,6 +112,60 @@ static int init_cwd(void)
> >  
> >  postcore_initcall(init_cwd);
> >  
> > +char *normalise_link(const char *pathname, const char* symlink)
> 
> like this instead: const char *symlink
> 
> > +{
> > +	const char *buf = symlink;
> > +	char *path_free, *path;
> > +	char *absolute_path;
> > +	int point = 0;
> > +	int dir = 1;
> > +	int len;
> > +
> > +	if (symlink[0] == '/')
> > +		return strdup(symlink);
> > +
> > +	path = path_free = strdup(pathname);
> > +
> > +	while (*buf == '.' || *buf == '/') {
> > +		if (*buf == '.') {
> > +			point++;
> > +		} else if (*buf == '/') {
> > +			point = 0;
> > +			dir++;
> > +		}
> > +		if (point > 2) {
> > +			buf -= 2;
> > +			break;
> > +		}
> > +		buf++;
> > +	}
> > +
> > +	if (dir) {
> 
> This is always true. Even if not, this would be covered by while (dir)
> below.
> 
> > +		while(dir) {
> > +			path = dirname(path);
> > +			dir--;
> > +		}
> > +	}
> > +
> > +	len = strlen(buf) + strlen(path) + 1;
> > +	if (buf[0] != '/')
> > +		len++;
> > +
> > +	absolute_path = calloc(sizeof(char), len);
> > +
> > +	if(!absolute_path)
> 
> if (
> 
> > +		return NULL;
> > +
> > +	strcat(absolute_path, path);
> > +	if (buf[0] != '/')
> > +		strcat(absolute_path, "/");
> > +	strcat(absolute_path, buf);
> > +
> > +	free(path_free);
> > +
> > +	return absolute_path;
> > +}
> > +
> >  char *normalise_path(const char *pathname)
> >  {
> >  	char *path = xzalloc(strlen(pathname) + strlen(cwd) + 2);
> > @@ -512,6 +567,40 @@ out:
> >  }
> >  EXPORT_SYMBOL(unlink);
> >  
> > +static char* realfile(const char *pathname, struct stat *s)
> 
> static char *realfile
> 
> > +{
> > +	char *path = normalise_path(pathname);
> > +	int ret;
> > +
> > +	ret = lstat(path, s);
> > +	if (ret)
> > +		goto out;
> > +
> > +	if (S_ISLNK(s->st_mode)) {
> > +		char tmp[PATH_MAX];
> > +		char *new_path;
> > +
> > +		ret = readlink(path, tmp, PATH_MAX);
> > +		if (ret < 0)
> > +			goto out;
> > +
> > +		new_path = normalise_link(path, tmp);
> > +		free(path);
> > +		if (!new_path)
> > +			return ERR_PTR(-ENOMEM);
> > +		path = new_path;
> > +
> > +		ret = lstat(path, s);
> > +	}
> 
> I see no code handling multiple link levels. I think this should be
> here?
yeap I did not add it so far I plan to add it in a second step if we need it
so far I'm not really sure

Best Regards,
J.

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

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH 03/18] fs: add symlink support
  2012-08-27 13:35     ` Sascha Hauer
@ 2012-09-01 10:42       ` Jean-Christophe PLAGNIOL-VILLARD
  0 siblings, 0 replies; 38+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-09-01 10:42 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: barebox

On 15:35 Mon 27 Aug     , Sascha Hauer wrote:
> On Fri, Aug 24, 2012 at 06:50:03AM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > Limit it's support to existing file only
> > 
> > Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
> > ---
> >  fs/fs.c      |   43 +++++++++++++++++++++++++++++++++++++++++++
> >  include/fs.h |    4 ++++
> >  2 files changed, 47 insertions(+)
> > 
> > diff --git a/fs/fs.c b/fs/fs.c
> > index c950054..a19e1f4 100644
> > --- a/fs/fs.c
> > +++ b/fs/fs.c
> > @@ -949,6 +949,49 @@ out:
> >  }
> >  EXPORT_SYMBOL(readlink);
> >  
> > +int symlink(const char *pathname, const char *newpath)
> > +{
> > +	struct fs_driver_d *fsdrv;
> > +	struct fs_device_d *fsdev;
> > +	char *p = normalise_path(pathname);
> > +	int ret;
> > +	struct stat s;
> > +
> > +	if (!stat(p, &s) && S_ISDIR(s.st_mode)) {
> > +		ret = -ENOSYS;
> > +		goto out;
> 
> You lose the memory allocated in normalise_path here.
yeap forget to put the free in out
> 
> > +	}
> > +
> > +	free(p);
> > +	p = normalise_path(newpath);
> 
> p is never freed again.
> 
> > +
> > +	ret = stat(p, &s);
> > +	if (!ret) {
> > +		ret = -EEXIST;
> > +		goto out;
> > +	}
> > +
> > +	fsdev = get_fs_device_and_root_path(&p);
> > +	if (!fsdev) {
> > +		ret = -ENODEV;
> > +		goto out;
> > +	}
> > +	fsdrv = fsdev->driver;
> > +
> > +	if (fsdrv->symlink) {
> > +		ret = fsdrv->symlink(&fsdev->dev, pathname, p);
> > +	} else {
> > +		ret = -EROFS;
> 
> Better:
> 
> EPERM  The file system containing newpath does not support the creation of symbolic links.
ok

Best Regards,
J.

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

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH 01/18] fs: add readlink support
  2012-08-27 13:25   ` [PATCH 01/18] fs: add readlink support Sascha Hauer
@ 2012-09-01 10:50     ` Jean-Christophe PLAGNIOL-VILLARD
  0 siblings, 0 replies; 38+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-09-01 10:50 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: barebox

On 15:25 Mon 27 Aug     , Sascha Hauer wrote:
> On Fri, Aug 24, 2012 at 06:50:01AM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
> > ---
> >  fs/fs.c      |   59 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> >  include/fs.h |    5 +++++
> >  2 files changed, 64 insertions(+)
> > 
> > diff --git a/fs/fs.c b/fs/fs.c
> > index 8ab1a3a..64a0d94 100644
> > --- a/fs/fs.c
> > +++ b/fs/fs.c
> > @@ -890,6 +890,65 @@ int close(int fd)
> >  }
> >  EXPORT_SYMBOL(close);
> >  
> > +ssize_t readlink(const char *pathname, char *buf, size_t bufsiz)
> 
> man 2 readlink says:
> 
> > On  success,  readlink()  returns  the number of bytes placed in buf.
> > On error, -1 is returned and errno is set to indicate the error.
> 
> This function instead returns 0 for success and a negative error value.
> This is ok, but if the meaning of the return value is different, then it
> does not make sense to try to match the function prototype with the libc
> function.
> Make the return type int.
> 
> > +{
> > +	struct fs_driver_d *fsdrv;
> > +	struct fs_device_d *fsdev;
> > +	char *p = normalise_path(pathname);
> > +	char *freep = p;
> > +	int ret;
> > +	size_t len = 0;
> > +	char tmp[PATH_MAX];
> > +
> > +	tmp[0] = 0;
> > +	buf[0] = 0;
> > +
> > +	ret = path_check_prereq(pathname, S_IFLNK);
> > +	if (ret)
> > +		goto out;
> > +
> > +	fsdev = get_fs_device_and_root_path(&p);
> > +	if (!fsdev) {
> > +		ret = -ENODEV;
> > +		goto out;
> > +	}
> > +	fsdrv = fsdev->driver;
> > +
> > +	len = min(bufsiz, (size_t)PATH_MAX);
> > +	if (fsdrv->readlink) {
> > +		ret = fsdrv->readlink(&fsdev->dev, p, tmp, len);
> > +	} else {
> > +		ret = -EROFS;
> 
> EROFS is a strange error code here.
ENOSYS maybe better
> 
> > +		goto out;
> 
> This is not needed
> 
> > +	}
> > +
> > +	if (ret)
> > +		goto out;
> > +
> > +	if (tmp[0] == '/') {
> > +		int l = strlen(fsdev->path);
> > +
> > +		if (fsdev->path[l - 1] == '/')
> > +			l--;
> > +
> > +		if (l) {
> > +			len -= l;
> > +			strncat(buf, fsdev->path, l);
> > +		}
> > +	}
> 
> I don't understand why you manipulate the link target when the link target
> is an absolute path. This means that if mount a fatfs to fat and put a
> link there:
> 
> /fat/somelink -> /env/bla
this is not how linux work

an absolute path is related to the mounted path that why I did so
> 
> Then readlink will return /fat/env/bla, which is not what you want.
it's in fact

I try on nfs

Best Regards,
J.

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

^ permalink raw reply	[flat|nested] 38+ messages in thread

* [PATCH 07/18] ramfs: add symlink and readlink support
  2012-09-03 10:08 ` [PATCH 01/18] fs: add " Jean-Christophe PLAGNIOL-VILLARD
@ 2012-09-03 10:08   ` Jean-Christophe PLAGNIOL-VILLARD
  0 siblings, 0 replies; 38+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-09-03 10:08 UTC (permalink / raw)
  To: barebox

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
 fs/ramfs.c |   61 ++++++++++++++++++++++++++++++++++++++++++++++++++++++------
 1 file changed, 55 insertions(+), 6 deletions(-)

diff --git a/fs/ramfs.c b/fs/ramfs.c
index 91d06b8..8f3b936 100644
--- a/fs/ramfs.c
+++ b/fs/ramfs.c
@@ -42,6 +42,7 @@ struct ramfs_inode {
 	struct ramfs_inode *parent;
 	struct ramfs_inode *next;
 	struct ramfs_inode *child;
+	char *symlink;
 	ulong mode;
 
 	struct handle_d *handle;
@@ -176,6 +177,7 @@ static void ramfs_put_inode(struct ramfs_inode *node)
 		data = tmp;
 	}
 
+	free(node->symlink);
 	free(node->name);
 	free(node);
 }
@@ -212,18 +214,38 @@ static struct ramfs_inode* node_insert(struct ramfs_inode *parent_node, const ch
 
 /* ---------------------------------------------------------------*/
 
-static int ramfs_create(struct device_d *dev, const char *pathname, mode_t mode)
+static int __ramfs_create(struct device_d *dev, const char *pathname,
+			  mode_t mode, const char *symlink)
 {
 	struct ramfs_priv *priv = dev->priv;
 	struct ramfs_inode *node;
 	char *file;
+	char *__symlink = NULL;
 
 	node = rlookup_parent(priv, pathname, &file);
-	if (node) {
-		node_insert(node, file, mode);
-		return 0;
+	if (!node)
+		return -ENOENT;
+
+	if (symlink) {
+		__symlink = strdup(symlink);
+		if (!__symlink)
+			return -ENOMEM;
 	}
-	return -ENOENT;
+
+	node = node_insert(node, file, mode);
+	if (!node) {
+		free(__symlink);
+		return -ENOMEM;
+	}
+
+	node->symlink = __symlink;
+
+	return 0;
+}
+
+static int ramfs_create(struct device_d *dev, const char *pathname, mode_t mode)
+{
+	return __ramfs_create(dev, pathname, mode, NULL);
 }
 
 static int ramfs_unlink(struct device_d *dev, const char *pathname)
@@ -532,12 +554,37 @@ static int ramfs_stat(struct device_d *dev, const char *filename, struct stat *s
 	if (!node)
 		return -ENOENT;
 
-	s->st_size = node->size;
+	s->st_size = node->symlink ? strlen(node->symlink) : node->size;
 	s->st_mode = node->mode;
 
 	return 0;
 }
 
+static int ramfs_symlink(struct device_d *dev, const char *pathname,
+		       const char *newpath)
+{
+	mode_t mode = S_IFLNK | S_IRWXU | S_IRWXG | S_IRWXO;
+
+	return __ramfs_create(dev, newpath, mode, pathname);
+}
+
+static int ramfs_readlink(struct device_d *dev, const char *pathname,
+			char *buf, size_t bufsiz)
+{
+	struct ramfs_priv *priv = dev->priv;
+	struct ramfs_inode *node = rlookup(priv, pathname);
+	int len;
+
+	if (!node || !node->symlink)
+		return -ENOENT;
+
+	len = min(bufsiz, strlen(node->symlink));
+
+	memcpy(buf, node->symlink, len);
+
+	return 0;
+}
+
 static int ramfs_probe(struct device_d *dev)
 {
 	struct ramfs_inode *n;
@@ -584,6 +631,8 @@ static struct fs_driver_d ramfs_driver = {
 	.readdir   = ramfs_readdir,
 	.closedir  = ramfs_closedir,
 	.stat      = ramfs_stat,
+	.symlink   = ramfs_symlink,
+	.readlink  = ramfs_readlink,
 	.flags     = FS_DRIVER_NO_DEV,
 	.drv = {
 		.probe  = ramfs_probe,
-- 
1.7.10.4


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

^ permalink raw reply	[flat|nested] 38+ messages in thread

* [PATCH 07/18] ramfs: add symlink and readlink support
  2012-09-01 12:37 ` [PATCH 01/18] fs: add " Jean-Christophe PLAGNIOL-VILLARD
@ 2012-09-01 12:37   ` Jean-Christophe PLAGNIOL-VILLARD
  0 siblings, 0 replies; 38+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-09-01 12:37 UTC (permalink / raw)
  To: barebox

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
 fs/ramfs.c |   57 ++++++++++++++++++++++++++++++++++++++++++++++++++++-----
 1 file changed, 52 insertions(+), 5 deletions(-)

diff --git a/fs/ramfs.c b/fs/ramfs.c
index 91d06b8..beea564 100644
--- a/fs/ramfs.c
+++ b/fs/ramfs.c
@@ -42,6 +42,7 @@ struct ramfs_inode {
 	struct ramfs_inode *parent;
 	struct ramfs_inode *next;
 	struct ramfs_inode *child;
+	char *symlink;
 	ulong mode;
 
 	struct handle_d *handle;
@@ -176,6 +177,7 @@ static void ramfs_put_inode(struct ramfs_inode *node)
 		data = tmp;
 	}
 
+	free(node->symlink);
 	free(node->name);
 	free(node);
 }
@@ -212,18 +214,36 @@ static struct ramfs_inode* node_insert(struct ramfs_inode *parent_node, const ch
 
 /* ---------------------------------------------------------------*/
 
-static int ramfs_create(struct device_d *dev, const char *pathname, mode_t mode)
+static int __ramfs_create(struct device_d *dev, const char *pathname,
+			  mode_t mode, const char *symlink)
 {
 	struct ramfs_priv *priv = dev->priv;
 	struct ramfs_inode *node;
 	char *file;
 
 	node = rlookup_parent(priv, pathname, &file);
-	if (node) {
-		node_insert(node, file, mode);
+	if (!node)
+		return -ENOENT;
+
+	node = node_insert(node, file, mode);
+	if (!node)
+		return -ENOMEM;
+
+	if (!symlink)
 		return 0;
+
+	node->symlink = strdup(symlink);
+	if (!node->symlink) {
+		ramfs_put_inode(node);
+		return -ENOMEM;
 	}
-	return -ENOENT;
+
+	return 0;
+}
+
+static int ramfs_create(struct device_d *dev, const char *pathname, mode_t mode)
+{
+	return __ramfs_create(dev, pathname, mode, NULL);
 }
 
 static int ramfs_unlink(struct device_d *dev, const char *pathname)
@@ -532,12 +552,37 @@ static int ramfs_stat(struct device_d *dev, const char *filename, struct stat *s
 	if (!node)
 		return -ENOENT;
 
-	s->st_size = node->size;
+	s->st_size = node->symlink ? strlen(node->symlink) : node->size;
 	s->st_mode = node->mode;
 
 	return 0;
 }
 
+static int ramfs_symlink(struct device_d *dev, const char *pathname,
+		       const char *newpath)
+{
+	mode_t mode = S_IFLNK | S_IRWXU | S_IRWXG | S_IRWXO;
+
+	return __ramfs_create(dev, newpath, mode, pathname);
+}
+
+static int ramfs_readlink(struct device_d *dev, const char *pathname,
+			char *buf, size_t bufsiz)
+{
+	struct ramfs_priv *priv = dev->priv;
+	struct ramfs_inode *node = rlookup(priv, pathname);
+	int len;
+
+	if (!node || !node->symlink)
+		return -ENOENT;
+
+	len = min(bufsiz, strlen(node->symlink));
+
+	memcpy(buf, node->symlink, len);
+
+	return 0;
+}
+
 static int ramfs_probe(struct device_d *dev)
 {
 	struct ramfs_inode *n;
@@ -584,6 +629,8 @@ static struct fs_driver_d ramfs_driver = {
 	.readdir   = ramfs_readdir,
 	.closedir  = ramfs_closedir,
 	.stat      = ramfs_stat,
+	.symlink   = ramfs_symlink,
+	.readlink  = ramfs_readlink,
 	.flags     = FS_DRIVER_NO_DEV,
 	.drv = {
 		.probe  = ramfs_probe,
-- 
1.7.10.4


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

^ permalink raw reply	[flat|nested] 38+ messages in thread

end of thread, other threads:[~2012-09-03 10:08 UTC | newest]

Thread overview: 38+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-08-24  4:46 [PATCH 00/18] fs: add symlink and readlink support Jean-Christophe PLAGNIOL-VILLARD
2012-08-24  4:50 ` [PATCH 01/18] fs: add " Jean-Christophe PLAGNIOL-VILLARD
2012-08-24  4:50   ` [PATCH 02/18] fs: rename stat to lstat as we implement lstat Jean-Christophe PLAGNIOL-VILLARD
2012-08-24  4:50   ` [PATCH 03/18] fs: add symlink support Jean-Christophe PLAGNIOL-VILLARD
2012-08-27 13:35     ` Sascha Hauer
2012-09-01 10:42       ` Jean-Christophe PLAGNIOL-VILLARD
2012-08-24  4:50   ` [PATCH 04/18] fs: implement stat Jean-Christophe PLAGNIOL-VILLARD
2012-08-24  9:25     ` Roberto Nibali
2012-08-24 18:47       ` Jean-Christophe PLAGNIOL-VILLARD
2012-08-27 13:52     ` Sascha Hauer
2012-09-01 10:39       ` Jean-Christophe PLAGNIOL-VILLARD
2012-08-24  4:50   ` [PATCH 05/18] fs: open: add symlink support Jean-Christophe PLAGNIOL-VILLARD
2012-08-24  4:50   ` [PATCH 06/18] fs: introduce get_mounted_path to get the path where a file is mounted Jean-Christophe PLAGNIOL-VILLARD
2012-08-27 13:53     ` Sascha Hauer
2012-09-01 10:37       ` Jean-Christophe PLAGNIOL-VILLARD
2012-08-24  4:50   ` [PATCH 07/18] ramfs: add symlink and readlink support Jean-Christophe PLAGNIOL-VILLARD
2012-08-27 13:59     ` Sascha Hauer
2012-08-29  5:21       ` Jean-Christophe PLAGNIOL-VILLARD
2012-08-24  4:50   ` [PATCH 08/18] nfs: add " Jean-Christophe PLAGNIOL-VILLARD
2012-08-27 14:04     ` Sascha Hauer
2012-08-24  4:50   ` [PATCH 09/18] test: add -L support to test if it's a symbolic link Jean-Christophe PLAGNIOL-VILLARD
2012-08-24  4:50   ` [PATCH 10/18] commands: add readlink support Jean-Christophe PLAGNIOL-VILLARD
2012-08-24  9:31     ` Roberto Nibali
2012-08-24 18:46       ` Jean-Christophe PLAGNIOL-VILLARD
2012-08-24  4:50   ` [PATCH 11/18] command: add ln support Jean-Christophe PLAGNIOL-VILLARD
2012-08-24  4:50   ` [PATCH 12/18] ls: add symlink support to -l Jean-Christophe PLAGNIOL-VILLARD
2012-08-24  4:50   ` [PATCH 13/18] dirname: add -V option to return only path related to the mountpoint Jean-Christophe PLAGNIOL-VILLARD
2012-08-24  4:50   ` [PATCH 14/18] recursive_action: add ACTION_FOLLOWLINKS support Jean-Christophe PLAGNIOL-VILLARD
2012-08-24  4:50   ` [PATCH 15/18] evnfs: introduce major and minor Jean-Christophe PLAGNIOL-VILLARD
2012-08-27 14:12     ` Sascha Hauer
2012-08-29  5:23       ` Jean-Christophe PLAGNIOL-VILLARD
2012-08-24  4:50   ` [PATCH 16/18] envfs: add support of variable inode size Jean-Christophe PLAGNIOL-VILLARD
2012-08-24  4:50   ` [PATCH 17/18] envfs: add support of symlink Jean-Christophe PLAGNIOL-VILLARD
2012-08-24  4:50   ` [PATCH 18/18] defautenv: " Jean-Christophe PLAGNIOL-VILLARD
2012-08-27 13:25   ` [PATCH 01/18] fs: add readlink support Sascha Hauer
2012-09-01 10:50     ` Jean-Christophe PLAGNIOL-VILLARD
2012-09-01 12:35 [PATCH 00/18 v2] fs: add symlink and " Jean-Christophe PLAGNIOL-VILLARD
2012-09-01 12:37 ` [PATCH 01/18] fs: add " Jean-Christophe PLAGNIOL-VILLARD
2012-09-01 12:37   ` [PATCH 07/18] ramfs: add symlink and " Jean-Christophe PLAGNIOL-VILLARD
2012-09-03 10:04 [PATCH 00/18 v3] fs: " Jean-Christophe PLAGNIOL-VILLARD
2012-09-03 10:08 ` [PATCH 01/18] fs: add " Jean-Christophe PLAGNIOL-VILLARD
2012-09-03 10:08   ` [PATCH 07/18] ramfs: add symlink and " Jean-Christophe PLAGNIOL-VILLARD

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox