diff options
author | Nick Withers <nick.withers@anu.edu.au> | 2014-03-07 14:23:30 +1100 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2014-12-11 08:12:13 +0100 |
commit | 9d9c42601ac54a316a5a8656ebc083c401da07e2 (patch) | |
tree | 54101eaf191266ea430cf27b7eae75e954271906 /cpukit/libfs | |
parent | sparc64: put each copyright on one line (diff) | |
download | rtems-9d9c42601ac54a316a5a8656ebc083c401da07e2.tar.bz2 |
Teach rtems_tarfs_load() about symlinks
Diffstat (limited to 'cpukit/libfs')
-rw-r--r-- | cpukit/libfs/src/imfs/imfs_load_tar.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/cpukit/libfs/src/imfs/imfs_load_tar.c b/cpukit/libfs/src/imfs/imfs_load_tar.c index 5b6f545f4c..1ef0e0b6d4 100644 --- a/cpukit/libfs/src/imfs/imfs_load_tar.c +++ b/cpukit/libfs/src/imfs/imfs_load_tar.c @@ -24,6 +24,7 @@ #include <sys/stat.h> #include <string.h> #include <tar.h> +#include <unistd.h> #include <rtems/untar.h> @@ -96,6 +97,7 @@ int rtems_tarfs_load( * Generate an IMFS node depending on the file type. * - For directories, just create directories as usual. IMFS * will take care of the rest. + * - For symbolic links, create as usual * - For files, create a file node with special tarfs properties. */ if (linkflag == DIRTYPE) { @@ -136,6 +138,21 @@ int rtems_tarfs_load( nblocks = (((file_size) + 511) & ~511) / 512; offset += 512 * nblocks; } + /* + * Create a symbolic link + */ + else if (linkflag == SYMTYPE) { + const char *linkto = hdr_ptr + 157; + int len; + + strncpy(full_filename, mountpoint, 255); + if (full_filename[(len=strlen(full_filename))-1] != '/') + strcat(full_filename, "/"); + ++len; + strncat(full_filename, filename, 256-len-1); + + rv = symlink(linkto, full_filename); + } } rtems_filesystem_location_free( &rootloc ); |