diff options
author | Thomas Doerfler <Thomas.Doerfler@embedded-brains.de> | 2008-05-27 10:34:15 +0000 |
---|---|---|
committer | Thomas Doerfler <Thomas.Doerfler@embedded-brains.de> | 2008-05-27 10:34:15 +0000 |
commit | bf95ccb5068543b453c1dfbf5e8ae7b6c814e1e4 (patch) | |
tree | e1ce92224d77dd59b5d6227c2c800c19d90ae605 /cpukit/libfs/src | |
parent | Bugfix: Moved definition of ppp_softc into source file. (diff) | |
download | rtems-bf95ccb5068543b453c1dfbf5e8ae7b6c814e1e4.tar.bz2 |
Added const qualifier to various pointers and data tables to
reduce size of data area.
IMFS: Fixed creation of symbolic links to avoid a compiler warning.
DOSFS: Use LibBlock instead of read() to read the boot record.
Diffstat (limited to '')
-rw-r--r-- | cpukit/libfs/src/dosfs/fat.c | 22 | ||||
-rw-r--r-- | cpukit/libfs/src/dosfs/msdos.h | 36 | ||||
-rw-r--r-- | cpukit/libfs/src/dosfs/msdos_handlers_dir.c | 2 | ||||
-rw-r--r-- | cpukit/libfs/src/dosfs/msdos_handlers_file.c | 2 | ||||
-rw-r--r-- | cpukit/libfs/src/dosfs/msdos_init.c | 2 | ||||
-rw-r--r-- | cpukit/libfs/src/dosfs/msdos_initsupp.c | 8 | ||||
-rw-r--r-- | cpukit/libfs/src/imfs/deviceio.c | 2 | ||||
-rw-r--r-- | cpukit/libfs/src/imfs/imfs.h | 40 | ||||
-rw-r--r-- | cpukit/libfs/src/imfs/imfs_config.c | 2 | ||||
-rw-r--r-- | cpukit/libfs/src/imfs/imfs_creat.c | 15 | ||||
-rw-r--r-- | cpukit/libfs/src/imfs/imfs_getchild.c | 4 | ||||
-rw-r--r-- | cpukit/libfs/src/imfs/imfs_handlers_device.c | 2 | ||||
-rw-r--r-- | cpukit/libfs/src/imfs/imfs_handlers_directory.c | 2 | ||||
-rw-r--r-- | cpukit/libfs/src/imfs/imfs_handlers_link.c | 2 | ||||
-rw-r--r-- | cpukit/libfs/src/imfs/imfs_handlers_memfile.c | 2 | ||||
-rw-r--r-- | cpukit/libfs/src/imfs/imfs_init.c | 2 | ||||
-rw-r--r-- | cpukit/libfs/src/imfs/imfs_initsupp.c | 8 | ||||
-rw-r--r-- | cpukit/libfs/src/imfs/imfs_symlink.c | 17 | ||||
-rw-r--r-- | cpukit/libfs/src/imfs/imfs_unixstub.c | 4 | ||||
-rw-r--r-- | cpukit/libfs/src/imfs/miniimfs_init.c | 2 |
20 files changed, 94 insertions, 82 deletions
diff --git a/cpukit/libfs/src/dosfs/fat.c b/cpukit/libfs/src/dosfs/fat.c index aa390d64cb..65bf30e624 100644 --- a/cpukit/libfs/src/dosfs/fat.c +++ b/cpukit/libfs/src/dosfs/fat.c @@ -205,6 +205,7 @@ fat_cluster_write( int fat_init_volume_info(rtems_filesystem_mount_table_entry_t *mt_entry) { + rtems_status_code sc = RTEMS_SUCCESSFUL; int rc = RC_OK; fat_fs_info_t *fs_info = mt_entry->fs_info; register fat_vol_t *vol = &fs_info->vol; @@ -212,9 +213,9 @@ fat_init_volume_info(rtems_filesystem_mount_table_entry_t *mt_entry) char boot_rec[FAT_MAX_BPB_SIZE]; char fs_info_sector[FAT_USEFUL_INFO_SIZE]; ssize_t ret = 0; - int fd; struct stat stat_buf; int i = 0; + bdbuf_buffer *block = NULL; rc = stat(mt_entry->dev, &stat_buf); if (rc == -1) @@ -231,22 +232,25 @@ fat_init_volume_info(rtems_filesystem_mount_table_entry_t *mt_entry) vol->dev = stat_buf.st_dev; - fd = open(mt_entry->dev, O_RDONLY); - if (fd == -1) + /* Read boot record */ + /* FIXME: Asserts FAT_MAX_BPB_SIZE < bdbuf block size */ + sc = rtems_bdbuf_read( vol->dev, 0, &block); + if (sc != RTEMS_SUCCESSFUL) { rtems_disk_release(vol->dd); - return -1; + set_errno_and_return_minus_one( EIO); } - ret = read(fd, (void *)boot_rec, FAT_MAX_BPB_SIZE); - if ( ret != FAT_MAX_BPB_SIZE ) + memcpy( boot_rec, block->buffer, FAT_MAX_BPB_SIZE); + + sc = rtems_bdbuf_release( block); + if (sc != RTEMS_SUCCESSFUL) { - close(fd); rtems_disk_release(vol->dd); - set_errno_and_return_minus_one( EIO ); + set_errno_and_return_minus_one( EIO); } - close(fd); + /* Evaluate boot record */ vol->bps = FAT_GET_BR_BYTES_PER_SECTOR(boot_rec); if ( (vol->bps != 512) && diff --git a/cpukit/libfs/src/dosfs/msdos.h b/cpukit/libfs/src/dosfs/msdos.h index 2fec769446..050b283863 100644 --- a/cpukit/libfs/src/dosfs/msdos.h +++ b/cpukit/libfs/src/dosfs/msdos.h @@ -37,18 +37,18 @@ typedef struct msdos_fs_info_s * volume * description */ - rtems_filesystem_file_handlers_r *directory_handlers; /* - * a set of routines - * that handles the - * nodes of directory - * type - */ - rtems_filesystem_file_handlers_r *file_handlers; /* - * a set of routines - * that handles the - * nodes of file - * type - */ + const rtems_filesystem_file_handlers_r *directory_handlers; /* + * a set of routines + * that handles the + * nodes of directory + * type + */ + const rtems_filesystem_file_handlers_r *file_handlers; /* + * a set of routines + * that handles the + * nodes of file + * type + */ rtems_id vol_sema; /* * semaphore * associated with @@ -61,10 +61,10 @@ typedef struct msdos_fs_info_s } msdos_fs_info_t; /* a set of routines that handle the nodes which are directories */ -extern rtems_filesystem_file_handlers_r msdos_dir_handlers; +extern const rtems_filesystem_file_handlers_r msdos_dir_handlers; /* a set of routines that handle the nodes which are files */ -extern rtems_filesystem_file_handlers_r msdos_file_handlers; +extern const rtems_filesystem_file_handlers_r msdos_file_handlers; /* Volume semaphore timeout value. This value can be changed to a number * of ticks to help debugging or if you need such a */ @@ -231,10 +231,10 @@ int msdos_utime( ); int msdos_initialize_support( - rtems_filesystem_mount_table_entry_t *temp_mt_entry, - rtems_filesystem_operations_table *op_table, - rtems_filesystem_file_handlers_r *file_handlers, - rtems_filesystem_file_handlers_r *directory_handlers + rtems_filesystem_mount_table_entry_t *temp_mt_entry, + const rtems_filesystem_operations_table *op_table, + const rtems_filesystem_file_handlers_r *file_handlers, + const rtems_filesystem_file_handlers_r *directory_handlers ); int msdos_file_open( diff --git a/cpukit/libfs/src/dosfs/msdos_handlers_dir.c b/cpukit/libfs/src/dosfs/msdos_handlers_dir.c index 4a6d098b8e..e42f72ab16 100644 --- a/cpukit/libfs/src/dosfs/msdos_handlers_dir.c +++ b/cpukit/libfs/src/dosfs/msdos_handlers_dir.c @@ -18,7 +18,7 @@ #include <rtems/libio.h> #include "msdos.h" -rtems_filesystem_file_handlers_r msdos_dir_handlers = { +const rtems_filesystem_file_handlers_r msdos_dir_handlers = { msdos_dir_open, msdos_dir_close, msdos_dir_read, diff --git a/cpukit/libfs/src/dosfs/msdos_handlers_file.c b/cpukit/libfs/src/dosfs/msdos_handlers_file.c index 857c5ad7a6..6ad6d1850d 100644 --- a/cpukit/libfs/src/dosfs/msdos_handlers_file.c +++ b/cpukit/libfs/src/dosfs/msdos_handlers_file.c @@ -18,7 +18,7 @@ #include <rtems/libio.h> #include "msdos.h" -rtems_filesystem_file_handlers_r msdos_file_handlers = { +const rtems_filesystem_file_handlers_r msdos_file_handlers = { msdos_file_open, msdos_file_close, msdos_file_read, diff --git a/cpukit/libfs/src/dosfs/msdos_init.c b/cpukit/libfs/src/dosfs/msdos_init.c index d5d61d9103..8642cead0a 100644 --- a/cpukit/libfs/src/dosfs/msdos_init.c +++ b/cpukit/libfs/src/dosfs/msdos_init.c @@ -18,7 +18,7 @@ #include <rtems/libio_.h> #include "msdos.h" -rtems_filesystem_operations_table msdos_ops = { +const rtems_filesystem_operations_table msdos_ops = { msdos_eval_path, msdos_eval4make, #if 0 diff --git a/cpukit/libfs/src/dosfs/msdos_initsupp.c b/cpukit/libfs/src/dosfs/msdos_initsupp.c index 73a76f00c3..ce86fa22b0 100644 --- a/cpukit/libfs/src/dosfs/msdos_initsupp.c +++ b/cpukit/libfs/src/dosfs/msdos_initsupp.c @@ -47,10 +47,10 @@ */ int msdos_initialize_support( - rtems_filesystem_mount_table_entry_t *temp_mt_entry, - rtems_filesystem_operations_table *op_table, - rtems_filesystem_file_handlers_r *file_handlers, - rtems_filesystem_file_handlers_r *directory_handlers + rtems_filesystem_mount_table_entry_t *temp_mt_entry, + const rtems_filesystem_operations_table *op_table, + const rtems_filesystem_file_handlers_r *file_handlers, + const rtems_filesystem_file_handlers_r *directory_handlers ) { int rc = RC_OK; diff --git a/cpukit/libfs/src/imfs/deviceio.c b/cpukit/libfs/src/imfs/deviceio.c index 8c44e0a223..05edf454f7 100644 --- a/cpukit/libfs/src/imfs/deviceio.c +++ b/cpukit/libfs/src/imfs/deviceio.c @@ -29,7 +29,7 @@ * Convert RTEMS status to a UNIX errno */ -rtems_assoc_t errno_assoc[] = { +const rtems_assoc_t errno_assoc[] = { { "OK", RTEMS_SUCCESSFUL, 0 }, { "BUSY", RTEMS_RESOURCE_IN_USE, EBUSY }, { "INVALID NAME", RTEMS_INVALID_NAME, EINVAL }, diff --git a/cpukit/libfs/src/imfs/imfs.h b/cpukit/libfs/src/imfs/imfs.h index 2f69537b83..ae1839b3f7 100644 --- a/cpukit/libfs/src/imfs/imfs.h +++ b/cpukit/libfs/src/imfs/imfs.h @@ -56,7 +56,7 @@ typedef struct { } IMFS_link_t; typedef struct { - const char *name; + char *name; } IMFS_sym_link_t; /* @@ -205,9 +205,9 @@ struct IMFS_jnode_tt { } while (0) typedef struct { - ino_t ino_count; - rtems_filesystem_file_handlers_r *memfile_handlers; - rtems_filesystem_file_handlers_r *directory_handlers; + ino_t ino_count; + const rtems_filesystem_file_handlers_r *memfile_handlers; + const rtems_filesystem_file_handlers_r *directory_handlers; } IMFS_fs_info_t; /* @@ -226,13 +226,13 @@ typedef enum { * Shared Data */ -extern rtems_filesystem_file_handlers_r IMFS_directory_handlers; -extern rtems_filesystem_file_handlers_r IMFS_device_handlers; -extern rtems_filesystem_file_handlers_r IMFS_link_handlers; -extern rtems_filesystem_file_handlers_r IMFS_memfile_handlers; -extern rtems_filesystem_operations_table IMFS_ops; -extern rtems_filesystem_operations_table miniIMFS_ops; -extern rtems_filesystem_limits_and_options_t IMFS_LIMITS_AND_OPTIONS; +extern const rtems_filesystem_file_handlers_r IMFS_directory_handlers; +extern const rtems_filesystem_file_handlers_r IMFS_device_handlers; +extern const rtems_filesystem_file_handlers_r IMFS_link_handlers; +extern const rtems_filesystem_file_handlers_r IMFS_memfile_handlers; +extern const rtems_filesystem_operations_table IMFS_ops; +extern const rtems_filesystem_operations_table miniIMFS_ops; +extern const rtems_filesystem_limits_and_options_t IMFS_LIMITS_AND_OPTIONS; /* * Routines @@ -247,10 +247,10 @@ int miniIMFS_initialize( ); int IMFS_initialize_support( - rtems_filesystem_mount_table_entry_t *mt_entry, - rtems_filesystem_operations_table *op_table, - rtems_filesystem_file_handlers_r *memfile_handlers, - rtems_filesystem_file_handlers_r *directory_handlers + rtems_filesystem_mount_table_entry_t *mt_entry, + const rtems_filesystem_operations_table *op_table, + const rtems_filesystem_file_handlers_r *memfile_handlers, + const rtems_filesystem_file_handlers_r *directory_handlers ); int IMFS_fsunmount( @@ -340,11 +340,11 @@ int IMFS_mknod( ); IMFS_jnode_t *IMFS_create_node( - rtems_filesystem_location_info_t *parent_loc, /* IN */ - IMFS_jnode_types_t type, /* IN */ - char *name, /* IN */ - mode_t mode, /* IN */ - IMFS_types_union *info /* IN */ + rtems_filesystem_location_info_t *parent_loc, /* IN */ + IMFS_jnode_types_t type, /* IN */ + const char *name, /* IN */ + mode_t mode, /* IN */ + const IMFS_types_union *info /* IN */ ); int IMFS_evaluate_for_make( diff --git a/cpukit/libfs/src/imfs/imfs_config.c b/cpukit/libfs/src/imfs/imfs_config.c index 20da389fa2..78f947e81f 100644 --- a/cpukit/libfs/src/imfs/imfs_config.c +++ b/cpukit/libfs/src/imfs/imfs_config.c @@ -19,7 +19,7 @@ /* XXX this structure should use real constants */ -rtems_filesystem_limits_and_options_t IMFS_LIMITS_AND_OPTIONS = { +const rtems_filesystem_limits_and_options_t IMFS_LIMITS_AND_OPTIONS = { 5, /* link_max */ 6, /* max_canon */ 7, /* max_input */ diff --git a/cpukit/libfs/src/imfs/imfs_creat.c b/cpukit/libfs/src/imfs/imfs_creat.c index 94d9dac9c1..1eaea0b384 100644 --- a/cpukit/libfs/src/imfs/imfs_creat.c +++ b/cpukit/libfs/src/imfs/imfs_creat.c @@ -24,18 +24,17 @@ #include <rtems/libio_.h> IMFS_jnode_t *IMFS_create_node( - rtems_filesystem_location_info_t *parent_loc, - IMFS_jnode_types_t type, - char *name, - mode_t mode, - IMFS_types_union *info + rtems_filesystem_location_info_t *parent_loc, + IMFS_jnode_types_t type, + const char *name, + mode_t mode, + const IMFS_types_union *info ) { IMFS_jnode_t *node; struct timeval tv; IMFS_jnode_t *parent = NULL; IMFS_fs_info_t *fs_info; - char *sym_name; if ( parent_loc != NULL ) parent = parent_loc->node_access; @@ -94,9 +93,7 @@ IMFS_jnode_t *IMFS_create_node( break; case IMFS_SYM_LINK: - sym_name = calloc( 1, strlen( info->sym_link.name ) + 1 ); - strcpy( sym_name, info->sym_link.name ); - node->info.sym_link.name = sym_name; + node->info.sym_link.name = info->sym_link.name; break; case IMFS_DEVICE: diff --git a/cpukit/libfs/src/imfs/imfs_getchild.c b/cpukit/libfs/src/imfs/imfs_getchild.c index 67663db8ea..0c29516dd7 100644 --- a/cpukit/libfs/src/imfs/imfs_getchild.c +++ b/cpukit/libfs/src/imfs/imfs_getchild.c @@ -22,8 +22,8 @@ #include <string.h> #include "imfs.h" -static char dotname[2] = "."; -static char dotdotname[3] = ".."; +static const char dotname[2] = "."; +static const char dotdotname[3] = ".."; IMFS_jnode_t *IMFS_find_match_in_dir( IMFS_jnode_t *directory, diff --git a/cpukit/libfs/src/imfs/imfs_handlers_device.c b/cpukit/libfs/src/imfs/imfs_handlers_device.c index fa373b8b91..a1ed7ab912 100644 --- a/cpukit/libfs/src/imfs/imfs_handlers_device.c +++ b/cpukit/libfs/src/imfs/imfs_handlers_device.c @@ -23,7 +23,7 @@ * Handler table for IMFS device nodes */ -rtems_filesystem_file_handlers_r IMFS_device_handlers = { +const rtems_filesystem_file_handlers_r IMFS_device_handlers = { device_open, device_close, device_read, diff --git a/cpukit/libfs/src/imfs/imfs_handlers_directory.c b/cpukit/libfs/src/imfs/imfs_handlers_directory.c index b9453a0725..18ec588876 100644 --- a/cpukit/libfs/src/imfs/imfs_handlers_directory.c +++ b/cpukit/libfs/src/imfs/imfs_handlers_directory.c @@ -23,7 +23,7 @@ * Set of operations handlers for operations on directories. */ -rtems_filesystem_file_handlers_r IMFS_directory_handlers = { +const rtems_filesystem_file_handlers_r IMFS_directory_handlers = { imfs_dir_open, imfs_dir_close, imfs_dir_read, diff --git a/cpukit/libfs/src/imfs/imfs_handlers_link.c b/cpukit/libfs/src/imfs/imfs_handlers_link.c index f4b926dcab..038da475fc 100644 --- a/cpukit/libfs/src/imfs/imfs_handlers_link.c +++ b/cpukit/libfs/src/imfs/imfs_handlers_link.c @@ -23,7 +23,7 @@ * Handler table for IMFS device nodes */ -rtems_filesystem_file_handlers_r IMFS_link_handlers = { +const rtems_filesystem_file_handlers_r IMFS_link_handlers = { NULL, /* open */ NULL, /* close */ NULL, /* read */ diff --git a/cpukit/libfs/src/imfs/imfs_handlers_memfile.c b/cpukit/libfs/src/imfs/imfs_handlers_memfile.c index 1db049b504..3b765f0149 100644 --- a/cpukit/libfs/src/imfs/imfs_handlers_memfile.c +++ b/cpukit/libfs/src/imfs/imfs_handlers_memfile.c @@ -23,7 +23,7 @@ * Set of operations handlers for operations on memfile entities. */ -rtems_filesystem_file_handlers_r IMFS_memfile_handlers = { +const rtems_filesystem_file_handlers_r IMFS_memfile_handlers = { memfile_open, memfile_close, memfile_read, diff --git a/cpukit/libfs/src/imfs/imfs_init.c b/cpukit/libfs/src/imfs/imfs_init.c index 4ed08bd500..81091bc936 100644 --- a/cpukit/libfs/src/imfs/imfs_init.c +++ b/cpukit/libfs/src/imfs/imfs_init.c @@ -33,7 +33,7 @@ * IMFS file system operations table */ -rtems_filesystem_operations_table IMFS_ops = { +const rtems_filesystem_operations_table IMFS_ops = { IMFS_eval_path, IMFS_evaluate_for_make, IMFS_link, diff --git a/cpukit/libfs/src/imfs/imfs_initsupp.c b/cpukit/libfs/src/imfs/imfs_initsupp.c index 29b014d374..05f7ab768a 100644 --- a/cpukit/libfs/src/imfs/imfs_initsupp.c +++ b/cpukit/libfs/src/imfs/imfs_initsupp.c @@ -66,10 +66,10 @@ static int IMFS_determine_bytes_per_block( */ int IMFS_initialize_support( - rtems_filesystem_mount_table_entry_t *temp_mt_entry, - rtems_filesystem_operations_table *op_table, - rtems_filesystem_file_handlers_r *memfile_handlers, - rtems_filesystem_file_handlers_r *directory_handlers + rtems_filesystem_mount_table_entry_t *temp_mt_entry, + const rtems_filesystem_operations_table *op_table, + const rtems_filesystem_file_handlers_r *memfile_handlers, + const rtems_filesystem_file_handlers_r *directory_handlers ) { IMFS_fs_info_t *fs_info; diff --git a/cpukit/libfs/src/imfs/imfs_symlink.c b/cpukit/libfs/src/imfs/imfs_symlink.c index 38072b9f69..e946f3dc66 100644 --- a/cpukit/libfs/src/imfs/imfs_symlink.c +++ b/cpukit/libfs/src/imfs/imfs_symlink.c @@ -20,6 +20,8 @@ #endif #include <errno.h> +#include <string.h> +#include <stdlib.h> #include "imfs.h" #include <rtems/libio_.h> #include <rtems/seterr.h> @@ -41,7 +43,14 @@ int IMFS_symlink( IMFS_get_token( node_name, new_name, &i ); - info.sym_link.name = link_name; + /* + * Duplicate link name + */ + + info.sym_link.name = strdup( link_name); + if (info.sym_link.name == NULL) { + rtems_set_errno_and_return_minus_one( ENOMEM); + } /* * Create a new link node. @@ -55,8 +64,10 @@ int IMFS_symlink( &info ); - if ( !new_node ) - rtems_set_errno_and_return_minus_one( ENOMEM ); + if (new_node == NULL) { + free( info.sym_link.name); + rtems_set_errno_and_return_minus_one( ENOMEM); + } return 0; } diff --git a/cpukit/libfs/src/imfs/imfs_unixstub.c b/cpukit/libfs/src/imfs/imfs_unixstub.c index d642b260d5..47943040bb 100644 --- a/cpukit/libfs/src/imfs/imfs_unixstub.c +++ b/cpukit/libfs/src/imfs/imfs_unixstub.c @@ -31,7 +31,7 @@ * IMFS file system operations table */ -rtems_filesystem_operations_table IMFS_ops = { +const rtems_filesystem_operations_table IMFS_ops = { NULL, NULL, NULL, @@ -54,7 +54,7 @@ rtems_filesystem_operations_table IMFS_ops = { * IMFS file system operations table */ -rtems_filesystem_operations_table miniIMFS_ops = { +const rtems_filesystem_operations_table miniIMFS_ops = { NULL, NULL, NULL, diff --git a/cpukit/libfs/src/imfs/miniimfs_init.c b/cpukit/libfs/src/imfs/miniimfs_init.c index fdf2310cf3..15ca663429 100644 --- a/cpukit/libfs/src/imfs/miniimfs_init.c +++ b/cpukit/libfs/src/imfs/miniimfs_init.c @@ -33,7 +33,7 @@ * miniIMFS file system operations table */ -rtems_filesystem_operations_table miniIMFS_ops = { +const rtems_filesystem_operations_table miniIMFS_ops = { IMFS_eval_path, IMFS_evaluate_for_make, NULL, /* XXX IMFS_link, */ |