summaryrefslogtreecommitdiffstats
path: root/cpukit
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2010-06-08 12:59:51 +0000
committerSebastian Huber <sebastian.huber@embedded-brains.de>2010-06-08 12:59:51 +0000
commiteaee27b0b9b9dd243512e10ff8988ec66751474a (patch)
tree3265b365c2285f4060b8ad97c6428da020de72d8 /cpukit
parent2010-06-08 Sebastian Huber <sebastian.huber@embedded-brains.de> (diff)
downloadrtems-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')
-rw-r--r--cpukit/ChangeLog12
-rw-r--r--cpukit/libblock/src/bdpart-mount.c4
-rw-r--r--cpukit/libcsupport/Makefile.am2
-rw-r--r--cpukit/libcsupport/include/rtems/libio.h11
-rw-r--r--cpukit/libfs/src/pipe/pipe.c15
-rw-r--r--cpukit/libmisc/fsmount/fsmount.c76
-rw-r--r--cpukit/libmisc/fsmount/fsmount.h14
-rw-r--r--cpukit/libnetworking/rtems/mkrootfs.c94
-rw-r--r--cpukit/libnetworking/rtems/mkrootfs.h7
9 files changed, 35 insertions, 200 deletions
diff --git a/cpukit/ChangeLog b/cpukit/ChangeLog
index 798f157f26..5f5dfd6031 100644
--- a/cpukit/ChangeLog
+++ b/cpukit/ChangeLog
@@ -1,5 +1,17 @@
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().
+
+2010-06-08 Sebastian Huber <sebastian.huber@embedded-brains.de>
+
* libfs/src/imfs/fifoimfs_init.c: New file.
* libfs/Makefile.am: Reflect change above.
* libfs/src/imfs/imfs.h, libfs/src/imfs/imfs_eval.c,
diff --git a/cpukit/libblock/src/bdpart-mount.c b/cpukit/libblock/src/bdpart-mount.c
index 8f2e051c61..aef15dfbaa 100644
--- a/cpukit/libblock/src/bdpart-mount.c
+++ b/cpukit/libblock/src/bdpart-mount.c
@@ -29,7 +29,7 @@
#include <rtems.h>
#include <rtems/bdpart.h>
-#include <rtems/fsmount.h>
+#include <rtems/libio.h>
rtems_status_code rtems_bdpart_mount(
const char *disk_name,
@@ -90,7 +90,7 @@ rtems_status_code rtems_bdpart_mount(
/* Create mount point */
strncpy( mount_marker, logical_disk_marker, RTEMS_BDPART_NUMBER_SIZE);
- rv = rtems_fsmount_create_mount_point( mount_point);
+ rv = rtems_mkdir( mount_point, S_IRWXU | S_IRWXG | S_IRWXO);
if (rv != 0) {
esc = RTEMS_IO_ERROR;
goto cleanup;
diff --git a/cpukit/libcsupport/Makefile.am b/cpukit/libcsupport/Makefile.am
index 6b74f0e052..3e80056408 100644
--- a/cpukit/libcsupport/Makefile.am
+++ b/cpukit/libcsupport/Makefile.am
@@ -46,7 +46,7 @@ ASSOCIATION_C_FILES = src/assoclocalbyname.c \
BASE_FS_C_FILES = src/base_fs.c src/mount.c src/unmount.c src/libio.c \
src/mount-mgr.c src/libio_init.c \
src/libio_sockets.c src/eval.c src/fs_null_handlers.c src/privateenv.c \
- src/open_dev_console.c src/__usrenv.c
+ src/open_dev_console.c src/__usrenv.c src/rtems_mkdir.c
TERMIOS_C_FILES = src/cfgetispeed.c src/cfgetospeed.c src/cfsetispeed.c \
src/cfsetospeed.c src/tcgetattr.c src/tcsetattr.c src/tcdrain.c \
diff --git a/cpukit/libcsupport/include/rtems/libio.h b/cpukit/libcsupport/include/rtems/libio.h
index da9fa884a0..04fdc6898f 100644
--- a/cpukit/libcsupport/include/rtems/libio.h
+++ b/cpukit/libcsupport/include/rtems/libio.h
@@ -735,6 +735,17 @@ extern rtems_libio_supp_functions_t rtems_libio_supp_helper;
typedef void (*rtems_fs_init_functions_t)(void);
extern rtems_fs_init_functions_t rtems_fs_init_helper;
+/**
+ * @brief Creates a directory and all its parrent directories according to
+ * @a path.
+ *
+ * The @a mode value selects the access permissions of the directory.
+ *
+ * @retval 0 Successful operation.
+ * @retval -1 An error occured. @c errno indicates the error.
+ */
+extern int rtems_mkdir(const char *path, mode_t mode);
+
#ifdef __cplusplus
}
#endif
diff --git a/cpukit/libfs/src/pipe/pipe.c b/cpukit/libfs/src/pipe/pipe.c
index 0cc8c9acdb..a7a78e95fa 100644
--- a/cpukit/libfs/src/pipe/pipe.c
+++ b/cpukit/libfs/src/pipe/pipe.c
@@ -30,20 +30,11 @@ int pipe_create(
int filsdes[2]
)
{
- rtems_filesystem_location_info_t loc;
rtems_libio_t *iop;
int err = 0;
- /* Create /tmp if not exists */
- /* FIXME: We should use a general mkdir function for this */
- if (rtems_filesystem_evaluate_path("/tmp", 3, RTEMS_LIBIO_PERMS_RWX, &loc, TRUE)
- != 0) {
- if (errno != ENOENT)
- return -1;
- if (mkdir("/tmp", S_IRWXU|S_IRWXG|S_IRWXO|S_ISVTX) != 0)
- return -1;
- }
- else
- rtems_filesystem_freenode(&loc);
+
+ if (rtems_mkdir("/tmp", S_IRWXU | S_IRWXG | S_IRWXO) != 0)
+ return -1;
/* /tmp/.fifoXXXX */
char fifopath[15];
diff --git a/cpukit/libmisc/fsmount/fsmount.c b/cpukit/libmisc/fsmount/fsmount.c
index 5fa52e99f2..1d82b94391 100644
--- a/cpukit/libmisc/fsmount/fsmount.c
+++ b/cpukit/libmisc/fsmount/fsmount.c
@@ -34,83 +34,11 @@
#include <rtems.h>
#include <rtems/fsmount.h>
+#include <rtems/libio.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
-#include <rtems/imfs.h>
-#include <sys/stat.h>
-
-/*=========================================================================*\
-| Function: |
-\*-------------------------------------------------------------------------*/
-int rtems_fsmount_create_mount_point
-(
-/*-------------------------------------------------------------------------*\
-| Purpose: |
-| This function will create the mount point given |
-+---------------------------------------------------------------------------+
-| Input Parameters: |
-\*-------------------------------------------------------------------------*/
- const char *mount_point
- )
-/*-------------------------------------------------------------------------*\
-| Return Value: |
-| 0, if success, -1 and errno if failed |
-\*=========================================================================*/
-{
- int rc = 0;
- char *tok_buffer = NULL;
- char *token = NULL;
- int token_len;
- size_t total_len;
- IMFS_token_types token_type;
- struct stat file_info;
- /*
- * allocate temp memory to rebuild path name
- */
- tok_buffer = calloc(strlen(mount_point)+1,sizeof(char));
- if ( !tok_buffer )
- return -1;
- token = tok_buffer;
- total_len = 0;
- do {
- /*
- * scan through given string, one segment at a time
- */
- token_type = IMFS_get_token(
- mount_point+total_len,
- strlen(mount_point+total_len),
- token,
- &token_len
- );
- total_len += token_len;
- strncpy(tok_buffer,mount_point,total_len);
- tok_buffer[total_len] = '\0';
-
- if ((token_type != IMFS_NO_MORE_PATH) &&
- (token_type != IMFS_CURRENT_DIR) &&
- (token_type != IMFS_INVALID_TOKEN)) {
- /*
- * check, whether segment exists
- */
- if (0 != stat(tok_buffer,&file_info)) {
- /*
- * if not, create directory
- */
- rc = mknod(tok_buffer,S_IRWXU | S_IRWXG | S_IRWXO | S_IFDIR,0);
- }
- }
- } while ((rc == 0) &&
- (token_type != IMFS_NO_MORE_PATH) &&
- (token_type != IMFS_INVALID_TOKEN));
-
- /*
- * return token buffer to heap. Verified to be non-NULL when calloc'ed.
- */
- free(tok_buffer);
- return rc;
-}
/*=========================================================================*\
| Function: |
@@ -148,7 +76,7 @@ int rtems_fsmount
* create mount point
*/
if (tmp_rc == 0) {
- tmp_rc = rtems_fsmount_create_mount_point(fstab_ptr->target);
+ tmp_rc = rtems_mkdir(fstab_ptr->target, S_IRWXU | S_IRWXG | S_IRWXO);
if (tmp_rc != 0) {
if (0 != (fstab_ptr->report_reasons & FSMOUNT_MNTPNT_CRTERR)) {
fprintf(stdout,"fsmount: creation of mount point \"%s\" failed: %s\n",
diff --git a/cpukit/libmisc/fsmount/fsmount.h b/cpukit/libmisc/fsmount/fsmount.h
index 15597c31ff..94c8508358 100644
--- a/cpukit/libmisc/fsmount/fsmount.h
+++ b/cpukit/libmisc/fsmount/fsmount.h
@@ -121,24 +121,14 @@ typedef struct {
} rtems_fstab_entry;
/**
- * Creates the mount point with path @a mount_point.
- *
- * On success, zero is returned. On error, -1 is returned, and @c errno is set
- * appropriately.
- *
- * @see rtems_fsmount().
- */
-int rtems_fsmount_create_mount_point(const char *mount_point);
-
-/**
* Mounts the file systems listed in the file system mount table @a fstab of
* size @a size.
*
* Each file system will be mounted according to its table entry parameters.
* In case of an abort condition the corresponding table index will be reported
* in @a abort_index. The pointer @a abort_index may be @c NULL. The mount
- * point paths will be created with rtems_fsmount_create_mount_point() and need
- * not exist beforehand.
+ * point paths will be created with rtems_mkdir() and need not exist
+ * beforehand.
*
* On success, zero is returned. On error, -1 is returned, and @c errno is set
* appropriately.
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.
*/