diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2010-06-08 12:59:51 +0000 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2010-06-08 12:59:51 +0000 |
commit | eaee27b0b9b9dd243512e10ff8988ec66751474a (patch) | |
tree | 3265b365c2285f4060b8ad97c6428da020de72d8 /cpukit/libnetworking/rtems | |
parent | 2010-06-08 Sebastian Huber <sebastian.huber@embedded-brains.de> (diff) | |
download | rtems-eaee27b0b9b9dd243512e10ff8988ec66751474a.tar.bz2 |
2010-06-08 Sebastian Huber <sebastian.huber@embedded-brains.de>
PR 1524/filesystem
* libcsupport/src/rtems_mkdir.c: New file.
* libcsupport/src/Makefile.am: Reflect change above.
* libcsupport/include/rtems/libio.h: Added rtems_mkdir().
* libmisc/fsmount/fsmount.h, libmisc/fsmount/fsmount.c,
libblock/src/bdpart-mount.c, libnetworking/rtems/mkrootfs.h,
libnetworking/rtems/mkrootfs.c, libfs/src/pipe/pipe.c: Use
rtems_mkdir(). Removed rtems_fsmount_create_mount_point() and
rtems_rootfs_mkdir().
Diffstat (limited to 'cpukit/libnetworking/rtems')
-rw-r--r-- | cpukit/libnetworking/rtems/mkrootfs.c | 94 | ||||
-rw-r--r-- | cpukit/libnetworking/rtems/mkrootfs.h | 7 |
2 files changed, 2 insertions, 99 deletions
diff --git a/cpukit/libnetworking/rtems/mkrootfs.c b/cpukit/libnetworking/rtems/mkrootfs.c index fc8aee36d0..0bf6a6ac56 100644 --- a/cpukit/libnetworking/rtems/mkrootfs.c +++ b/cpukit/libnetworking/rtems/mkrootfs.c @@ -68,96 +68,6 @@ static const rtems_rootfs_dir_table default_directories[] = #define MKDIR_MODE (S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH) /* - * Build a path. Taken from the BSD `mkdir' command. - */ - -int -rtems_rootfs_mkdir (const char *path_orig, mode_t omode) -{ - struct stat sb; - mode_t numask, oumask; - int first, last, retval; - char path[128]; - char *p = path; - - if (strlen (path_orig) >= sizeof path) - { - printf ("root fs: mkdir path too long `%s'\n", path); - return -1; - } - - strcpy (path, path_orig); - oumask = 0; - retval = 0; - if (p[0] == '/') /* Skip leading '/'. */ - ++p; - for (first = 1, last = 0; !last ; ++p) - { - if (p[0] == '\0') - last = 1; - else if (p[0] != '/') - continue; - *p = '\0'; - if (p[1] == '\0') - last = 1; - if (first) - { - /* - * POSIX 1003.2: - * For each dir operand that does not name an existing - * directory, effects equivalent to those cased by the - * following command shall occcur: - * - * mkdir -p -m $(umask -S),u+wx $(dirname dir) && - * mkdir [-m mode] dir - * - * We change the user's umask and then restore it, - * instead of doing chmod's. - */ - oumask = umask(0); - numask = oumask & ~(S_IWUSR | S_IXUSR); - umask(numask); - first = 0; - } - if (last) - umask(oumask); - if (stat(path, &sb)) - { - if (errno != ENOENT) - { - printf ("root fs: error stat'ing path `%s', %s\n", - path, strerror (errno)); - retval = 1; - break; - } - if (mkdir(path, last ? omode : S_IRWXU | S_IRWXG | S_IRWXO) < 0) - { - printf ("root fs: error building path `%s', %s\n", - path, strerror (errno)); - retval = 1; - break; - } - } - else if ((sb.st_mode & S_IFMT) != S_IFDIR) - { - if (last) - errno = EEXIST; - else - errno = ENOTDIR; - printf ("root fs: path `%s' contains a file, %s\n", - path, strerror (errno)); - retval = 1; - break; - } - if (!last) - *p = '/'; - } - if (!first && !last) - umask(oumask); - return retval; -} - -/* * Create enough files to support the networking stack. * Points to a table of strings. */ @@ -205,7 +115,7 @@ rtems_rootfs_file_append (const char *file, strncpy (path, file, i); path[i] = '\0'; - if (rtems_rootfs_mkdir (path, MKDIR_MODE)) + if (rtems_mkdir (path, MKDIR_MODE)) return -1; break; } @@ -310,7 +220,7 @@ rtems_create_root_fs (void) for (i = 0; i < (sizeof (default_directories) / sizeof (rtems_rootfs_dir_table)); i++) - if (rtems_rootfs_mkdir (default_directories[i].name, + if (rtems_mkdir (default_directories[i].name, default_directories[i].mode)) return -1; diff --git a/cpukit/libnetworking/rtems/mkrootfs.h b/cpukit/libnetworking/rtems/mkrootfs.h index 661ddc6147..a8d0284c84 100644 --- a/cpukit/libnetworking/rtems/mkrootfs.h +++ b/cpukit/libnetworking/rtems/mkrootfs.h @@ -31,13 +31,6 @@ extern "C" { #include <rtems.h> /* - * Builds the complete path, like "mkdir -p". - */ - -int -rtems_rootfs_mkdir (const char *path, mode_t omode); - -/* * Appends the lines to the a file. Create the file * and builds the path if it does not exist. */ |