* 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().
This commit is contained in:
Sebastian Huber
2010-07-01 14:29:09 +00:00
parent 00bf6744f5
commit 615d8ccf76
9 changed files with 331 additions and 294 deletions

View File

@@ -207,6 +207,21 @@
* configure.ac: Remove c4x (dead port).
* score/cpu/Makefile.am: Remove c4x (dead port).
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().
2010-06-07 Sebastian Huber <sebastian.huber@embedded-brains.de>
* libcsupport/include/rtems/libio_.h: Declare

View File

@@ -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;

View File

@@ -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 \

View File

@@ -1,15 +1,12 @@
/**
* @file rtems/libio.h
* @file
*
* @ingroup LibIO
*
* @brief Basic IO API.
*/
/*
* System call and file system interface definition
*
* General purpose communication channel for RTEMS to allow UNIX/POSIX
* system call behavior under RTEMS. Initially this supported only
* IO to devices but has since been enhanced to support networking
* and support for mounted file systems.
*
* COPYRIGHT (c) 1989-2008.
* On-Line Applications Research Corporation (OAR).
*
@@ -23,41 +20,63 @@
#ifndef _RTEMS_RTEMS_LIBIO_H
#define _RTEMS_RTEMS_LIBIO_H
#include <rtems.h>
#include <rtems/chain.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/ioctl.h>
#include <sys/statvfs.h>
/*
* Define data types which must be constructed using forward references.
*/
#include <unistd.h>
#include <termios.h>
#include <rtems.h>
#include <rtems/fs.h>
#include <rtems/chain.h>
#ifdef __cplusplus
extern "C" {
#endif
/*
* A 64bit file offset for internal use by RTEMS. Based on the newlib type.
/**
* @defgroup LibIO IO Library
*
* @brief Provides system call and file system interface definitions.
*
* General purpose communication channel for RTEMS to allow UNIX/POSIX
* system call behavior under RTEMS. Initially this supported only
* IO to devices but has since been enhanced to support networking
* and support for mounted file systems.
*
* @{
*/
/**
* @brief A 64-bit file offset for internal use by RTEMS. Based on the Newlib
* type.
*/
typedef _off64_t rtems_off64_t;
/*
* Valid RTEMS file types.
/**
* @name File system node types.
*
* @{
*/
#define RTEMS_FILESYSTEM_DIRECTORY 1
#define RTEMS_FILESYSTEM_DEVICE 2
#define RTEMS_FILESYSTEM_HARD_LINK 3
#define RTEMS_FILESYSTEM_SYM_LINK 4
#define RTEMS_FILESYSTEM_MEMORY_FILE 5
/** @} */
typedef int rtems_filesystem_node_types_t;
/*
* File Handler Operations Table
/**
* @name File System Node Operations
*
* @{
*/
typedef int (*rtems_filesystem_open_t)(
rtems_libio_t *iop,
const char *pathname,
@@ -131,6 +150,11 @@ typedef int (*rtems_filesystem_rmnod_t)(
rtems_filesystem_location_info_t *pathloc /* IN */
);
/** @} */
/**
* @brief File system node operations table.
*/
struct _rtems_filesystem_file_handlers_r {
rtems_filesystem_open_t open_h;
rtems_filesystem_close_t close_h;
@@ -148,8 +172,10 @@ struct _rtems_filesystem_file_handlers_r {
rtems_filesystem_rmnod_t rmnod_h;
};
/*
* File System Operations Table
/**
* @name File System Operations
*
* @{
*/
/*
@@ -261,12 +287,10 @@ typedef int (*rtems_filesystem_statvfs_t)(
struct statvfs *buf /* OUT */
);
/*
* operations table that must be defined for every file system.
*/
/** @} */
/*
* File system types
/**
* @brief File system operations table.
*/
struct _rtems_filesystem_operations_table {
rtems_filesystem_evalpath_t evalpath_h;
@@ -307,7 +331,10 @@ extern const rtems_filesystem_table_t rtems_filesystem_table [];
/**
* @brief Per file system table entry routine type.
*
* Return @c true to continue the iteration, and @c false to stop.
* @see rtems_filesystem_iterate().
*
* @retval true Continue the iteration.
* @retval false Stop the iteration.
*/
typedef bool (*rtems_per_filesystem_routine)(
const rtems_filesystem_table_t *entry,
@@ -327,7 +354,9 @@ rtems_filesystem_iterate(
);
/**
* @brief Returns the file system mount handler associated with the @a type, or
* @brief Gets the mount handler for the file system @a type.
*
* @return The file system mount handler associated with the @a type, or
* @c NULL if no such association exists.
*/
rtems_filesystem_fsmount_me_t
@@ -364,9 +393,9 @@ rtems_filesystem_unregister(
const char *type
);
/*
* Structure used to contain file system specific information which
* is required to support fpathconf().
/**
* @brief Contain file system specific information which is required to support
* fpathconf().
*/
typedef struct {
int link_max; /* count */
@@ -383,15 +412,16 @@ typedef struct {
int posix_vdisable; /* special char processing, 0=no, 1=yes */
} rtems_filesystem_limits_and_options_t;
/*
* Default pathconf settings. Override in a filesystem.
/**
* @brief Default pathconf settings.
*
* Override in a filesystem.
*/
extern const rtems_filesystem_limits_and_options_t rtems_filesystem_default_pathconf;
/*
* Structure for a mount table entry.
/**
* @brief Mount table entry.
*/
struct rtems_filesystem_mount_table_entry_tt {
rtems_chain_node Node;
rtems_filesystem_location_info_t mt_point_node;
@@ -422,27 +452,27 @@ struct rtems_filesystem_mount_table_entry_tt {
};
/**
* The pathconf setting for a file system.
* @brief The pathconf setting for a file system.
*/
#define rtems_filesystem_pathconf(_mte) ((_mte)->pathconf_limits_and_options)
/**
* The type of file system. Its name.
* @brief The type of file system. Its name.
*/
#define rtems_filesystem_type(_mte) ((_mte)->type)
/**
* The mount point of a file system.
* @brief The mount point of a file system.
*/
#define rtems_filesystem_mount_point(_mte) ((_mte)->target)
/**
* The device entry of a file system.
* @brief The device entry of a file system.
*/
#define rtems_filesystem_mount_device(_mte) ((_mte)->dev)
/*
* Valid RTEMS file systems options
/**
* @brief File systems options.
*/
typedef enum {
RTEMS_FILESYSTEM_READ_ONLY,
@@ -450,12 +480,13 @@ typedef enum {
RTEMS_FILESYSTEM_BAD_OPTIONS
} rtems_filesystem_options_t;
/*
* An open file data structure, indexed by 'fd'
* TODO:
* should really have a separate per/file data structure that this
* points to (eg: size, offset, driver, pathname should be in that)
/**
* @brief An open file data structure.
*
* It will be indexed by 'fd'.
*
* @todo Should really have a separate per/file data structure that this points
* to (eg: size, offset, driver, pathname should be in that)
*/
struct rtems_libio_tt {
rtems_driver_name_t *driver;
@@ -470,10 +501,11 @@ struct rtems_libio_tt {
const rtems_filesystem_file_handlers_r *handlers; /* type specific handlers */
};
/*
* param block for read/write
* Note: it must include 'offset' instead of using iop's offset since
* we can have multiple outstanding i/o's on a device.
/**
* @brief Paramameter block for read/write.
*
* It must include 'offset' instead of using iop's offset since we can have
* multiple outstanding i/o's on a device.
*/
typedef struct {
rtems_libio_t *iop;
@@ -484,8 +516,8 @@ typedef struct {
uint32_t bytes_moved;
} rtems_libio_rw_args_t;
/*
* param block for open/close
/**
* @brief Parameter block for open/close.
*/
typedef struct {
rtems_libio_t *iop;
@@ -493,8 +525,8 @@ typedef struct {
uint32_t mode;
} rtems_libio_open_close_args_t;
/*
* param block for ioctl
/**
* @brief Parameter block for ioctl.
*/
typedef struct {
rtems_libio_t *iop;
@@ -503,9 +535,12 @@ typedef struct {
uint32_t ioctl_return;
} rtems_libio_ioctl_args_t;
/*
* Values for 'flag'
/**
* @name Flag Values
*
* @{
*/
#define LIBIO_FLAGS_NO_DELAY 0x0001 /* return immediately if no data */
#define LIBIO_FLAGS_READ 0x0002 /* reading */
#define LIBIO_FLAGS_WRITE 0x0004 /* writing */
@@ -515,10 +550,14 @@ typedef struct {
#define LIBIO_FLAGS_CLOSE_ON_EXEC 0x0800 /* close on process exec() */
#define LIBIO_FLAGS_READ_WRITE (LIBIO_FLAGS_READ | LIBIO_FLAGS_WRITE)
/** @} */
void rtems_libio_init(void);
/*
* External I/O handlers
/**
* @name External I/O Handlers
*
* @{
*/
typedef int (*rtems_libio_open_t)(
@@ -555,6 +594,14 @@ typedef rtems_off64_t (*rtems_libio_lseek_t)(
int whence
);
/** @} */
/**
* @name Permission Macros
*
* @{
*/
/*
* The following macros are used to build up the permissions sets
* used to check permissions. These are similar in style to the
@@ -567,11 +614,7 @@ typedef rtems_off64_t (*rtems_libio_lseek_t)(
#define RTEMS_LIBIO_PERMS_SEARCH RTEMS_LIBIO_PERMS_EXEC
#define RTEMS_LIBIO_PERMS_RWX S_IRWXO
/*
* Macros
*/
#include <unistd.h>
/** @} */
union __rtems_dev_t {
dev_t device;
@@ -632,10 +675,65 @@ static inline rtems_device_minor_number rtems_filesystem_dev_minor_t(
void rtems_filesystem_initialize( void );
int unmount(
const char *mount_path
);
int mount(
const char *source,
const char *target,
const char *filesystemtype,
rtems_filesystem_options_t options,
const void *data
);
/*
* Callbacks from TERMIOS routines to device-dependent code
* Boot Time Mount Table Structure
*/
typedef struct {
const char *type;
rtems_filesystem_options_t fsoptions;
const char *device;
const char *mount_point;
} rtems_filesystem_mount_table_t;
extern const rtems_filesystem_mount_table_t *rtems_filesystem_mount_table;
extern const int rtems_filesystem_mount_table_size;
typedef void (*rtems_libio_init_functions_t)(void);
extern rtems_libio_init_functions_t rtems_libio_init_helper;
void open_dev_console(void);
typedef void (*rtems_libio_supp_functions_t)(void);
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);
/** @} */
/**
* @defgroup Termios Termios
*
* @ingroup LibIO
*
* @brief Termios
*
* @{
*/
#include <termios.h>
typedef struct rtems_termios_callbacks {
int (*firstOpen)(int major, int minor, void *arg);
@@ -648,9 +746,6 @@ typedef struct rtems_termios_callbacks {
int outputUsesInterrupts;
} rtems_termios_callbacks;
/*
* Device-independent TERMIOS routines
*/
void rtems_termios_initialize (void);
/*
@@ -698,42 +793,7 @@ int rtems_termios_dequeue_characters(
int len
);
int unmount(
const char *mount_path
);
int mount(
const char *source,
const char *target,
const char *filesystemtype,
rtems_filesystem_options_t options,
const void *data
);
/*
* Boot Time Mount Table Structure
*/
typedef struct {
const char *type;
rtems_filesystem_options_t fsoptions;
const char *device;
const char *mount_point;
} rtems_filesystem_mount_table_t;
extern const rtems_filesystem_mount_table_t *rtems_filesystem_mount_table;
extern const int rtems_filesystem_mount_table_size;
typedef void (*rtems_libio_init_functions_t)(void);
extern rtems_libio_init_functions_t rtems_libio_init_helper;
void open_dev_console(void);
typedef void (*rtems_libio_supp_functions_t)(void);
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;
/** @} */
#ifdef __cplusplus
}

View File

@@ -0,0 +1,141 @@
/**
* @file
*
* @ingroup LibIO
*
* @brief rtems_mkdir() implementation.
*
* The implementation is based on FreeBSD 'bin/mkdir/mkdir.c' revision 163213.
*/
/*-
* Copyright (c) 2010 embedded brains GmbH.
*
* Copyright (c) 1983, 1992, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#if HAVE_CONFIG_H
#include "config.h"
#endif
#include <sys/types.h>
#include <sys/stat.h>
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <rtems/libio.h>
/*
* Returns 1 if a directory has been created,
* 2 if it already existed, and 0 on failure.
*/
static int
build(char *path, mode_t omode)
{
struct stat sb;
mode_t numask, oumask;
int first, last, retval;
char *p;
p = path;
oumask = 0;
retval = 1;
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 (!last && 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 caused 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);
(void)umask(numask);
first = 0;
}
if (last)
(void)umask(oumask);
if (mkdir(path, last ? omode : S_IRWXU | S_IRWXG | S_IRWXO) < 0) {
if (errno == EEXIST || errno == EISDIR) {
if (stat(path, &sb) < 0) {
retval = 0;
break;
} else if (!S_ISDIR(sb.st_mode)) {
if (last)
errno = EEXIST;
else
errno = ENOTDIR;
retval = 0;
break;
}
if (last)
retval = 2;
} else {
retval = 0;
break;
}
}
if (!last)
*p = '/';
}
if (!first && !last)
(void)umask(oumask);
return (retval);
}
int
rtems_mkdir(const char *path, mode_t mode)
{
int success = 0;
char *dup_path = strdup(path);
if (dup_path != NULL) {
success = build(dup_path, mode);
free(dup_path);
}
return success != 0 ? 0 : -1;
}

View File

@@ -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",

View File

@@ -120,16 +120,6 @@ typedef struct {
uint16_t abort_reasons;
} 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.
@@ -137,8 +127,8 @@ int rtems_fsmount_create_mount_point(const char *mount_point);
* 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.

View File

@@ -67,96 +67,6 @@ static const rtems_rootfs_dir_table default_directories[] =
#define MKFILE_MODE (S_IRUSR | S_IWUSR | S_IWGRP | S_IRGRP | S_IROTH)
#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;

View File

@@ -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.