diff options
author | Joel Sherrill <joel.sherrill@OARcorp.com> | 1999-02-05 00:28:43 +0000 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@OARcorp.com> | 1999-02-05 00:28:43 +0000 |
commit | 2f87c84349248bf105de731c17cdf75d0050219a (patch) | |
tree | d88c1b261e2fb14ff1cba1e16a7245381765ed19 /c/src/exec/libcsupport/src | |
parent | Added optional data and instruction caching enable calls. (diff) | |
download | rtems-2f87c84349248bf105de731c17cdf75d0050219a.tar.bz2 |
Corrected spacing and added some new error checks that were needed
to avoid dereferencing NULLs.
Diffstat (limited to 'c/src/exec/libcsupport/src')
-rw-r--r-- | c/src/exec/libcsupport/src/mount.c | 36 | ||||
-rw-r--r-- | c/src/exec/libcsupport/src/open.c | 4 |
2 files changed, 25 insertions, 15 deletions
diff --git a/c/src/exec/libcsupport/src/mount.c b/c/src/exec/libcsupport/src/mount.c index fa8cebc3f9..9b42c78118 100644 --- a/c/src/exec/libcsupport/src/mount.c +++ b/c/src/exec/libcsupport/src/mount.c @@ -101,20 +101,25 @@ int mount( /* XXX add code to check for required operations */ /* - * Are the file system options valid? + * Is there a file system operations table? */ - options = get_file_system_options( fsoptions ); - if ( options == RTEMS_FILESYSTEM_BAD_OPTIONS ){ + if ( fs_ops == NULL ) { errno = EINVAL; return -1; } /* - * Is the file system type valid? + * Are the file system options valid? */ - if ( fs_ops == NULL ){ + if ( fsoptions == NULL ) { + errno = EINVAL; + return -1; + } + + options = get_file_system_options( fsoptions ); + if ( options == RTEMS_FILESYSTEM_BAD_OPTIONS ) { errno = EINVAL; return -1; } @@ -125,12 +130,17 @@ int mount( temp_mt_entry = malloc( sizeof(rtems_filesystem_mount_table_entry_t) ); + if ( !temp_mt_entry ) { + errno = ENOMEM; + return -1; + } + temp_mt_entry->mt_fs_root.mt_entry = temp_mt_entry; temp_mt_entry->options = options; - if( device ) - sprintf( temp_mt_entry->dev, "%s", device ); + if ( device ) + sprintf( temp_mt_entry->dev, "%s", device ); else - temp_mt_entry->dev = 0; + temp_mt_entry->dev = 0; /* * The mount_point should be a directory with read/write/execute @@ -149,7 +159,7 @@ int mount( * Test to see if it is a directory */ - if ( temp_loc.ops->node_type( &temp_loc ) != RTEMS_FILESYSTEM_DIRECTORY ){ + if ( temp_loc.ops->node_type( &temp_loc ) != RTEMS_FILESYSTEM_DIRECTORY ) { errno = ENOTDIR; goto cleanup_and_bail; } @@ -158,7 +168,7 @@ int mount( * You can only mount one file system onto a single mount point. */ - if ( search_mt_for_mount_point( &temp_loc ) == FOUND ){ + if ( search_mt_for_mount_point( &temp_loc ) == FOUND ) { errno = EBUSY; goto cleanup_and_bail; } @@ -179,8 +189,8 @@ int mount( */ if ( !temp_loc.ops->mount ){ - errno = ENOTSUP; - goto cleanup_and_bail; + errno = ENOTSUP; + goto cleanup_and_bail; } if ( temp_loc.ops->mount( temp_mt_entry ) ) { @@ -282,7 +292,7 @@ int search_mt_for_mount_point( rtems_filesystem_location_info_t *location_of_mount_point ) { - Chain_Node *the_node; + Chain_Node *the_node; rtems_filesystem_mount_table_entry_t *the_mount_entry; for ( the_node = rtems_filesystem_mount_table_control.first; diff --git a/c/src/exec/libcsupport/src/open.c b/c/src/exec/libcsupport/src/open.c index 4cdf5acf35..32fd4076e6 100644 --- a/c/src/exec/libcsupport/src/open.c +++ b/c/src/exec/libcsupport/src/open.c @@ -102,9 +102,9 @@ int open( /* * See if the file exists. */ - - status = rtems_filesystem_evaluate_path( pathname, eval_flags, &temp_loc, TRUE ); + status = rtems_filesystem_evaluate_path( + pathname, eval_flags, &temp_loc, TRUE ); if ( status == -1 ) { if ( errno != ENOENT ) { |