diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2010-07-01 14:29:09 +0000 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2010-07-01 14:29:09 +0000 |
commit | 615d8ccf769fb68f094e0678c65880324a9ab431 (patch) | |
tree | 653986b1955b7c07703a8ca865306640bafeed48 /cpukit/libnetworking | |
parent | 2010-06-07 Sebastian Huber <sebastian.huber@embedded-brains.de> (diff) | |
download | rtems-615d8ccf769fb68f094e0678c65880324a9ab431.tar.bz2 |
2010-06-08 Sebastian Huber <sebastian.huber@embedded-brains.de>
* libcsupport/include/rtems/libio.h: Documentation.
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: Use rtems_mkdir(). Removed
rtems_fsmount_create_mount_point() and rtems_rootfs_mkdir().
Diffstat (limited to 'cpukit/libnetworking')
-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 3871314ca2..819684b9d4 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 e3e50d55d1..8bf053bc52 100644 --- a/cpukit/libnetworking/rtems/mkrootfs.h +++ b/cpukit/libnetworking/rtems/mkrootfs.h @@ -30,13 +30,6 @@ extern "C" { #endif -/* - * 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. |