[PATCH 00/18 v2] fs: add symlink and readlink support
Jean-Christophe PLAGNIOL-VILLARD
plagnioj at jcrosoft.com
Mon Sep 3 05:40:16 EDT 2012
On 10:35 Mon 03 Sep , Sascha Hauer wrote:
> On Sat, Sep 01, 2012 at 02:35:11PM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > HI,
> >
> > v2:
> > addres comments
> >
> > 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
> >
>
> The following results in a crash here:
>
> # mkdir mymount
> # mount -t ramfs none mymount/
> # ln /env/boot/net /mymount/link
found
this will fix it
diff --git a/fs/fs.c b/fs/fs.c
index 05a1b85..53d8316 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -1060,17 +1060,24 @@ int symlink(const char *pathname, const char *newpath)
{
struct fs_driver_d *fsdrv;
struct fs_device_d *fsdev;
- char *p = normalise_path(pathname);
+ char *p;
+ char *freep = normalise_path(pathname);
int ret;
struct stat s;
- if (!stat(p, &s) && S_ISDIR(s.st_mode)) {
+ if (!freep)
+ return -ENOMEM;
+
+ if (!stat(freep, &s) && S_ISDIR(s.st_mode)) {
ret = -ENOSYS;
goto out;
}
- free(p);
- p = normalise_path(newpath);
+ free(freep);
+ freep = p = normalise_path(newpath);
+
+ if (!p)
+ return -ENOMEM;
ret = stat(p, &s);
if (!ret) {
@@ -1092,7 +1099,7 @@ int symlink(const char *pathname, const char *newpath)
}
out:
- free(p);
+ free(freep);
if (ret)
errno = -ret;
Best Regards,
J.
More information about the barebox
mailing list