Changeset eaee27b in rtems


Ignore:
Timestamp:
Jun 8, 2010, 12:59:51 PM (9 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
4.11, master
Children:
b81c8a69
Parents:
241f4c96
Message:

2010-06-08 Sebastian Huber <sebastian.huber@…>

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().
Location:
cpukit
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • cpukit/ChangeLog

    r241f4c96 reaee27b  
     12010-06-08      Sebastian Huber <sebastian.huber@embedded-brains.de>
     2
     3        PR 1524/filesystem
     4        * libcsupport/src/rtems_mkdir.c: New file.
     5        * libcsupport/src/Makefile.am: Reflect change above.
     6        * libcsupport/include/rtems/libio.h: Added rtems_mkdir().
     7        * libmisc/fsmount/fsmount.h, libmisc/fsmount/fsmount.c,
     8        libblock/src/bdpart-mount.c, libnetworking/rtems/mkrootfs.h,
     9        libnetworking/rtems/mkrootfs.c, libfs/src/pipe/pipe.c: Use
     10        rtems_mkdir().  Removed rtems_fsmount_create_mount_point() and
     11        rtems_rootfs_mkdir().
     12
    1132010-06-08      Sebastian Huber <sebastian.huber@embedded-brains.de>
    214
  • cpukit/libblock/src/bdpart-mount.c

    r241f4c96 reaee27b  
    3030#include <rtems.h>
    3131#include <rtems/bdpart.h>
    32 #include <rtems/fsmount.h>
     32#include <rtems/libio.h>
    3333
    3434rtems_status_code rtems_bdpart_mount(
     
    9191    /* Create mount point */
    9292    strncpy( mount_marker, logical_disk_marker, RTEMS_BDPART_NUMBER_SIZE);
    93     rv = rtems_fsmount_create_mount_point( mount_point);
     93    rv = rtems_mkdir( mount_point, S_IRWXU | S_IRWXG | S_IRWXO);
    9494    if (rv != 0) {
    9595      esc = RTEMS_IO_ERROR;
  • cpukit/libcsupport/Makefile.am

    r241f4c96 reaee27b  
    4747    src/mount-mgr.c src/libio_init.c \
    4848    src/libio_sockets.c src/eval.c src/fs_null_handlers.c src/privateenv.c \
    49     src/open_dev_console.c src/__usrenv.c
     49    src/open_dev_console.c src/__usrenv.c src/rtems_mkdir.c
    5050
    5151TERMIOS_C_FILES = src/cfgetispeed.c src/cfgetospeed.c src/cfsetispeed.c \
  • cpukit/libcsupport/include/rtems/libio.h

    r241f4c96 reaee27b  
    736736extern  rtems_fs_init_functions_t    rtems_fs_init_helper;
    737737
     738/**
     739 * @brief Creates a directory and all its parrent directories according to
     740 * @a path.
     741 *
     742 * The @a mode value selects the access permissions of the directory.
     743 *
     744 * @retval 0 Successful operation.
     745 * @retval -1 An error occured.  @c errno indicates the error.
     746 */
     747extern int rtems_mkdir(const char *path, mode_t mode);
     748
    738749#ifdef __cplusplus
    739750}
  • cpukit/libfs/src/pipe/pipe.c

    r241f4c96 reaee27b  
    3131)
    3232{
    33   rtems_filesystem_location_info_t loc;
    3433  rtems_libio_t *iop;
    3534  int err = 0;
    36   /* Create /tmp if not exists */
    37   /* FIXME: We should use a general mkdir function for this */
    38   if (rtems_filesystem_evaluate_path("/tmp", 3, RTEMS_LIBIO_PERMS_RWX, &loc, TRUE)
    39       != 0) {
    40     if (errno != ENOENT)
    41       return -1;
    42     if (mkdir("/tmp", S_IRWXU|S_IRWXG|S_IRWXO|S_ISVTX) != 0)
    43       return -1;
    44   }
    45   else
    46     rtems_filesystem_freenode(&loc);
     35
     36  if (rtems_mkdir("/tmp", S_IRWXU | S_IRWXG | S_IRWXO) != 0)
     37    return -1;
    4738
    4839  /* /tmp/.fifoXXXX */
  • cpukit/libmisc/fsmount/fsmount.c

    r241f4c96 reaee27b  
    3535#include <rtems.h>
    3636#include <rtems/fsmount.h>
     37#include <rtems/libio.h>
    3738#include <stdio.h>
    3839#include <stdlib.h>
    3940#include <string.h>
    4041#include <errno.h>
    41 #include <rtems/imfs.h>
    42 #include <sys/stat.h>
    43 
    44 /*=========================================================================*\
    45 | Function:                                                                 |
    46 \*-------------------------------------------------------------------------*/
    47 int rtems_fsmount_create_mount_point
    48 (
    49 /*-------------------------------------------------------------------------*\
    50 | Purpose:                                                                  |
    51 |  This function will create the mount point given                          |
    52 +---------------------------------------------------------------------------+
    53 | Input Parameters:                                                         |
    54 \*-------------------------------------------------------------------------*/
    55  const char *mount_point
    56  )
    57 /*-------------------------------------------------------------------------*\
    58 | Return Value:                                                             |
    59 |    0, if success, -1 and errno if failed                                  |
    60 \*=========================================================================*/
    61 {
    62   int rc = 0;
    63   char *tok_buffer = NULL;
    64   char *token = NULL;
    65   int    token_len;
    66   size_t total_len;
    67   IMFS_token_types token_type;
    68   struct stat file_info;
    69   /*
    70    * allocate temp memory to rebuild path name
    71    */
    72   tok_buffer = calloc(strlen(mount_point)+1,sizeof(char));
    73   if ( !tok_buffer )
    74     return -1;
    75   token = tok_buffer;
    76   total_len = 0;
    77   do {
    78     /*
    79      * scan through given string, one segment at a time
    80      */
    81     token_type = IMFS_get_token(
    82       mount_point+total_len,
    83       strlen(mount_point+total_len),
    84       token,
    85       &token_len
    86     );
    87     total_len += token_len;
    88     strncpy(tok_buffer,mount_point,total_len);
    89     tok_buffer[total_len] = '\0';
    90 
    91     if ((token_type != IMFS_NO_MORE_PATH) &&
    92         (token_type != IMFS_CURRENT_DIR)  &&
    93         (token_type != IMFS_INVALID_TOKEN)) {
    94       /*
    95        * check, whether segment exists
    96        */
    97       if (0 != stat(tok_buffer,&file_info)) {
    98         /*
    99          * if not, create directory
    100          */
    101         rc = mknod(tok_buffer,S_IRWXU | S_IRWXG | S_IRWXO | S_IFDIR,0);
    102       }
    103     }
    104   } while ((rc == 0) &&
    105            (token_type != IMFS_NO_MORE_PATH) &&
    106            (token_type != IMFS_INVALID_TOKEN));
    107 
    108   /*
    109    * return token buffer to heap. Verified to be non-NULL when calloc'ed.
    110    */
    111   free(tok_buffer);
    112   return rc;
    113 }
    11442
    11543/*=========================================================================*\
     
    14977     */
    15078    if (tmp_rc == 0) {
    151       tmp_rc = rtems_fsmount_create_mount_point(fstab_ptr->target);
     79      tmp_rc = rtems_mkdir(fstab_ptr->target, S_IRWXU | S_IRWXG | S_IRWXO);
    15280      if (tmp_rc != 0) {
    15381        if (0 != (fstab_ptr->report_reasons & FSMOUNT_MNTPNT_CRTERR)) {
  • cpukit/libmisc/fsmount/fsmount.h

    r241f4c96 reaee27b  
    122122
    123123/**
    124  * Creates the mount point with path @a mount_point.
    125  *
    126  * On success, zero is returned.  On error, -1 is returned, and @c errno is set
    127  * appropriately.
    128  *
    129  * @see rtems_fsmount().
    130  */
    131 int rtems_fsmount_create_mount_point(const char *mount_point);
    132 
    133 /**
    134124 * Mounts the file systems listed in the file system mount table @a fstab of
    135125 * size @a size.
     
    138128 * In case of an abort condition the corresponding table index will be reported
    139129 * in @a abort_index.  The pointer @a abort_index may be @c NULL.  The mount
    140  * point paths will be created with rtems_fsmount_create_mount_point() and need
    141  * not exist beforehand.
     130 * point paths will be created with rtems_mkdir() and need not exist
     131 * beforehand.
    142132 *
    143133 * On success, zero is returned.  On error, -1 is returned, and @c errno is set
  • cpukit/libnetworking/rtems/mkrootfs.c

    r241f4c96 reaee27b  
    6969
    7070/*
    71  * Build a path. Taken from the BSD `mkdir' command.
    72  */
    73 
    74 int
    75 rtems_rootfs_mkdir (const char *path_orig, mode_t omode)
    76 {
    77   struct stat sb;
    78   mode_t      numask, oumask;
    79   int         first, last, retval;
    80   char        path[128];
    81   char        *p = path;
    82 
    83   if (strlen (path_orig) >= sizeof path)
    84   {
    85     printf ("root fs: mkdir path too long `%s'\n", path);
    86     return -1;
    87   }
    88 
    89   strcpy (path, path_orig);
    90   oumask = 0;
    91   retval = 0;
    92   if (p[0] == '/')    /* Skip leading '/'. */
    93     ++p;
    94   for (first = 1, last = 0; !last ; ++p)
    95   {
    96     if (p[0] == '\0')
    97       last = 1;
    98     else if (p[0] != '/')
    99       continue;
    100     *p = '\0';
    101     if (p[1] == '\0')
    102       last = 1;
    103     if (first)
    104     {
    105       /*
    106        * POSIX 1003.2:
    107        * For each dir operand that does not name an existing
    108        * directory, effects equivalent to those cased by the
    109        * following command shall occcur:
    110        *
    111        * mkdir -p -m $(umask -S),u+wx $(dirname dir) &&
    112        *    mkdir [-m mode] dir
    113        *
    114        * We change the user's umask and then restore it,
    115        * instead of doing chmod's.
    116        */
    117       oumask = umask(0);
    118       numask = oumask & ~(S_IWUSR | S_IXUSR);
    119       umask(numask);
    120       first = 0;
    121     }
    122     if (last)
    123       umask(oumask);
    124     if (stat(path, &sb))
    125     {
    126       if (errno != ENOENT)
    127       {
    128         printf ("root fs: error stat'ing path `%s', %s\n",
    129                 path, strerror (errno));
    130         retval = 1;
    131         break;
    132       }
    133       if (mkdir(path, last ? omode : S_IRWXU | S_IRWXG | S_IRWXO) < 0)
    134       {
    135         printf ("root fs: error building path `%s', %s\n",
    136                 path, strerror (errno));
    137         retval = 1;
    138         break;
    139       }
    140     }
    141     else if ((sb.st_mode & S_IFMT) != S_IFDIR)
    142     {
    143       if (last)
    144         errno = EEXIST;
    145       else
    146         errno = ENOTDIR;
    147       printf ("root fs: path `%s' contains a file, %s\n",
    148               path, strerror (errno));
    149       retval = 1;
    150       break;
    151     }
    152     if (!last)
    153       *p = '/';
    154   }
    155   if (!first && !last)
    156     umask(oumask);
    157   return retval;
    158 }
    159 
    160 /*
    16171 * Create enough files to support the networking stack.
    16272 * Points to a table of strings.
     
    206116          path[i] = '\0';
    207117
    208           if (rtems_rootfs_mkdir (path, MKDIR_MODE))
     118          if (rtems_mkdir (path, MKDIR_MODE))
    209119            return -1;
    210120          break;
     
    311221       i < (sizeof (default_directories) / sizeof (rtems_rootfs_dir_table));
    312222       i++)
    313     if (rtems_rootfs_mkdir (default_directories[i].name,
     223    if (rtems_mkdir (default_directories[i].name,
    314224                            default_directories[i].mode))
    315225      return -1;
  • cpukit/libnetworking/rtems/mkrootfs.h

    r241f4c96 reaee27b  
    3030
    3131#include <rtems.h>
    32 
    33 /*
    34  *  Builds the complete path, like "mkdir -p".
    35  */
    36 
    37 int
    38 rtems_rootfs_mkdir (const char *path, mode_t omode);
    3932
    4033/*
Note: See TracChangeset for help on using the changeset viewer.