summaryrefslogtreecommitdiffstats
path: root/cpukit/libcsupport
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2010-08-02 18:24:15 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2010-08-02 18:24:15 +0000
commit2d08be11ddc0194e0b997ed5f82b306e6eed73ee (patch)
tree24b826abdb1ec9686525fe609d8c705d690c19e5 /cpukit/libcsupport
parent2010-07-30 Bharath Suri <bharath.s.jois@gmail.com> (diff)
downloadrtems-2d08be11ddc0194e0b997ed5f82b306e6eed73ee.tar.bz2
2010-08-02 Joel Sherrill <joel.sherrill@oarcorp.com>
* libcsupport/src/base_fs.c, libcsupport/src/rtems_mkdir.c: Formatting.
Diffstat (limited to 'cpukit/libcsupport')
-rw-r--r--cpukit/libcsupport/src/base_fs.c2
-rw-r--r--cpukit/libcsupport/src/rtems_mkdir.c142
2 files changed, 71 insertions, 73 deletions
diff --git a/cpukit/libcsupport/src/base_fs.c b/cpukit/libcsupport/src/base_fs.c
index e552769577..b5681eda63 100644
--- a/cpukit/libcsupport/src/base_fs.c
+++ b/cpukit/libcsupport/src/base_fs.c
@@ -48,14 +48,12 @@ void rtems_filesystem_initialize( void )
/*
* mount the first filesystem.
*/
-
if ( rtems_filesystem_mount_table_size == 0 )
rtems_fatal_error_occurred( 0xABCD0001 );
mt = &rtems_filesystem_mount_table[0];
status = mount( mt->device, mt->mount_point, mt->type, mt->fsoptions, NULL );
-
if ( status == -1 )
rtems_fatal_error_occurred( 0xABCD0002 );
diff --git a/cpukit/libcsupport/src/rtems_mkdir.c b/cpukit/libcsupport/src/rtems_mkdir.c
index d80f521300..86ef7e1b84 100644
--- a/cpukit/libcsupport/src/rtems_mkdir.c
+++ b/cpukit/libcsupport/src/rtems_mkdir.c
@@ -12,7 +12,7 @@
* Copyright (c) 2010 embedded brains GmbH.
*
* Copyright (c) 1983, 1992, 1993
- * The Regents of the University of California. All rights reserved.
+ * 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
@@ -60,82 +60,82 @@
static int
build(char *path, mode_t omode)
{
- struct stat sb;
- mode_t numask, oumask;
- int first, last, retval;
- char *p;
+ 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);
+ 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);
+ int success = 0;
+ char *dup_path = strdup(path);
- if (dup_path != NULL) {
- success = build(dup_path, mode);
- free(dup_path);
- }
+ if (dup_path != NULL) {
+ success = build(dup_path, mode);
+ free(dup_path);
+ }
- return success != 0 ? 0 : -1;
+ return success != 0 ? 0 : -1;
}