change log for rtems (2010-06-08)

rtems-vc at rtems.org rtems-vc at rtems.org
Tue Jun 8 13:11:20 UTC 2010


 *sh*:
2010-06-08	Sebastian Huber <sebastian.huber at 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().

M 1.2355  cpukit/ChangeLog
M    1.3  cpukit/libblock/src/bdpart-mount.c
M  1.120  cpukit/libcsupport/Makefile.am
M   1.67  cpukit/libcsupport/include/rtems/libio.h
A    1.1  cpukit/libcsupport/src/rtems_mkdir.c
M    1.6  cpukit/libfs/src/pipe/pipe.c
M    1.8  cpukit/libmisc/fsmount/fsmount.h
M   1.13  cpukit/libmisc/fsmount/fsmount.c
M    1.9  cpukit/libnetworking/rtems/mkrootfs.h
M   1.12  cpukit/libnetworking/rtems/mkrootfs.c

diff -u rtems/cpukit/ChangeLog:1.2354 rtems/cpukit/ChangeLog:1.2355
--- rtems/cpukit/ChangeLog:1.2354	Tue Jun  8 05:25:36 2010
+++ rtems/cpukit/ChangeLog	Tue Jun  8 07:59:50 2010
@@ -1,5 +1,17 @@
 2010-06-08	Sebastian Huber <sebastian.huber at 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 at 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 -u rtems/cpukit/libblock/src/bdpart-mount.c:1.2 rtems/cpukit/libblock/src/bdpart-mount.c:1.3
--- rtems/cpukit/libblock/src/bdpart-mount.c:1.2	Mon May 31 08:56:36 2010
+++ rtems/cpukit/libblock/src/bdpart-mount.c	Tue Jun  8 07:59:51 2010
@@ -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 @@
 
     /* 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 -u rtems/cpukit/libcsupport/Makefile.am:1.119 rtems/cpukit/libcsupport/Makefile.am:1.120
--- rtems/cpukit/libcsupport/Makefile.am:1.119	Mon Jun  7 09:57:31 2010
+++ rtems/cpukit/libcsupport/Makefile.am	Tue Jun  8 07:59:51 2010
@@ -46,7 +46,7 @@
 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 -u rtems/cpukit/libcsupport/include/rtems/libio.h:1.66 rtems/cpukit/libcsupport/include/rtems/libio.h:1.67
--- rtems/cpukit/libcsupport/include/rtems/libio.h:1.66	Mon Jun  7 10:35:24 2010
+++ rtems/cpukit/libcsupport/include/rtems/libio.h	Tue Jun  8 07:59:51 2010
@@ -735,6 +735,17 @@
 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 -u /dev/null rtems/cpukit/libcsupport/src/rtems_mkdir.c:1.1
--- /dev/null	Tue Jun  8 08:11:19 2010
+++ rtems/cpukit/libcsupport/src/rtems_mkdir.c	Tue Jun  8 08:05:11 2010
@@ -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;
+}

diff -u rtems/cpukit/libfs/src/pipe/pipe.c:1.5 rtems/cpukit/libfs/src/pipe/pipe.c:1.6
--- rtems/cpukit/libfs/src/pipe/pipe.c:1.5	Tue Jun  8 05:25:46 2010
+++ rtems/cpukit/libfs/src/pipe/pipe.c	Tue Jun  8 07:59:51 2010
@@ -30,20 +30,11 @@
   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 -u rtems/cpukit/libmisc/fsmount/fsmount.h:1.7 rtems/cpukit/libmisc/fsmount/fsmount.h:1.8
--- rtems/cpukit/libmisc/fsmount/fsmount.h:1.7	Mon May 31 08:56:37 2010
+++ rtems/cpukit/libmisc/fsmount/fsmount.h	Tue Jun  8 07:59:51 2010
@@ -121,24 +121,14 @@
 } 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 -u rtems/cpukit/libmisc/fsmount/fsmount.c:1.12 rtems/cpukit/libmisc/fsmount/fsmount.c:1.13
--- rtems/cpukit/libmisc/fsmount/fsmount.c:1.12	Mon May 31 08:56:37 2010
+++ rtems/cpukit/libmisc/fsmount/fsmount.c	Tue Jun  8 07:59:51 2010
@@ -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 @@
      * 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 -u rtems/cpukit/libnetworking/rtems/mkrootfs.h:1.8 rtems/cpukit/libnetworking/rtems/mkrootfs.h:1.9
--- rtems/cpukit/libnetworking/rtems/mkrootfs.h:1.8	Fri Aug  1 00:07:41 2008
+++ rtems/cpukit/libnetworking/rtems/mkrootfs.h	Tue Jun  8 07:59:51 2010
@@ -31,13 +31,6 @@
 #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.
  */

diff -u rtems/cpukit/libnetworking/rtems/mkrootfs.c:1.11 rtems/cpukit/libnetworking/rtems/mkrootfs.c:1.12
--- rtems/cpukit/libnetworking/rtems/mkrootfs.c:1.11	Sun Jan 31 18:03:01 2010
+++ rtems/cpukit/libnetworking/rtems/mkrootfs.c	Tue Jun  8 07:59:51 2010
@@ -68,96 +68,6 @@
 #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 @@
           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 @@
   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;
 



--

Generated by Deluxe Loginfo [http://www.codewiz.org/projects/index.html#loginfo] 2.122 by Bernardo Innocenti <bernie at develer.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/vc/attachments/20100608/f337e7c1/attachment-0001.html>


More information about the vc mailing list