From bf95ccb5068543b453c1dfbf5e8ae7b6c814e1e4 Mon Sep 17 00:00:00 2001 From: Thomas Doerfler Date: Tue, 27 May 2008 10:34:15 +0000 Subject: 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. --- cpukit/ChangeLog | 66 +++++++++++++++++++++++++ cpukit/include/rtems/fs.h | 8 +-- cpukit/libblock/include/rtems/diskdevs.h | 2 +- cpukit/libblock/src/diskdevs.c | 4 +- cpukit/libcsupport/include/rtems/libio.h | 42 ++++++++-------- cpukit/libcsupport/src/base_fs.c | 4 +- cpukit/libcsupport/src/error.c | 2 +- cpukit/libcsupport/src/libio.c | 4 +- cpukit/libcsupport/src/mount.c | 10 ++-- cpukit/libfs/src/dosfs/fat.c | 22 +++++---- cpukit/libfs/src/dosfs/msdos.h | 36 +++++++------- cpukit/libfs/src/dosfs/msdos_handlers_dir.c | 2 +- cpukit/libfs/src/dosfs/msdos_handlers_file.c | 2 +- cpukit/libfs/src/dosfs/msdos_init.c | 2 +- cpukit/libfs/src/dosfs/msdos_initsupp.c | 8 +-- cpukit/libfs/src/imfs/deviceio.c | 2 +- cpukit/libfs/src/imfs/imfs.h | 40 +++++++-------- cpukit/libfs/src/imfs/imfs_config.c | 2 +- cpukit/libfs/src/imfs/imfs_creat.c | 15 +++--- cpukit/libfs/src/imfs/imfs_getchild.c | 4 +- cpukit/libfs/src/imfs/imfs_handlers_device.c | 2 +- cpukit/libfs/src/imfs/imfs_handlers_directory.c | 2 +- cpukit/libfs/src/imfs/imfs_handlers_link.c | 2 +- cpukit/libfs/src/imfs/imfs_handlers_memfile.c | 2 +- cpukit/libfs/src/imfs/imfs_init.c | 2 +- cpukit/libfs/src/imfs/imfs_initsupp.c | 8 +-- cpukit/libfs/src/imfs/imfs_symlink.c | 17 +++++-- cpukit/libfs/src/imfs/imfs_unixstub.c | 4 +- cpukit/libfs/src/imfs/miniimfs_init.c | 2 +- cpukit/posix/include/rtems/posix/psignal.h | 2 +- cpukit/posix/src/psignal.c | 2 +- cpukit/rtems/include/rtems/rtems/status.h | 2 +- cpukit/rtems/src/semtranslatereturncode.c | 4 +- cpukit/sapi/include/confdefs.h | 6 +-- cpukit/sapi/include/rtems/io.h | 2 +- cpukit/sapi/src/ioregisterdriver.c | 2 +- cpukit/sapi/src/itronapi.c | 4 +- cpukit/sapi/src/posixapi.c | 4 +- 38 files changed, 212 insertions(+), 134 deletions(-) diff --git a/cpukit/ChangeLog b/cpukit/ChangeLog index b4379342f7..9cc1e2449c 100644 --- a/cpukit/ChangeLog +++ b/cpukit/ChangeLog @@ -1,3 +1,69 @@ + +2008-05-27 Sebastian Huber + + * score/include/rtems/score/object.h, + rtems/include/rtems/rtems/types.h: Added new defines OBJECTS_ID_NONE + and RTEMS_ID_NONE. No object can have this ID. + +2008-05-27 Sebastian Huber + + * include/rtems/fs.h, + libblock/include/rtems/diskdevs.h, + libblock/src/diskdevs.c, + libcsupport/include/rtems/libio.h, + libcsupport/src/base_fs.c, + libcsupport/src/error.c, + libcsupport/src/libio.c, + libcsupport/src/mount.c, + libfs/src/dosfs/fat.c, + libfs/src/dosfs/msdos.h, + libfs/src/dosfs/msdos_handlers_dir.c, + libfs/src/dosfs/msdos_handlers_file.c, + libfs/src/dosfs/msdos_init.c, + libfs/src/dosfs/msdos_initsupp.c, + libfs/src/imfs/deviceio.c, + libfs/src/imfs/imfs.h, + libfs/src/imfs/imfs_config.c, + libfs/src/imfs/imfs_creat.c, + libfs/src/imfs/imfs_getchild.c, + libfs/src/imfs/imfs_handlers_device.c, + libfs/src/imfs/imfs_handlers_directory.c, + libfs/src/imfs/imfs_handlers_link.c, + libfs/src/imfs/imfs_handlers_memfile.c, + libfs/src/imfs/imfs_init.c, + libfs/src/imfs/imfs_initsupp.c, + libfs/src/imfs/imfs_symlink.c, + libfs/src/imfs/imfs_unixstub.c, + libfs/src/imfs/miniimfs_init.c, + posix/include/rtems/posix/psignal.h, + posix/src/psignal.c, + rtems/include/rtems/rtems/status.h, + rtems/src/semtranslatereturncode.c, + sapi/include/confdefs.h, + sapi/include/rtems/io.h, + sapi/src/ioregisterdriver.c, + sapi/src/itronapi.c, + sapi/src/posixapi.c: + 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. + +2008-05-27 Sebastian Huber + + * libcsupport/include/console.h: + New define: CONSOLE_DEVICE_NAME. + +2008-05-27 Sebastian Huber + + * libcsupport/src/printk.c: + Bugfix: String output without width option. + +2008-05-27 Sebastian Huber + + * libnetworking/net/if_ppp.c, libnetworking/net/if_pppvar.h: + Bugfix: Moved definition of ppp_softc into source file. + 2008-05-23 Till Straumann * libnetworking/netinet/ip_output.c: when fragmenting diff --git a/cpukit/include/rtems/fs.h b/cpukit/include/rtems/fs.h index 6f4f54c259..01ae4ab28d 100644 --- a/cpukit/include/rtems/fs.h +++ b/cpukit/include/rtems/fs.h @@ -45,10 +45,10 @@ typedef struct _rtems_filesystem_operations_table struct rtems_filesystem_location_info_tt { - void *node_access; - rtems_filesystem_file_handlers_r *handlers; - rtems_filesystem_operations_table *ops; - rtems_filesystem_mount_table_entry_t *mt_entry; + void *node_access; + const rtems_filesystem_file_handlers_r *handlers; + const rtems_filesystem_operations_table *ops; + rtems_filesystem_mount_table_entry_t *mt_entry; }; #ifdef __cplusplus diff --git a/cpukit/libblock/include/rtems/diskdevs.h b/cpukit/libblock/include/rtems/diskdevs.h index eff763f9e0..6542d74775 100644 --- a/cpukit/libblock/include/rtems/diskdevs.h +++ b/cpukit/libblock/include/rtems/diskdevs.h @@ -85,7 +85,7 @@ typedef struct disk_device { rtems_status_code rtems_disk_create_phys(dev_t dev, int block_size, int disk_size, block_device_ioctl handler, - char *name); + const char *name); /* rtems_disk_create_log -- * Create logical disk entry. Logical disk is contiguous area on physical diff --git a/cpukit/libblock/src/diskdevs.c b/cpukit/libblock/src/diskdevs.c index 25b8287610..545a4096e7 100644 --- a/cpukit/libblock/src/diskdevs.c +++ b/cpukit/libblock/src/diskdevs.c @@ -171,7 +171,7 @@ get_disk_entry(dev_t dev) * no memory available). */ static rtems_status_code -create_disk(dev_t dev, char *name, disk_device **diskdev) +create_disk(dev_t dev, const char *name, disk_device **diskdev) { disk_device *dd; char *n; @@ -235,7 +235,7 @@ create_disk(dev_t dev, char *name, disk_device **diskdev) rtems_status_code rtems_disk_create_phys(dev_t dev, int block_size, int disk_size, block_device_ioctl handler, - char *name) + const char *name) { int bs_log2; int i; diff --git a/cpukit/libcsupport/include/rtems/libio.h b/cpukit/libcsupport/include/rtems/libio.h index 2a3fcaed49..baa2219352 100644 --- a/cpukit/libcsupport/include/rtems/libio.h +++ b/cpukit/libcsupport/include/rtems/libio.h @@ -345,16 +345,16 @@ typedef enum */ struct rtems_libio_tt { - rtems_driver_name_t *driver; - off_t size; /* size of file */ - off_t offset; /* current offset into file */ - uint32_t flags; - rtems_filesystem_location_info_t pathinfo; - rtems_id sem; - uint32_t data0; /* private to "driver" */ - void *data1; /* ... */ - void *file_info; /* used by file handlers */ - rtems_filesystem_file_handlers_r *handlers; /* type specific handlers */ + rtems_driver_name_t *driver; + off_t size; /* size of file */ + off_t offset; /* current offset into file */ + uint32_t flags; + rtems_filesystem_location_info_t pathinfo; + rtems_id sem; + uint32_t data0; /* private to "driver" */ + void *data1; /* ... */ + void *file_info; /* used by file handlers */ + const rtems_filesystem_file_handlers_r *handlers; /* type specific handlers */ }; /* @@ -612,11 +612,11 @@ int unmount( ); int mount( - rtems_filesystem_mount_table_entry_t **mt_entry, - rtems_filesystem_operations_table *fs_ops, - rtems_filesystem_options_t fsoptions, - char *device, - char *mount_point + rtems_filesystem_mount_table_entry_t **mt_entry, + const rtems_filesystem_operations_table *fs_ops, + rtems_filesystem_options_t fsoptions, + const char *device, + const char *mount_point ); /* @@ -624,14 +624,14 @@ int mount( */ typedef struct { - rtems_filesystem_operations_table *fs_ops; - rtems_filesystem_options_t fsoptions; - char *device; - char *mount_point; + const rtems_filesystem_operations_table *fs_ops; + rtems_filesystem_options_t fsoptions; + const char *device; + const char *mount_point; } rtems_filesystem_mount_table_t; -extern rtems_filesystem_mount_table_t *rtems_filesystem_mount_table; -extern int rtems_filesystem_mount_table_size; +extern const rtems_filesystem_mount_table_t *rtems_filesystem_mount_table; +extern const int rtems_filesystem_mount_table_size; #ifdef __cplusplus } diff --git a/cpukit/libcsupport/src/base_fs.c b/cpukit/libcsupport/src/base_fs.c index e5ddb24494..4ce53b0e4b 100644 --- a/cpukit/libcsupport/src/base_fs.c +++ b/cpukit/libcsupport/src/base_fs.c @@ -45,8 +45,8 @@ void rtems_filesystem_initialize( void ) #if !defined(RTEMS_UNIX) int status; rtems_filesystem_mount_table_entry_t *entry; - rtems_filesystem_mount_table_t *mt; - rtems_filesystem_location_info_t loc; + const rtems_filesystem_mount_table_t *mt; + rtems_filesystem_location_info_t loc; /* * Set the default umask to "022". diff --git a/cpukit/libcsupport/src/error.c b/cpukit/libcsupport/src/error.c index c94be59ad5..15f8e8d23e 100644 --- a/cpukit/libcsupport/src/error.c +++ b/cpukit/libcsupport/src/error.c @@ -63,7 +63,7 @@ char *strerror(int); int rtems_panic_in_progress; -rtems_assoc_t rtems_status_assoc[] = { +const rtems_assoc_t rtems_status_assoc[] = { { "successful completion", RTEMS_SUCCESSFUL, }, { "returned from a thread", RTEMS_TASK_EXITTED, }, { "multiprocessing not configured", RTEMS_MP_NOT_CONFIGURED, }, diff --git a/cpukit/libcsupport/src/libio.c b/cpukit/libcsupport/src/libio.c index 879cd8134c..16bd7f1ec8 100644 --- a/cpukit/libcsupport/src/libio.c +++ b/cpukit/libcsupport/src/libio.c @@ -62,14 +62,14 @@ extern rtems_libio_t *rtems_libio_iop_freelist; * Convert UNIX fnctl(2) flags to ones that RTEMS drivers understand */ -rtems_assoc_t access_modes_assoc[] = { +const rtems_assoc_t access_modes_assoc[] = { { "READ", LIBIO_FLAGS_READ, O_RDONLY }, { "WRITE", LIBIO_FLAGS_WRITE, O_WRONLY }, { "READ/WRITE", LIBIO_FLAGS_READ_WRITE, O_RDWR }, { 0, 0, 0 }, }; -rtems_assoc_t status_flags_assoc[] = { +const rtems_assoc_t status_flags_assoc[] = { #ifdef ACCEPT_O_NDELAY_ALIAS { "NO DELAY", LIBIO_FLAGS_NO_DELAY, O_NDELAY }, #endif diff --git a/cpukit/libcsupport/src/mount.c b/cpukit/libcsupport/src/mount.c index 7b99dfae7d..997cf859b1 100644 --- a/cpukit/libcsupport/src/mount.c +++ b/cpukit/libcsupport/src/mount.c @@ -68,11 +68,11 @@ static int Is_node_fs_root( */ int mount( - rtems_filesystem_mount_table_entry_t **mt_entry, - rtems_filesystem_operations_table *fs_ops, - rtems_filesystem_options_t options, - char *device, - char *mount_point + rtems_filesystem_mount_table_entry_t **mt_entry, + const rtems_filesystem_operations_table *fs_ops, + rtems_filesystem_options_t options, + const char *device, + const char *mount_point ) { rtems_filesystem_location_info_t loc; 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 #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 #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 #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 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 #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 +#include +#include #include "imfs.h" #include #include @@ -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, */ diff --git a/cpukit/posix/include/rtems/posix/psignal.h b/cpukit/posix/include/rtems/posix/psignal.h index 537bef130c..d0b8574b7d 100644 --- a/cpukit/posix/include/rtems/posix/psignal.h +++ b/cpukit/posix/include/rtems/posix/psignal.h @@ -52,7 +52,7 @@ extern sigset_t _POSIX_signals_Pending; -extern struct sigaction _POSIX_signals_Default_vectors[ SIG_ARRAY_MAX ]; +extern const struct sigaction _POSIX_signals_Default_vectors[ SIG_ARRAY_MAX ]; extern struct sigaction _POSIX_signals_Vectors[ SIG_ARRAY_MAX ]; diff --git a/cpukit/posix/src/psignal.c b/cpukit/posix/src/psignal.c index a6c096caa7..70642cff09 100644 --- a/cpukit/posix/src/psignal.c +++ b/cpukit/posix/src/psignal.c @@ -42,7 +42,7 @@ void _POSIX_signals_Abnormal_termination_handler( int signo ) } #define SIG_ARRAY_MAX (SIGRTMAX + 1) -struct sigaction _POSIX_signals_Default_vectors[ SIG_ARRAY_MAX ] = { +const struct sigaction _POSIX_signals_Default_vectors[ SIG_ARRAY_MAX ] = { /* NO SIGNAL 0 */ SIGACTION_IGNORE, /* SIGHUP 1 */ SIGACTION_TERMINATE, /* SIGINT 2 */ SIGACTION_TERMINATE, diff --git a/cpukit/rtems/include/rtems/rtems/status.h b/cpukit/rtems/include/rtems/rtems/status.h index d32b433842..7af8ccec66 100644 --- a/cpukit/rtems/include/rtems/rtems/status.h +++ b/cpukit/rtems/include/rtems/rtems/status.h @@ -187,7 +187,7 @@ typedef enum { * codes to Classic API status codes. */ #ifdef RTEMS_API_INIT -rtems_status_code _Status_Object_name_errors_to_status[] = { +const rtems_status_code _Status_Object_name_errors_to_status[] = { /** This maps OBJECTS_SUCCESSFUL to RTEMS_SUCCESSFUL. */ RTEMS_SUCCESSFUL, /** This maps OBJECTS_INVALID_NAME to RTEMS_INVALID_NAME. */ diff --git a/cpukit/rtems/src/semtranslatereturncode.c b/cpukit/rtems/src/semtranslatereturncode.c index 1315952f33..5bbb0ef1fe 100644 --- a/cpukit/rtems/src/semtranslatereturncode.c +++ b/cpukit/rtems/src/semtranslatereturncode.c @@ -61,7 +61,7 @@ * */ -rtems_status_code _Semaphore_Translate_core_mutex_return_code_[] = { +const rtems_status_code _Semaphore_Translate_core_mutex_return_code_[] = { RTEMS_SUCCESSFUL, /* CORE_MUTEX_STATUS_SUCCESSFUL */ RTEMS_UNSATISFIED, /* CORE_MUTEX_STATUS_UNSATISFIED_NOWAIT */ RTEMS_UNSATISFIED, /* CORE_MUTEX_STATUS_NESTING_NOT_ALLOWED */ @@ -109,7 +109,7 @@ rtems_status_code _Semaphore_Translate_core_mutex_return_code ( * */ -rtems_status_code _Semaphore_Translate_core_semaphore_return_code_[] = { +const rtems_status_code _Semaphore_Translate_core_semaphore_return_code_[] = { RTEMS_SUCCESSFUL, /* CORE_SEMAPHORE_STATUS_SUCCESSFUL */ RTEMS_UNSATISFIED, /* CORE_SEMAPHORE_STATUS_UNSATISFIED_NOWAIT */ RTEMS_OBJECT_WAS_DELETED, /* CORE_SEMAPHORE_WAS_DELETED */ diff --git a/cpukit/sapi/include/confdefs.h b/cpukit/sapi/include/confdefs.h index 8d8f3b889b..de4bc5dc4f 100644 --- a/cpukit/sapi/include/confdefs.h +++ b/cpukit/sapi/include/confdefs.h @@ -133,7 +133,7 @@ extern int rtems_telnetd_maximum_ptys; #ifdef CONFIGURE_INIT #ifndef CONFIGURE_HAS_OWN_MOUNT_TABLE - rtems_filesystem_mount_table_t configuration_mount_table = { + const rtems_filesystem_mount_table_t configuration_mount_table = { #ifdef CONFIGURE_USE_IMFS_AS_BASE_FILESYSTEM &IMFS_ops, #else /* using miniIMFS as base filesystem */ @@ -144,9 +144,9 @@ extern int rtems_telnetd_maximum_ptys; NULL }; - rtems_filesystem_mount_table_t + const rtems_filesystem_mount_table_t *rtems_filesystem_mount_table = &configuration_mount_table; - int rtems_filesystem_mount_table_size = 1; + const int rtems_filesystem_mount_table_size = 1; #endif #endif diff --git a/cpukit/sapi/include/rtems/io.h b/cpukit/sapi/include/rtems/io.h index fdabc028b6..e96a2f6333 100644 --- a/cpukit/sapi/include/rtems/io.h +++ b/cpukit/sapi/include/rtems/io.h @@ -120,7 +120,7 @@ void _IO_Manager_initialization( rtems_status_code rtems_io_register_driver( rtems_device_major_number major, - rtems_driver_address_table *driver_table, + const rtems_driver_address_table *driver_table, rtems_device_major_number *registered_major ); diff --git a/cpukit/sapi/src/ioregisterdriver.c b/cpukit/sapi/src/ioregisterdriver.c index 4c57e3fbf7..7322d77d62 100644 --- a/cpukit/sapi/src/ioregisterdriver.c +++ b/cpukit/sapi/src/ioregisterdriver.c @@ -36,7 +36,7 @@ rtems_status_code rtems_io_register_driver( rtems_device_major_number major, - rtems_driver_address_table *driver_table, + const rtems_driver_address_table *driver_table, rtems_device_major_number *registered_major ) { diff --git a/cpukit/sapi/src/itronapi.c b/cpukit/sapi/src/itronapi.c index e52a64e370..0d44db6801 100644 --- a/cpukit/sapi/src/itronapi.c +++ b/cpukit/sapi/src/itronapi.c @@ -51,7 +51,7 @@ * XXX */ -itron_api_configuration_table _ITRON_Default_configuration = { +const itron_api_configuration_table _ITRON_Default_configuration = { 0, /* maximum_tasks */ 0, /* maximum_semaphores */ 0, /* maximum_eventflags */ @@ -70,7 +70,7 @@ void _ITRON_API_Initialize( rtems_configuration_table *configuration_table ) { - itron_api_configuration_table *api_configuration; + const itron_api_configuration_table *api_configuration; /* XXX need to assert here based on size assumptions */ diff --git a/cpukit/sapi/src/posixapi.c b/cpukit/sapi/src/posixapi.c index b224c6ad52..9ff55ab63e 100644 --- a/cpukit/sapi/src/posixapi.c +++ b/cpukit/sapi/src/posixapi.c @@ -55,7 +55,7 @@ * XXX */ -posix_api_configuration_table _POSIX_Default_configuration = { +const posix_api_configuration_table _POSIX_Default_configuration = { 0, /* maximum_threads */ 0, /* maximum_mutexes */ 0, /* maximum_condition_variables */ @@ -78,7 +78,7 @@ void _POSIX_API_Initialize( rtems_configuration_table *configuration_table ) { - posix_api_configuration_table *api_configuration; + const posix_api_configuration_table *api_configuration; /* XXX need to assert here based on size assumptions */ -- cgit v1.2.3