diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2012-05-15 10:06:18 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2012-05-15 10:06:18 +0200 |
commit | a7d1992c8313eeb5e67bd0f7eebe35e61a103b8a (patch) | |
tree | 594b8171a2aba1a6908c2cc7a42d2a4497b4652e | |
parent | Merge branch 'upstream' (diff) | |
parent | Filesystem: Move operations to mount table entry (diff) | |
download | rtems-a7d1992c8313eeb5e67bd0f7eebe35e61a103b8a.tar.bz2 |
Merge branch 'upstream'
80 files changed, 654 insertions, 520 deletions
diff --git a/c/src/lib/libbsp/shared/umon/tfsDriver.c b/c/src/lib/libbsp/shared/umon/tfsDriver.c index 426d9baee7..20e588329b 100644 --- a/c/src/lib/libbsp/shared/umon/tfsDriver.c +++ b/c/src/lib/libbsp/shared/umon/tfsDriver.c @@ -92,8 +92,8 @@ static int rtems_tfs_mount_me( rtems_set_errno_and_return_minus_one(ENOMEM); } + mt_entry->ops = &rtems_tfs_ops; mt_entry->mt_fs_root->location.handlers = &rtems_tfs_handlers; - mt_entry->mt_fs_root->location.ops = &rtems_tfs_ops; mt_entry->mt_fs_root->location.node_access = root_path; return 0; diff --git a/cpukit/include/rtems/fs.h b/cpukit/include/rtems/fs.h index 7e4dff9cad..6270877ee5 100644 --- a/cpukit/include/rtems/fs.h +++ b/cpukit/include/rtems/fs.h @@ -53,7 +53,6 @@ typedef struct rtems_filesystem_location_info_tt { void *node_access; void *node_access_2; const rtems_filesystem_file_handlers_r *handlers; - const rtems_filesystem_operations_table *ops; rtems_filesystem_mount_table_entry_t *mt_entry; } rtems_filesystem_location_info_t; diff --git a/cpukit/libblock/src/bdbuf.c b/cpukit/libblock/src/bdbuf.c index ad1112b517..de2cebd7be 100644 --- a/cpukit/libblock/src/bdbuf.c +++ b/cpukit/libblock/src/bdbuf.c @@ -2853,7 +2853,8 @@ rtems_bdbuf_gather_for_purge (rtems_chain_control *purge_list, } else { - while (*prev != NULL && cur == (*prev)->avl.right) + while (*prev != NULL + && (cur == (*prev)->avl.right || (*prev)->avl.right == NULL)) { /* Up */ cur = *prev; diff --git a/cpukit/libblock/src/blkdev-imfs.c b/cpukit/libblock/src/blkdev-imfs.c index 86455930f6..c69542d531 100644 --- a/cpukit/libblock/src/blkdev-imfs.c +++ b/cpukit/libblock/src/blkdev-imfs.c @@ -75,6 +75,7 @@ static ssize_t rtems_blkdev_imfs_read( } if (remaining >= 0) { + iop->offset += count; rv = (ssize_t) count; } else { errno = EIO; @@ -134,6 +135,7 @@ static ssize_t rtems_blkdev_imfs_write( } if (remaining >= 0) { + iop->offset += count; rv = (ssize_t) count; } else { errno = EIO; diff --git a/cpukit/libcsupport/Makefile.am b/cpukit/libcsupport/Makefile.am index 1d6fa3b50c..46805e9080 100644 --- a/cpukit/libcsupport/Makefile.am +++ b/cpukit/libcsupport/Makefile.am @@ -24,6 +24,7 @@ include_rtems_motorola_HEADERS += include/motorola/mc68681.h ## rtems include_rtems_HEADERS += include/rtems/assoc.h +include_rtems_HEADERS += include/rtems/deviceio.h include_rtems_HEADERS += include/rtems/error.h include_rtems_HEADERS += include/rtems/libcsupport.h include_rtems_HEADERS += include/rtems/libio.h @@ -127,6 +128,8 @@ libcsupport_a_SOURCES = src/gxx_wrappers.c src/getchark.c src/printk.c \ src/sup_fs_exist_in_same_instance.c \ src/sup_fs_mount_iterate.c \ src/sup_fs_node_type.c \ + src/sup_fs_deviceio.c \ + src/sup_fs_deviceerrno.c \ src/clonenode.c \ src/freenode.c \ $(BSD_LIBC_C_FILES) $(BASE_FS_C_FILES) $(MALLOC_C_FILES) \ diff --git a/cpukit/libcsupport/include/rtems/deviceio.h b/cpukit/libcsupport/include/rtems/deviceio.h new file mode 100644 index 0000000000..6ce5d105b4 --- /dev/null +++ b/cpukit/libcsupport/include/rtems/deviceio.h @@ -0,0 +1,56 @@ +/* + * COPYRIGHT (c) 1989-2012. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.com/license/LICENSE. + */ + +#ifndef _RTEMS_DEVICEIO_H +#define _RTEMS_DEVICEIO_H + +#include <rtems/libio.h> + +int rtems_deviceio_errno( rtems_status_code status ); + +int rtems_deviceio_open( + rtems_libio_t *iop, + const char *path, + int oflag, + mode_t mode, + rtems_device_major_number major, + rtems_device_minor_number minor +); + +int rtems_deviceio_close( + rtems_libio_t *iop, + rtems_device_major_number major, + rtems_device_minor_number minor +); + +ssize_t rtems_deviceio_read( + rtems_libio_t *iop, + void *buf, + size_t nbyte, + rtems_device_major_number major, + rtems_device_minor_number minor +); + +ssize_t rtems_deviceio_write( + rtems_libio_t *iop, + const void *buf, + size_t nbyte, + rtems_device_major_number major, + rtems_device_minor_number minor +); + +int rtems_deviceio_control( + rtems_libio_t *iop, + ioctl_command_t command, + void *buffer, + rtems_device_major_number major, + rtems_device_minor_number minor +); + +#endif /* _RTEMS_DEVICEIO_H */ diff --git a/cpukit/libcsupport/include/rtems/libio.h b/cpukit/libcsupport/include/rtems/libio.h index 0f21b36d65..0e74c4c7fe 100644 --- a/cpukit/libcsupport/include/rtems/libio.h +++ b/cpukit/libcsupport/include/rtems/libio.h @@ -69,7 +69,7 @@ typedef enum { * @see rtems_filesystem_default_lock(). */ typedef void (*rtems_filesystem_mt_entry_lock_t)( - rtems_filesystem_mount_table_entry_t *mt_entry + const rtems_filesystem_mount_table_entry_t *mt_entry ); /** @@ -80,7 +80,7 @@ typedef void (*rtems_filesystem_mt_entry_lock_t)( * @see rtems_filesystem_default_unlock(). */ typedef void (*rtems_filesystem_mt_entry_unlock_t)( - rtems_filesystem_mount_table_entry_t *mt_entry + const rtems_filesystem_mount_table_entry_t *mt_entry ); /** @@ -523,7 +523,7 @@ extern const rtems_filesystem_operations_table * @see rtems_filesystem_mt_entry_lock_t. */ void rtems_filesystem_default_lock( - rtems_filesystem_mount_table_entry_t *mt_entry + const rtems_filesystem_mount_table_entry_t *mt_entry ); /** @@ -532,7 +532,7 @@ void rtems_filesystem_default_lock( * @see rtems_filesystem_mt_entry_unlock_t. */ void rtems_filesystem_default_unlock( - rtems_filesystem_mount_table_entry_t *mt_entry + const rtems_filesystem_mount_table_entry_t *mt_entry ); /** @@ -786,6 +786,8 @@ typedef int (*rtems_filesystem_close_t)( /** * @brief Reads from a node. * + * This handler is responsible to update the offset field of the IO descriptor. + * * @param[in, out] iop The IO pointer. * @param[out] buffer The buffer for read data. * @param[in] count The size of the buffer in characters. @@ -804,6 +806,8 @@ typedef ssize_t (*rtems_filesystem_read_t)( /** * @brief Writes to a node. * + * This handler is responsible to update the offset field of the IO descriptor. + * * @param[in, out] iop The IO pointer. * @param[out] buffer The buffer for write data. * @param[in] count The size of the buffer in characters. @@ -832,9 +836,9 @@ typedef ssize_t (*rtems_filesystem_write_t)( * @see rtems_filesystem_default_ioctl(). */ typedef int (*rtems_filesystem_ioctl_t)( - rtems_libio_t *iop, - uint32_t request, - void *buffer + rtems_libio_t *iop, + ioctl_command_t request, + void *buffer ); /** @@ -1008,9 +1012,9 @@ ssize_t rtems_filesystem_default_write( * @see rtems_filesystem_ioctl_t. */ int rtems_filesystem_default_ioctl( - rtems_libio_t *iop, - uint32_t command, - void *buffer + rtems_libio_t *iop, + ioctl_command_t request, + void *buffer ); /** @@ -1065,17 +1069,6 @@ off_t rtems_filesystem_default_lseek_file( ); /** - * @retval 0 Always. - * - * @see rtems_filesystem_lseek_t. - */ -off_t rtems_filesystem_default_lseek_file( - rtems_libio_t *iop, - off_t offset, - int whence -); - -/** * @brief Sets the mode to S_IRWXU | S_IRWXG | S_IRWXO. * * @retval 0 Always. @@ -1236,7 +1229,7 @@ typedef struct { */ typedef struct { rtems_libio_t *iop; - uint32_t command; + ioctl_command_t command; void *buffer; int ioctl_return; } rtems_libio_ioctl_args_t; @@ -1438,13 +1431,14 @@ extern int rtems_mkdir(const char *path, mode_t mode); */ struct rtems_filesystem_mount_table_entry_tt { rtems_chain_node mt_node; + void *fs_info; + const rtems_filesystem_operations_table *ops; + const void *immutable_fs_info; rtems_chain_control location_chain; rtems_filesystem_global_location_t *mt_point_node; rtems_filesystem_global_location_t *mt_fs_root; bool mounted; bool writeable; - void *fs_info; - const void *immutable_fs_info; rtems_filesystem_limits_and_options_t pathconf_limits_and_options; /* diff --git a/cpukit/libcsupport/include/rtems/libio_.h b/cpukit/libcsupport/include/rtems/libio_.h index 3e2139f450..418f4a31ec 100644 --- a/cpukit/libcsupport/include/rtems/libio_.h +++ b/cpukit/libcsupport/include/rtems/libio_.h @@ -250,14 +250,18 @@ static inline void rtems_filesystem_instance_lock( const rtems_filesystem_location_info_t *loc ) { - (*loc->ops->lock_h)( loc->mt_entry ); + const rtems_filesystem_mount_table_entry_t *mt_entry = loc->mt_entry; + + (*mt_entry->ops->lock_h)( mt_entry ); } static inline void rtems_filesystem_instance_unlock( const rtems_filesystem_location_info_t *loc ) { - (*loc->ops->unlock_h)( loc->mt_entry ); + const rtems_filesystem_mount_table_entry_t *mt_entry = loc->mt_entry; + + (*mt_entry->ops->unlock_h)( mt_entry ); } /* @@ -582,9 +586,11 @@ static inline bool rtems_filesystem_location_is_root( const rtems_filesystem_location_info_t *loc ) { - return (*loc->ops->are_nodes_equal_h)( + const rtems_filesystem_mount_table_entry_t *mt_entry = loc->mt_entry; + + return (*mt_entry->ops->are_nodes_equal_h)( loc, - &loc->mt_entry->mt_fs_root->location + &mt_entry->mt_fs_root->location ); } diff --git a/cpukit/libcsupport/include/sys/ioccom.h b/cpukit/libcsupport/include/sys/ioccom.h index abeb7d536c..1a31374301 100644 --- a/cpukit/libcsupport/include/sys/ioccom.h +++ b/cpukit/libcsupport/include/sys/ioccom.h @@ -106,15 +106,12 @@ typedef struct { #define FIOSETOWN _IOW('f', 124, int) /* set owner */ #define FIOGETOWN _IOR('f', 123, int) /* get owner */ +typedef uint32_t ioctl_command_t; + #ifndef _KERNEL #include <sys/cdefs.h> -#ifndef __ioctl_command_defined -typedef u_int32_t ioctl_command_t; -#define __ioctl_command_defined -#endif - __BEGIN_DECLS int ioctl(int, ioctl_command_t, ...); __END_DECLS diff --git a/cpukit/libcsupport/preinstall.am b/cpukit/libcsupport/preinstall.am index f71362fe31..eb68f50fa4 100644 --- a/cpukit/libcsupport/preinstall.am +++ b/cpukit/libcsupport/preinstall.am @@ -71,6 +71,10 @@ $(PROJECT_INCLUDE)/rtems/assoc.h: include/rtems/assoc.h $(PROJECT_INCLUDE)/rtems $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/assoc.h PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/assoc.h +$(PROJECT_INCLUDE)/rtems/deviceio.h: include/rtems/deviceio.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) + $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/deviceio.h +PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/deviceio.h + $(PROJECT_INCLUDE)/rtems/error.h: include/rtems/error.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/error.h PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/error.h diff --git a/cpukit/libcsupport/src/__usrenv.c b/cpukit/libcsupport/src/__usrenv.c index 87ff25b1e4..6a793755ab 100644 --- a/cpukit/libcsupport/src/__usrenv.c +++ b/cpukit/libcsupport/src/__usrenv.c @@ -51,7 +51,7 @@ const rtems_filesystem_file_handlers_r rtems_filesystem_null_handlers = { }; static void null_op_lock_or_unlock( - rtems_filesystem_mount_table_entry_t *mt_entry + const rtems_filesystem_mount_table_entry_t *mt_entry ) { /* Do nothing */ @@ -220,6 +220,7 @@ rtems_filesystem_mount_table_entry_t rtems_filesystem_null_mt_entry = { .fill = &rtems_filesystem_global_location_null.location.mt_entry_node, } }, + .ops = &null_ops, .mt_point_node = &rtems_filesystem_global_location_null, .mt_fs_root = &rtems_filesystem_global_location_null, .mounted = false, @@ -233,7 +234,6 @@ rtems_filesystem_global_location_t rtems_filesystem_global_location_null = { .previous = &rtems_filesystem_null_mt_entry.location_chain.Head.Node }, .handlers = &rtems_filesystem_null_handlers, - .ops = &null_ops, .mt_entry = &rtems_filesystem_null_mt_entry }, diff --git a/cpukit/libcsupport/src/_rename_r.c b/cpukit/libcsupport/src/_rename_r.c index 45ba0adb6b..007f2499c4 100644 --- a/cpukit/libcsupport/src/_rename_r.c +++ b/cpukit/libcsupport/src/_rename_r.c @@ -57,7 +57,7 @@ int _rename_r( new_currentloc ); if ( rv == 0 ) { - rv = (*new_currentloc->ops->rename_h)( + rv = (*new_currentloc->mt_entry->ops->rename_h)( &old_parentloc, old_currentloc, new_currentloc, diff --git a/cpukit/libcsupport/src/chmod.c b/cpukit/libcsupport/src/chmod.c index 73333fe831..47de601b98 100644 --- a/cpukit/libcsupport/src/chmod.c +++ b/cpukit/libcsupport/src/chmod.c @@ -25,7 +25,7 @@ int chmod( const char *path, mode_t mode ) const rtems_filesystem_location_info_t *currentloc = rtems_filesystem_eval_path_start( &ctx, path, eval_flags ); - rv = (*currentloc->ops->fchmod_h)( currentloc, mode ); + rv = (*currentloc->mt_entry->ops->fchmod_h)( currentloc, mode ); rtems_filesystem_eval_path_cleanup( &ctx ); diff --git a/cpukit/libcsupport/src/chown.c b/cpukit/libcsupport/src/chown.c index fa677cbe9c..7cc03a2a07 100644 --- a/cpukit/libcsupport/src/chown.c +++ b/cpukit/libcsupport/src/chown.c @@ -32,12 +32,9 @@ int rtems_filesystem_chown( int eval_flags = eval_follow_link; const rtems_filesystem_location_info_t *currentloc = rtems_filesystem_eval_path_start( &ctx, path, eval_flags ); + const rtems_filesystem_operations_table *ops = currentloc->mt_entry->ops; - rv = (*currentloc->ops->chown_h)( - currentloc, - owner, - group - ); + rv = (*ops->chown_h)( currentloc, owner, group ); rtems_filesystem_eval_path_cleanup( &ctx ); diff --git a/cpukit/libcsupport/src/chroot.c b/cpukit/libcsupport/src/chroot.c index 11ae8fce7a..9e63704f95 100644 --- a/cpukit/libcsupport/src/chroot.c +++ b/cpukit/libcsupport/src/chroot.c @@ -49,7 +49,9 @@ int chroot( const char *path ) rtems_filesystem_global_location_t *new_root_loc = rtems_filesystem_global_location_obtain( &new_current_loc ); rtems_filesystem_node_types_t type = - (*new_root_loc->location.ops->node_type_h)( &new_root_loc->location ); + (*new_root_loc->location.mt_entry->ops->node_type_h)( + &new_root_loc->location + ); if ( type == RTEMS_FILESYSTEM_DIRECTORY ) { sc = rtems_libio_set_private_env(); diff --git a/cpukit/libcsupport/src/clonenode.c b/cpukit/libcsupport/src/clonenode.c index 380ad90699..0ac7c9ef40 100644 --- a/cpukit/libcsupport/src/clonenode.c +++ b/cpukit/libcsupport/src/clonenode.c @@ -26,7 +26,7 @@ void rtems_filesystem_location_clone( int rv = 0; clone = rtems_filesystem_location_copy( clone, master ); - rv = (*clone->ops->clonenod_h)( clone ); + rv = (*clone->mt_entry->ops->clonenod_h)( clone ); if ( rv != 0 ) { rtems_filesystem_location_remove_from_mt_entry( clone ); rtems_filesystem_location_initialize_to_null( clone ); diff --git a/cpukit/libcsupport/src/fchmod.c b/cpukit/libcsupport/src/fchmod.c index e2f166a8ab..944873817d 100644 --- a/cpukit/libcsupport/src/fchmod.c +++ b/cpukit/libcsupport/src/fchmod.c @@ -28,7 +28,7 @@ int fchmod( int fd, mode_t mode ) if (iop->pathinfo.mt_entry->writeable) { rtems_filesystem_instance_lock( &iop->pathinfo ); - rv = (*iop->pathinfo.ops->fchmod_h)( &iop->pathinfo, mode ); + rv = (*iop->pathinfo.mt_entry->ops->fchmod_h)( &iop->pathinfo, mode ); rtems_filesystem_instance_unlock( &iop->pathinfo ); } else { errno = EROFS; diff --git a/cpukit/libcsupport/src/fchown.c b/cpukit/libcsupport/src/fchown.c index bacdbacfd8..6dfbc52ff3 100644 --- a/cpukit/libcsupport/src/fchown.c +++ b/cpukit/libcsupport/src/fchown.c @@ -28,7 +28,11 @@ int fchown( int fd, uid_t owner, gid_t group ) if (iop->pathinfo.mt_entry->writeable) { rtems_filesystem_instance_lock( &iop->pathinfo ); - rv = (*iop->pathinfo.ops->chown_h)( &iop->pathinfo, owner, group ); + rv = (*iop->pathinfo.mt_entry->ops->chown_h)( + &iop->pathinfo, + owner, + group + ); rtems_filesystem_instance_unlock( &iop->pathinfo ); } else { errno = EROFS; diff --git a/cpukit/libcsupport/src/freenode.c b/cpukit/libcsupport/src/freenode.c index 28913a4e7d..84e58256d2 100644 --- a/cpukit/libcsupport/src/freenode.c +++ b/cpukit/libcsupport/src/freenode.c @@ -21,7 +21,7 @@ void rtems_filesystem_location_free( rtems_filesystem_location_info_t *loc ) { rtems_filesystem_instance_lock( loc ); - (*loc->ops->freenod_h)( loc ); + (*loc->mt_entry->ops->freenod_h)( loc ); rtems_filesystem_instance_unlock( loc ); rtems_filesystem_location_remove_from_mt_entry( loc ); } diff --git a/cpukit/libcsupport/src/link.c b/cpukit/libcsupport/src/link.c index 19ca2d6776..c16e7a018e 100644 --- a/cpukit/libcsupport/src/link.c +++ b/cpukit/libcsupport/src/link.c @@ -36,7 +36,7 @@ int link( const char *path1, const char *path2 ) currentloc_2 ); if ( rv == 0 ) { - rv = (*currentloc_2->ops->link_h)( + rv = (*currentloc_2->mt_entry->ops->link_h)( currentloc_2, currentloc_1, rtems_filesystem_eval_path_get_token( &ctx_2 ), diff --git a/cpukit/libcsupport/src/mknod.c b/cpukit/libcsupport/src/mknod.c index c9dc1d7ece..6a63455d81 100644 --- a/cpukit/libcsupport/src/mknod.c +++ b/cpukit/libcsupport/src/mknod.c @@ -47,7 +47,9 @@ int rtems_filesystem_mknod( } if ( rv == 0 ) { - rv = (*parentloc->ops->mknod_h)( parentloc, name, namelen, mode, dev ); + const rtems_filesystem_operations_table *ops = parentloc->mt_entry->ops; + + rv = (*ops->mknod_h)( parentloc, name, namelen, mode, dev ); } return rv; diff --git a/cpukit/libcsupport/src/mount.c b/cpukit/libcsupport/src/mount.c index 52886d15b6..4563bdbf24 100644 --- a/cpukit/libcsupport/src/mount.c +++ b/cpukit/libcsupport/src/mount.c @@ -122,7 +122,7 @@ static int register_subordinate_file_system( rtems_filesystem_eval_path_extract_currentloc( &ctx, &targetloc ); mt_point_node = rtems_filesystem_location_transform_to_global( &targetloc ); mt_entry->mt_point_node = mt_point_node; - rv = (*mt_point_node->location.ops->mount_h)( mt_entry ); + rv = (*mt_point_node->location.mt_entry->ops->mount_h)( mt_entry ); if ( rv == 0 ) { rtems_filesystem_mt_lock(); rtems_chain_append_unprotected( @@ -218,7 +218,7 @@ int mount( } if ( rv != 0 ) { - (*mt_entry->mt_fs_root->location.ops->fsunmount_me_h)( mt_entry ); + (*mt_entry->ops->fsunmount_me_h)( mt_entry ); } } diff --git a/cpukit/libcsupport/src/open.c b/cpukit/libcsupport/src/open.c index 6bfbd53202..02436b66e7 100644 --- a/cpukit/libcsupport/src/open.c +++ b/cpukit/libcsupport/src/open.c @@ -85,7 +85,7 @@ static int do_open( const rtems_filesystem_location_info_t *currentloc = rtems_filesystem_eval_path_get_currentloc( &ctx ); rtems_filesystem_node_types_t type = - (*currentloc->ops->node_type_h)( currentloc ); + (*currentloc->mt_entry->ops->node_type_h)( currentloc ); if ( type == RTEMS_FILESYSTEM_DIRECTORY ) { rtems_filesystem_eval_path_error( &ctx, EISDIR ); diff --git a/cpukit/libcsupport/src/read.c b/cpukit/libcsupport/src/read.c index 759133b0cb..ee10166dc8 100644 --- a/cpukit/libcsupport/src/read.c +++ b/cpukit/libcsupport/src/read.c @@ -22,7 +22,6 @@ ssize_t read( size_t count ) { - ssize_t rc; rtems_libio_t *iop; rtems_libio_check_fd( fd ); @@ -35,12 +34,7 @@ ssize_t read( /* * Now process the read(). */ - rc = (*iop->pathinfo.handlers->read_h)( iop, buffer, count ); - - if ( rc > 0 ) - iop->offset += rc; - - return rc; + return (*iop->pathinfo.handlers->read_h)( iop, buffer, count ); } /* diff --git a/cpukit/libcsupport/src/readlink.c b/cpukit/libcsupport/src/readlink.c index 3e7a831295..2cafcca10d 100644 --- a/cpukit/libcsupport/src/readlink.c +++ b/cpukit/libcsupport/src/readlink.c @@ -24,11 +24,11 @@ ssize_t readlink( const char *path, char *buf, size_t bufsize ) int eval_flags = RTEMS_FS_FOLLOW_HARD_LINK; const rtems_filesystem_location_info_t *currentloc = rtems_filesystem_eval_path_start( &ctx, path, eval_flags ); - rtems_filesystem_node_types_t type = - (*currentloc->ops->node_type_h)( currentloc ); + const rtems_filesystem_operations_table *ops = currentloc->mt_entry->ops; + rtems_filesystem_node_types_t type = (*ops->node_type_h)( currentloc ); if ( type == RTEMS_FILESYSTEM_SYM_LINK ) { - rv = (*currentloc->ops->readlink_h)( currentloc, buf, bufsize ); + rv = (*ops->readlink_h)( currentloc, buf, bufsize ); } else { rtems_filesystem_eval_path_error( &ctx, EINVAL ); rv = -1; diff --git a/cpukit/libcsupport/src/readv.c b/cpukit/libcsupport/src/readv.c index b23abd0b82..4e540d5da4 100644 --- a/cpukit/libcsupport/src/readv.c +++ b/cpukit/libcsupport/src/readv.c @@ -106,7 +106,6 @@ ssize_t readv( return -1; if ( bytes > 0 ) { - iop->offset += bytes; total += bytes; } diff --git a/cpukit/libcsupport/src/rmdir.c b/cpukit/libcsupport/src/rmdir.c index 9b54987e79..4e7baf5e39 100644 --- a/cpukit/libcsupport/src/rmdir.c +++ b/cpukit/libcsupport/src/rmdir.c @@ -34,14 +34,11 @@ int rmdir( const char *path ) &parentloc, parent_eval_flags ); - rtems_filesystem_node_types_t type = - (*currentloc->ops->node_type_h)( currentloc ); + const rtems_filesystem_operations_table *ops = currentloc->mt_entry->ops; + rtems_filesystem_node_types_t type = (*ops->node_type_h)( currentloc ); if ( type == RTEMS_FILESYSTEM_DIRECTORY ) { - rv = (*currentloc->ops->rmnod_h)( - &parentloc, - currentloc - ); + rv = (*ops->rmnod_h)( &parentloc, currentloc ); } else { rtems_filesystem_eval_path_error( &ctx, ENOTDIR ); rv = -1; diff --git a/cpukit/libcsupport/src/statvfs.c b/cpukit/libcsupport/src/statvfs.c index b944b631eb..163d51eb1a 100644 --- a/cpukit/libcsupport/src/statvfs.c +++ b/cpukit/libcsupport/src/statvfs.c @@ -29,7 +29,7 @@ int statvfs( const char *path, struct statvfs *buf ) memset( buf, 0, sizeof( *buf ) ); - rv = (*currentloc->ops->statvfs_h)( currentloc, buf ); + rv = (*currentloc->mt_entry->ops->statvfs_h)( currentloc, buf ); rtems_filesystem_eval_path_cleanup( &ctx ); diff --git a/cpukit/libfs/src/imfs/deviceerrno.c b/cpukit/libcsupport/src/sup_fs_deviceerrno.c index eb5e03dcaa..4316496561 100644 --- a/cpukit/libfs/src/imfs/deviceerrno.c +++ b/cpukit/libcsupport/src/sup_fs_deviceerrno.c @@ -13,14 +13,12 @@ */ #if HAVE_CONFIG_H -#include "config.h" + #include "config.h" #endif -#include <errno.h> +#include <rtems/deviceio.h> -#include <rtems.h> -#include <rtems/libio.h> -#include <rtems/devfs.h> +#include <errno.h> static const int status_code_to_errno [RTEMS_STATUS_CODES_LAST + 1] = { [RTEMS_SUCCESSFUL] = 0, diff --git a/cpukit/libcsupport/src/sup_fs_deviceio.c b/cpukit/libcsupport/src/sup_fs_deviceio.c new file mode 100644 index 0000000000..74f92cb44c --- /dev/null +++ b/cpukit/libcsupport/src/sup_fs_deviceio.c @@ -0,0 +1,132 @@ +/* + * COPYRIGHT (c) 1989-2012. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.com/license/LICENSE. + */ + +#if HAVE_CONFIG_H + #include "config.h" +#endif + +#include <rtems/deviceio.h> + +int rtems_deviceio_open( + rtems_libio_t *iop, + const char *path, + int oflag, + mode_t mode, + rtems_device_major_number major, + rtems_device_minor_number minor +) +{ + rtems_status_code status; + rtems_libio_open_close_args_t args; + + args.iop = iop; + args.flags = iop->flags; + args.mode = mode; + + status = rtems_io_open( major, minor, &args ); + + return rtems_deviceio_errno( status ); +} + +int rtems_deviceio_close( + rtems_libio_t *iop, + rtems_device_major_number major, + rtems_device_minor_number minor +) +{ + rtems_status_code status; + rtems_libio_open_close_args_t args; + + args.iop = iop; + args.flags = 0; + args.mode = 0; + + status = rtems_io_close( major, minor, &args ); + + return rtems_deviceio_errno( status ); +} + +ssize_t rtems_deviceio_read( + rtems_libio_t *iop, + void *buf, + size_t nbyte, + rtems_device_major_number major, + rtems_device_minor_number minor +) +{ + rtems_status_code status; + rtems_libio_rw_args_t args; + + args.iop = iop; + args.offset = iop->offset; + args.buffer = buf; + args.count = nbyte; + args.flags = iop->flags; + args.bytes_moved = 0; + + status = rtems_io_read( major, minor, &args ); + if ( status == RTEMS_SUCCESSFUL ) { + iop->offset += args.bytes_moved; + + return (ssize_t) args.bytes_moved; + } else { + return rtems_deviceio_errno( status ); + } +} + +ssize_t rtems_deviceio_write( + rtems_libio_t *iop, + const void *buf, + size_t nbyte, + rtems_device_major_number major, + rtems_device_minor_number minor +) +{ + rtems_status_code status; + rtems_libio_rw_args_t args; + + args.iop = iop; + args.offset = iop->offset; + args.buffer = buf; + args.count = nbyte; + args.flags = iop->flags; + args.bytes_moved = 0; + + status = rtems_io_write( major, minor, &args ); + if ( status == RTEMS_SUCCESSFUL ) { + iop->offset += args.bytes_moved; + + return (ssize_t) args.bytes_moved; + } else { + return rtems_deviceio_errno( status ); + } +} + +int rtems_deviceio_control( + rtems_libio_t *iop, + ioctl_command_t command, + void *buffer, + rtems_device_major_number major, + rtems_device_minor_number minor +) +{ + rtems_status_code status; + rtems_libio_ioctl_args_t args; + + args.iop = iop; + args.command = command; + args.buffer = buffer; + + status = rtems_io_control( major, minor, &args ); + if ( status == RTEMS_SUCCESSFUL ) { + return args.ioctl_return; + } else { + return rtems_deviceio_errno(status); + } +} diff --git a/cpukit/libcsupport/src/sup_fs_eval_path.c b/cpukit/libcsupport/src/sup_fs_eval_path.c index 5f7b606e7d..f323dbc8f3 100644 --- a/cpukit/libcsupport/src/sup_fs_eval_path.c +++ b/cpukit/libcsupport/src/sup_fs_eval_path.c @@ -104,7 +104,7 @@ void rtems_filesystem_eval_path_continue( int eval_flags; while (ctx->pathlen > 0) { - (*ctx->currentloc.ops->eval_path_h)(ctx); + (*ctx->currentloc.mt_entry->ops->eval_path_h)(ctx); } eval_flags = rtems_filesystem_eval_path_get_flags(ctx); @@ -260,7 +260,7 @@ void rtems_filesystem_eval_path_recursive( ++ctx->recursionlevel; while (ctx->pathlen > 0) { - (*ctx->currentloc.ops->eval_path_h)(ctx); + (*ctx->currentloc.mt_entry->ops->eval_path_h)(ctx); } --ctx->recursionlevel; @@ -297,7 +297,7 @@ static void free_location(rtems_filesystem_location_info_t *loc) { rtems_filesystem_mt_entry_declare_lock_context(lock_context); - (*loc->ops->freenod_h)(loc); + (*loc->mt_entry->ops->freenod_h)(loc); rtems_filesystem_mt_entry_lock(lock_context); rtems_chain_extract_unprotected(&loc->mt_entry_node); diff --git a/cpukit/libcsupport/src/sup_fs_eval_path_generic.c b/cpukit/libcsupport/src/sup_fs_eval_path_generic.c index d8629c64ab..27dd80145a 100644 --- a/cpukit/libcsupport/src/sup_fs_eval_path_generic.c +++ b/cpukit/libcsupport/src/sup_fs_eval_path_generic.c @@ -20,10 +20,11 @@ static bool is_fs_root( const rtems_filesystem_location_info_t *loc ) { + const rtems_filesystem_mount_table_entry_t *mt_entry = loc->mt_entry; const rtems_filesystem_location_info_t *mt_fs_root = - &loc->mt_entry->mt_fs_root->location; + &mt_entry->mt_fs_root->location; - return (*loc->ops->are_nodes_equal_h)( loc, mt_fs_root ); + return (*mt_entry->ops->are_nodes_equal_h)( loc, mt_fs_root ); } static bool is_eval_path_root( @@ -31,10 +32,11 @@ static bool is_eval_path_root( const rtems_filesystem_location_info_t *loc ) { + const rtems_filesystem_mount_table_entry_t *mt_entry = loc->mt_entry; const rtems_filesystem_location_info_t *rootloc = &ctx->rootloc->location; - return loc->mt_entry == rootloc->mt_entry - && (*loc->ops->are_nodes_equal_h)( loc, rootloc ); + return mt_entry == rootloc->mt_entry + && (*mt_entry->ops->are_nodes_equal_h)( loc, rootloc ); } void rtems_filesystem_eval_path_generic( diff --git a/cpukit/libcsupport/src/sup_fs_location.c b/cpukit/libcsupport/src/sup_fs_location.c index 5234c01ddc..4ebf5f04d7 100644 --- a/cpukit/libcsupport/src/sup_fs_location.c +++ b/cpukit/libcsupport/src/sup_fs_location.c @@ -33,7 +33,6 @@ rtems_filesystem_location_info_t *rtems_filesystem_location_copy( dst->node_access = src->node_access; dst->node_access_2 = src->node_access_2; dst->handlers = src->handlers; - dst->ops = src->ops; dst->mt_entry = src->mt_entry; rtems_filesystem_location_add_to_mt_entry(dst); @@ -213,6 +212,6 @@ void rtems_filesystem_do_unmount( rtems_chain_extract_unprotected(&mt_entry->mt_node); rtems_filesystem_mt_unlock(); rtems_filesystem_global_location_release(mt_entry->mt_point_node); - (*mt_entry->mt_fs_root->location.ops->fsunmount_me_h)(mt_entry); + (*mt_entry->ops->fsunmount_me_h)(mt_entry); free(mt_entry); } diff --git a/cpukit/libcsupport/src/sup_fs_node_type.c b/cpukit/libcsupport/src/sup_fs_node_type.c index f78451dee1..0eb4221402 100644 --- a/cpukit/libcsupport/src/sup_fs_node_type.c +++ b/cpukit/libcsupport/src/sup_fs_node_type.c @@ -25,7 +25,7 @@ rtems_filesystem_node_types_t rtems_filesystem_node_type( rtems_filesystem_node_types_t type; rtems_filesystem_instance_lock(loc); - type = (*loc->ops->node_type_h)(loc); + type = (*loc->mt_entry->ops->node_type_h)(loc); rtems_filesystem_instance_unlock(loc); return type; diff --git a/cpukit/libcsupport/src/symlink.c b/cpukit/libcsupport/src/symlink.c index f49730df70..07ab87fc57 100644 --- a/cpukit/libcsupport/src/symlink.c +++ b/cpukit/libcsupport/src/symlink.c @@ -27,7 +27,7 @@ int symlink( const char *path1, const char *path2 ) const rtems_filesystem_location_info_t *currentloc = rtems_filesystem_eval_path_start( &ctx, path2, eval_flags ); - rv = (*currentloc->ops->symlink_h)( + rv = (*currentloc->mt_entry->ops->symlink_h)( currentloc, rtems_filesystem_eval_path_get_token( &ctx ), rtems_filesystem_eval_path_get_tokenlen( &ctx ), diff --git a/cpukit/libcsupport/src/unlink.c b/cpukit/libcsupport/src/unlink.c index 6a6091575b..9817ad9611 100644 --- a/cpukit/libcsupport/src/unlink.c +++ b/cpukit/libcsupport/src/unlink.c @@ -34,11 +34,9 @@ int unlink( const char *path ) &parentloc, parent_eval_flags ); + const rtems_filesystem_operations_table *ops = currentloc->mt_entry->ops; - rv = (*currentloc->ops->rmnod_h)( - &parentloc, - currentloc - ); + rv = (*ops->rmnod_h)( &parentloc, currentloc ); rtems_filesystem_eval_path_cleanup_with_parent( &ctx, &parentloc ); diff --git a/cpukit/libcsupport/src/unmount.c b/cpukit/libcsupport/src/unmount.c index cf4befe5a4..b58955d33c 100644 --- a/cpukit/libcsupport/src/unmount.c +++ b/cpukit/libcsupport/src/unmount.c @@ -32,7 +32,10 @@ int unmount( const char *path ) rtems_filesystem_mount_table_entry_t *mt_entry = currentloc->mt_entry; if ( rtems_filesystem_location_is_root( currentloc ) ) { - rv = (*mt_entry->mt_point_node->location.ops->unmount_h)( mt_entry ); + const rtems_filesystem_operations_table *mt_point_ops = + mt_entry->mt_point_node->location.mt_entry->ops; + + rv = (*mt_point_ops->unmount_h)( mt_entry ); if ( rv == 0 ) { rtems_filesystem_mt_entry_declare_lock_context( lock_context ); diff --git a/cpukit/libcsupport/src/utime.c b/cpukit/libcsupport/src/utime.c index fe4f7109a3..0f65397166 100644 --- a/cpukit/libcsupport/src/utime.c +++ b/cpukit/libcsupport/src/utime.c @@ -38,7 +38,7 @@ int utime( const char *path, const struct utimbuf *times ) times = &now_times; } - rv = (*currentloc->ops->utime_h)( + rv = (*currentloc->mt_entry->ops->utime_h)( currentloc, times->actime, times->modtime diff --git a/cpukit/libcsupport/src/write.c b/cpukit/libcsupport/src/write.c index b74738845b..dc1255867d 100644 --- a/cpukit/libcsupport/src/write.c +++ b/cpukit/libcsupport/src/write.c @@ -29,7 +29,6 @@ ssize_t write( size_t count ) { - ssize_t rc; rtems_libio_t *iop; rtems_libio_check_fd( fd ); @@ -42,10 +41,5 @@ ssize_t write( /* * Now process the write() request. */ - rc = (*iop->pathinfo.handlers->write_h)( iop, buffer, count ); - - if ( rc > 0 ) - iop->offset += rc; - - return rc; + return (*iop->pathinfo.handlers->write_h)( iop, buffer, count ); } diff --git a/cpukit/libcsupport/src/writev.c b/cpukit/libcsupport/src/writev.c index 8356c1ee66..47605a4cd9 100644 --- a/cpukit/libcsupport/src/writev.c +++ b/cpukit/libcsupport/src/writev.c @@ -113,7 +113,6 @@ ssize_t writev( return -1; if ( bytes > 0 ) { - iop->offset += bytes; total += bytes; } diff --git a/cpukit/libfs/Makefile.am b/cpukit/libfs/Makefile.am index 9a792d1a2f..c5e483ef5a 100644 --- a/cpukit/libfs/Makefile.am +++ b/cpukit/libfs/Makefile.am @@ -37,7 +37,7 @@ libdefaultfs_a_SOURCES = \ noinst_LIBRARIES += libimfs.a libimfs_a_SOURCES = -libimfs_a_SOURCES += src/imfs/deviceerrno.c src/imfs/deviceio.c \ +libimfs_a_SOURCES += src/imfs/deviceio.c \ src/imfs/fifoimfs_init.c src/imfs/imfs_chown.c src/imfs/imfs_config.c \ src/imfs/imfs_creat.c src/imfs/imfs_debug.c src/imfs/imfs_directory.c \ src/imfs/imfs_eval.c src/imfs/imfs_fchmod.c \ diff --git a/cpukit/libfs/src/defaults/default_ioctl.c b/cpukit/libfs/src/defaults/default_ioctl.c index f86f2bc173..edd1c622ba 100644 --- a/cpukit/libfs/src/defaults/default_ioctl.c +++ b/cpukit/libfs/src/defaults/default_ioctl.c @@ -7,14 +7,16 @@ * http://www.rtems.com/license/LICENSE. */ -#include <rtems/libio.h> +#if HAVE_CONFIG_H + #include "config.h" +#endif + #include <rtems/libio_.h> -#include <rtems/seterr.h> int rtems_filesystem_default_ioctl( - rtems_libio_t *iop, - uint32_t command, - void *buffer + rtems_libio_t *iop, + ioctl_command_t request, + void *buffer ) { rtems_set_errno_and_return_minus_one( ENOTSUP ); diff --git a/cpukit/libfs/src/defaults/default_lock_and_unlock.c b/cpukit/libfs/src/defaults/default_lock_and_unlock.c index de29a076f1..a88a99d4a5 100644 --- a/cpukit/libfs/src/defaults/default_lock_and_unlock.c +++ b/cpukit/libfs/src/defaults/default_lock_and_unlock.c @@ -19,14 +19,14 @@ #include <rtems/libio_.h> void rtems_filesystem_default_lock( - rtems_filesystem_mount_table_entry_t *mt_entry + const rtems_filesystem_mount_table_entry_t *mt_entry ) { rtems_libio_lock(); } void rtems_filesystem_default_unlock( - rtems_filesystem_mount_table_entry_t *mt_entry + const rtems_filesystem_mount_table_entry_t *mt_entry ) { rtems_libio_unlock(); diff --git a/cpukit/libfs/src/devfs/devclose.c b/cpukit/libfs/src/devfs/devclose.c index c83fab9745..83646c7619 100644 --- a/cpukit/libfs/src/devfs/devclose.c +++ b/cpukit/libfs/src/devfs/devclose.c @@ -5,33 +5,18 @@ */ #if HAVE_CONFIG_H -#include "config.h" + #include "config.h" #endif -#include <rtems.h> -#include <rtems/io.h> - #include "devfs.h" +#include <rtems/deviceio.h> + int devFS_close( rtems_libio_t *iop ) { - rtems_libio_open_close_args_t args; - rtems_status_code status; const devFS_node *np = iop->pathinfo.node_access; - args.iop = iop; - args.flags = 0; - args.mode = 0; - - status = rtems_io_close( - np->major, - np->minor, - (void *) &args - ); - - return rtems_deviceio_errno(status); + return rtems_deviceio_close( iop, np->major, np->minor ); } - - diff --git a/cpukit/libfs/src/devfs/devfs.h b/cpukit/libfs/src/devfs/devfs.h index 758edf932b..4155dd6884 100644 --- a/cpukit/libfs/src/devfs/devfs.h +++ b/cpukit/libfs/src/devfs/devfs.h @@ -49,17 +49,11 @@ extern const rtems_filesystem_operations_table devFS_ops; extern const rtems_filesystem_file_handlers_r devFS_file_handlers; -/** - * This routine associates RTEMS status code with errno - */ - -extern int rtems_deviceio_errno(rtems_status_code code); - static inline const devFS_data *devFS_get_data( const rtems_filesystem_location_info_t *loc ) { - return loc->mt_entry->immutable_fs_info; + return (const devFS_data *) loc->mt_entry->immutable_fs_info; } extern void devFS_eval_path( @@ -137,9 +131,9 @@ extern ssize_t devFS_write( */ extern int devFS_ioctl( - rtems_libio_t *iop, - uint32_t command, - void *buffer + rtems_libio_t *iop, + ioctl_command_t command, + void *buffer ); diff --git a/cpukit/libfs/src/devfs/devfs_init.c b/cpukit/libfs/src/devfs/devfs_init.c index e489781f63..7ec3d9f9be 100644 --- a/cpukit/libfs/src/devfs/devfs_init.c +++ b/cpukit/libfs/src/devfs/devfs_init.c @@ -56,9 +56,9 @@ int devFS_initialize( int rv = 0; if (data != NULL) { + mt_entry->ops = &devFS_ops; mt_entry->immutable_fs_info = data; mt_entry->mt_fs_root->location.handlers = &devFS_file_handlers; - mt_entry->mt_fs_root->location.ops = &devFS_ops; } else { errno = EINVAL; rv = -1; diff --git a/cpukit/libfs/src/devfs/devfs_show.c b/cpukit/libfs/src/devfs/devfs_show.c index acaa346784..56badb1207 100644 --- a/cpukit/libfs/src/devfs/devfs_show.c +++ b/cpukit/libfs/src/devfs/devfs_show.c @@ -14,7 +14,7 @@ void devFS_Show(void) { rtems_filesystem_location_info_t *rootloc = &rtems_filesystem_root->location; - if (rootloc->ops == &devFS_ops) { + if (rootloc->mt_entry->ops == &devFS_ops) { const devFS_data *data = devFS_get_data(rootloc); size_t i = 0; size_t n = data->count; diff --git a/cpukit/libfs/src/devfs/devioctl.c b/cpukit/libfs/src/devfs/devioctl.c index 7f9c343afb..e1d62c4d78 100644 --- a/cpukit/libfs/src/devfs/devioctl.c +++ b/cpukit/libfs/src/devfs/devioctl.c @@ -1,41 +1,24 @@ -#if HAVE_CONFIG_H /* * The license and distribution terms for this file may be * found in the file LICENSE in this distribution or at * http://www.rtems.com/license/LICENSE. */ -#include "config.h" +#if HAVE_CONFIG_H + #include "config.h" #endif -#include <rtems.h> -#include <rtems/io.h> - #include "devfs.h" +#include <rtems/deviceio.h> + int devFS_ioctl( - rtems_libio_t *iop, - uint32_t command, - void *buffer + rtems_libio_t *iop, + ioctl_command_t command, + void *buffer ) { - rtems_libio_ioctl_args_t args; - rtems_status_code status; const devFS_node *np = iop->pathinfo.node_access; - args.iop = iop; - args.command = command; - args.buffer = buffer; - - status = rtems_io_control( - np->major, - np->minor, - (void *) &args - ); - - if ( status ) - return rtems_deviceio_errno(status); - - return args.ioctl_return; + return rtems_deviceio_control( iop, command, buffer, np->major, np->minor ); } - diff --git a/cpukit/libfs/src/devfs/devopen.c b/cpukit/libfs/src/devfs/devopen.c index adb8fe43b1..26450ab26b 100644 --- a/cpukit/libfs/src/devfs/devopen.c +++ b/cpukit/libfs/src/devfs/devopen.c @@ -5,14 +5,13 @@ */ #if HAVE_CONFIG_H -#include "config.h" + #include "config.h" #endif -#include <rtems.h> -#include <rtems/io.h> - #include "devfs.h" +#include <rtems/deviceio.h> + int devFS_open( rtems_libio_t *iop, const char *pathname, @@ -20,19 +19,14 @@ int devFS_open( mode_t mode ) { - rtems_libio_open_close_args_t args; - rtems_status_code status; const devFS_node *np = iop->pathinfo.node_access; - args.iop = iop; - args.flags = iop->flags; - args.mode = mode; - - status = rtems_io_open( + return rtems_deviceio_open( + iop, + pathname, + oflag, + mode, np->major, - np->minor, - (void *) &args + np->minor ); - - return rtems_deviceio_errno(status); } diff --git a/cpukit/libfs/src/devfs/devread.c b/cpukit/libfs/src/devfs/devread.c index 6868a9e952..25d69b0284 100644 --- a/cpukit/libfs/src/devfs/devread.c +++ b/cpukit/libfs/src/devfs/devread.c @@ -5,40 +5,20 @@ */ #if HAVE_CONFIG_H -#include "config.h" + #include "config.h" #endif -#include <rtems.h> -#include <rtems/io.h> - #include "devfs.h" +#include <rtems/deviceio.h> + ssize_t devFS_read( rtems_libio_t *iop, void *buffer, size_t count ) { - rtems_libio_rw_args_t args; - rtems_status_code status; const devFS_node *np = iop->pathinfo.node_access; - args.iop = iop; - args.offset = iop->offset; - args.buffer = buffer; - args.count = count; - args.flags = iop->flags; - args.bytes_moved = 0; - - status = rtems_io_read( - np->major, - np->minor, - (void *) &args - ); - - if ( status ) - return rtems_deviceio_errno(status); - - return (ssize_t) args.bytes_moved; + return rtems_deviceio_read( iop, buffer, count, np->major, np->minor ); } - diff --git a/cpukit/libfs/src/devfs/devwrite.c b/cpukit/libfs/src/devfs/devwrite.c index fe48745d9f..57e7fdb221 100644 --- a/cpukit/libfs/src/devfs/devwrite.c +++ b/cpukit/libfs/src/devfs/devwrite.c @@ -5,40 +5,20 @@ */ #if HAVE_CONFIG_H -#include "config.h" + #include "config.h" #endif -#include <rtems.h> -#include <rtems/io.h> - #include "devfs.h" +#include <rtems/deviceio.h> + ssize_t devFS_write( rtems_libio_t *iop, const void *buffer, size_t count ) { - rtems_libio_rw_args_t args; - rtems_status_code status; const devFS_node *np = iop->pathinfo.node_access; - args.iop = iop; - args.offset = iop->offset; - args.buffer = (void *) buffer; - args.count = count; - args.flags = iop->flags; - args.bytes_moved = 0; - - status = rtems_io_write( - np->major, - np->minor, - (void *) &args - ); - - if ( status ) - return rtems_deviceio_errno(status); - - return (ssize_t) args.bytes_moved; + return rtems_deviceio_write( iop, buffer, count, np->major, np->minor ); } - diff --git a/cpukit/libfs/src/dosfs/msdos.h b/cpukit/libfs/src/dosfs/msdos.h index 25f25b57a5..f762656607 100644 --- a/cpukit/libfs/src/dosfs/msdos.h +++ b/cpukit/libfs/src/dosfs/msdos.h @@ -252,9 +252,9 @@ int msdos_rename( size_t new_namelen ); -void msdos_lock(rtems_filesystem_mount_table_entry_t *mt_entry); +void msdos_lock(const rtems_filesystem_mount_table_entry_t *mt_entry); -void msdos_unlock(rtems_filesystem_mount_table_entry_t *mt_entry); +void msdos_unlock(const rtems_filesystem_mount_table_entry_t *mt_entry); int msdos_initialize_support( rtems_filesystem_mount_table_entry_t *temp_mt_entry, diff --git a/cpukit/libfs/src/dosfs/msdos_file.c b/cpukit/libfs/src/dosfs/msdos_file.c index 9f4a84cb30..e20b71b8e6 100644 --- a/cpukit/libfs/src/dosfs/msdos_file.c +++ b/cpukit/libfs/src/dosfs/msdos_file.c @@ -117,6 +117,8 @@ msdos_file_read(rtems_libio_t *iop, void *buffer, size_t count) ret = fat_file_read(iop->pathinfo.mt_entry, fat_fd, iop->offset, count, buffer); + if (ret > 0) + iop->offset += ret; rtems_semaphore_release(fs_info->vol_sema); return ret; @@ -163,8 +165,9 @@ msdos_file_write(rtems_libio_t *iop,const void *buffer, size_t count) * update file size in both fat-file descriptor and file control block if * file was extended */ - if (iop->offset + ret > fat_fd->fat_file_size) - fat_fd->fat_file_size = iop->offset + ret; + iop->offset += ret; + if (iop->offset > fat_fd->fat_file_size) + fat_fd->fat_file_size = iop->offset; rtems_semaphore_release(fs_info->vol_sema); return ret; @@ -273,7 +276,6 @@ msdos_file_sync(rtems_libio_t *iop) { int rc = RC_OK; rtems_status_code sc = RTEMS_SUCCESSFUL; - fat_file_fd_t *fat_fd = iop->pathinfo.node_access; msdos_fs_info_t *fs_info = iop->pathinfo.mt_entry->fs_info; sc = rtems_semaphore_obtain(fs_info->vol_sema, RTEMS_WAIT, diff --git a/cpukit/libfs/src/dosfs/msdos_init.c b/cpukit/libfs/src/dosfs/msdos_init.c index 589ba1c0fe..544fef49be 100644 --- a/cpukit/libfs/src/dosfs/msdos_init.c +++ b/cpukit/libfs/src/dosfs/msdos_init.c @@ -51,7 +51,7 @@ const rtems_filesystem_operations_table msdos_ops = { .statvfs_h = rtems_filesystem_default_statvfs }; -void msdos_lock(rtems_filesystem_mount_table_entry_t *mt_entry) +void msdos_lock(const rtems_filesystem_mount_table_entry_t *mt_entry) { msdos_fs_info_t *fs_info = mt_entry->fs_info; rtems_status_code sc = rtems_semaphore_obtain( @@ -64,7 +64,7 @@ void msdos_lock(rtems_filesystem_mount_table_entry_t *mt_entry) } } -void msdos_unlock(rtems_filesystem_mount_table_entry_t *mt_entry) +void msdos_unlock(const rtems_filesystem_mount_table_entry_t *mt_entry) { msdos_fs_info_t *fs_info = mt_entry->fs_info; rtems_status_code sc = rtems_semaphore_release(fs_info->vol_sema); diff --git a/cpukit/libfs/src/dosfs/msdos_initsupp.c b/cpukit/libfs/src/dosfs/msdos_initsupp.c index 1f05398dd9..f3a2cc5281 100644 --- a/cpukit/libfs/src/dosfs/msdos_initsupp.c +++ b/cpukit/libfs/src/dosfs/msdos_initsupp.c @@ -141,7 +141,7 @@ msdos_initialize_support( temp_mt_entry->mt_fs_root->location.node_access = fat_fd; temp_mt_entry->mt_fs_root->location.handlers = directory_handlers; - temp_mt_entry->mt_fs_root->location.ops = op_table; + temp_mt_entry->ops = op_table; return rc; } diff --git a/cpukit/libfs/src/imfs/deviceio.c b/cpukit/libfs/src/imfs/deviceio.c index e5a4d85a21..679f94559c 100644 --- a/cpukit/libfs/src/imfs/deviceio.c +++ b/cpukit/libfs/src/imfs/deviceio.c @@ -4,7 +4,7 @@ * This file contains the set of handlers used to map operations on * IMFS device nodes onto calls to the RTEMS Classic API IO Manager. * - * COPYRIGHT (c) 1989-2008. + * COPYRIGHT (c) 1989-2012. * On-Line Applications Research Corporation (OAR). * * The license and distribution terms for this file may be @@ -18,13 +18,7 @@ #include "imfs.h" -#include <rtems/devfs.h> - -/* - * device_open - * - * This handler maps an open() operation onto rtems_io_open(). - */ +#include <rtems/deviceio.h> int device_open( rtems_libio_t *iop, @@ -33,174 +27,92 @@ int device_open( mode_t mode ) { - rtems_libio_open_close_args_t args; - rtems_status_code status; IMFS_jnode_t *the_jnode; the_jnode = iop->pathinfo.node_access; - args.iop = iop; - args.flags = iop->flags; - args.mode = mode; - - status = rtems_io_open( + return rtems_deviceio_open( + iop, + pathname, + oflag, + mode, the_jnode->info.device.major, - the_jnode->info.device.minor, - (void *) &args + the_jnode->info.device.minor ); - - return rtems_deviceio_errno( status ); } -/* - * device_close - * - * This handler maps a close() operation onto rtems_io_close(). - */ - int device_close( rtems_libio_t *iop ) { - rtems_libio_open_close_args_t args; - rtems_status_code status; IMFS_jnode_t *the_jnode; the_jnode = iop->pathinfo.node_access; - args.iop = iop; - args.flags = 0; - args.mode = 0; - - status = rtems_io_close( + return rtems_deviceio_close( + iop, the_jnode->info.device.major, - the_jnode->info.device.minor, - (void *) &args + the_jnode->info.device.minor ); - - return rtems_deviceio_errno( status ); } -/* - * device_read - * - * This handler maps a read() operation onto rtems_io_read(). - */ - ssize_t device_read( rtems_libio_t *iop, void *buffer, size_t count ) { - rtems_libio_rw_args_t args; - rtems_status_code status; IMFS_jnode_t *the_jnode; the_jnode = iop->pathinfo.node_access; - args.iop = iop; - args.offset = iop->offset; - args.buffer = buffer; - args.count = count; - args.flags = iop->flags; - args.bytes_moved = 0; - - status = rtems_io_read( + return rtems_deviceio_read( + iop, + buffer, + count, the_jnode->info.device.major, - the_jnode->info.device.minor, - (void *) &args + the_jnode->info.device.minor ); - - if ( status ) - return rtems_deviceio_errno(status); - - return (ssize_t) args.bytes_moved; } -/* - * device_write - * - * This handler maps a write() operation onto rtems_io_write(). - */ - ssize_t device_write( rtems_libio_t *iop, const void *buffer, size_t count ) { - rtems_libio_rw_args_t args; - rtems_status_code status; IMFS_jnode_t *the_jnode; the_jnode = iop->pathinfo.node_access; - args.iop = iop; - args.offset = iop->offset; - args.buffer = (void *) buffer; - args.count = count; - args.flags = iop->flags; - args.bytes_moved = 0; - - status = rtems_io_write( + return rtems_deviceio_write( + iop, + buffer, + count, the_jnode->info.device.major, - the_jnode->info.device.minor, - (void *) &args + the_jnode->info.device.minor ); - - if ( status ) - return rtems_deviceio_errno(status); - - return (ssize_t) args.bytes_moved; } -/* - * device_ioctl - * - * This handler maps an ioctl() operation onto rtems_io_ioctl(). - */ - int device_ioctl( - rtems_libio_t *iop, - uint32_t command, - void *buffer + rtems_libio_t *iop, + ioctl_command_t command, + void *buffer ) { - rtems_libio_ioctl_args_t args; - rtems_status_code status; IMFS_jnode_t *the_jnode; - args.iop = iop; - args.command = command; - args.buffer = buffer; - the_jnode = iop->pathinfo.node_access; - status = rtems_io_control( + return rtems_deviceio_control( + iop, + command, + buffer, the_jnode->info.device.major, - the_jnode->info.device.minor, - (void *) &args + the_jnode->info.device.minor ); - - if ( status ) - return rtems_deviceio_errno(status); - - return args.ioctl_return; } -/* - * device_stat - * - * The IMFS_stat() is used. - */ - -/* - * device_rmnod - * - * The IMFS_rmnod() is used. - */ - int device_ftruncate( rtems_libio_t *iop, off_t length diff --git a/cpukit/libfs/src/imfs/imfs.h b/cpukit/libfs/src/imfs/imfs.h index fc9d50e912..7c0cbe5931 100644 --- a/cpukit/libfs/src/imfs/imfs.h +++ b/cpukit/libfs/src/imfs/imfs.h @@ -435,12 +435,6 @@ extern ssize_t memfile_write( size_t count /* IN */ ); -extern int memfile_ioctl( - rtems_libio_t *iop, /* IN */ - uint32_t command, /* IN */ - void *buffer /* IN */ -); - extern int device_open( rtems_libio_t *iop, /* IN */ const char *pathname, /* IN */ @@ -465,9 +459,9 @@ extern ssize_t device_write( ); extern int device_ioctl( - rtems_libio_t *iop, /* IN */ - uint32_t command, /* IN */ - void *buffer /* IN */ + rtems_libio_t *iop, + ioctl_command_t command, + void *buffer ); extern int device_ftruncate( diff --git a/cpukit/libfs/src/imfs/imfs_fifo.c b/cpukit/libfs/src/imfs/imfs_fifo.c index 943bfed692..8601ef7b62 100644 --- a/cpukit/libfs/src/imfs/imfs_fifo.c +++ b/cpukit/libfs/src/imfs/imfs_fifo.c @@ -83,9 +83,9 @@ static ssize_t IMFS_fifo_write( } static int IMFS_fifo_ioctl( - rtems_libio_t *iop, - uint32_t command, - void *buffer + rtems_libio_t *iop, + ioctl_command_t command, + void *buffer ) { int err; diff --git a/cpukit/libfs/src/imfs/imfs_handlers_memfile.c b/cpukit/libfs/src/imfs/imfs_handlers_memfile.c index 6a1466e29c..6953319861 100644 --- a/cpukit/libfs/src/imfs/imfs_handlers_memfile.c +++ b/cpukit/libfs/src/imfs/imfs_handlers_memfile.c @@ -33,7 +33,7 @@ static const rtems_filesystem_file_handlers_r IMFS_memfile_handlers = { rtems_filesystem_default_close, memfile_read, memfile_write, - memfile_ioctl, + rtems_filesystem_default_ioctl, rtems_filesystem_default_lseek_file, IMFS_stat_file, memfile_ftruncate, diff --git a/cpukit/libfs/src/imfs/imfs_initsupp.c b/cpukit/libfs/src/imfs/imfs_initsupp.c index 39b691a49b..f005774e1d 100644 --- a/cpukit/libfs/src/imfs/imfs_initsupp.c +++ b/cpukit/libfs/src/imfs/imfs_initsupp.c @@ -79,9 +79,9 @@ int IMFS_initialize_support( ); if ( root_node != NULL ) { mt_entry->fs_info = fs_info; + mt_entry->ops = op_table; mt_entry->pathconf_limits_and_options = IMFS_LIMITS_AND_OPTIONS; mt_entry->mt_fs_root->location.node_access = root_node; - mt_entry->mt_fs_root->location.ops = op_table; IMFS_Set_handlers( &mt_entry->mt_fs_root->location ); } else { errno = ENOMEM; diff --git a/cpukit/libfs/src/imfs/imfs_load_tar.c b/cpukit/libfs/src/imfs/imfs_load_tar.c index 9abaf2f8ee..e51194fa8c 100644 --- a/cpukit/libfs/src/imfs/imfs_load_tar.c +++ b/cpukit/libfs/src/imfs/imfs_load_tar.c @@ -101,7 +101,11 @@ int rtems_tarfs_load( &ctx, RTEMS_FS_MAKE | RTEMS_FS_EXCLUSIVE ); - if (rootloc.ops != &IMFS_ops && rootloc.ops != &fifoIMFS_ops) { + + if ( + rootloc.mt_entry->ops != &IMFS_ops + && rootloc.mt_entry->ops != &fifoIMFS_ops + ) { rv = -1; } diff --git a/cpukit/libfs/src/imfs/memfile.c b/cpukit/libfs/src/imfs/memfile.c index 2907591bfb..2eb7949275 100644 --- a/cpukit/libfs/src/imfs/memfile.c +++ b/cpukit/libfs/src/imfs/memfile.c @@ -121,10 +121,16 @@ ssize_t memfile_read( ) { IMFS_jnode_t *the_jnode; + ssize_t status; the_jnode = iop->pathinfo.node_access; - return IMFS_memfile_read( the_jnode, iop->offset, buffer, count ); + status = IMFS_memfile_read( the_jnode, iop->offset, buffer, count ); + + if ( status > 0 ) + iop->offset += status; + + return status; } /* @@ -148,23 +154,10 @@ ssize_t memfile_write( status = IMFS_memfile_write( the_jnode, iop->offset, buffer, count ); - return status; -} + if ( status > 0 ) + iop->offset += status; -/* - * memfile_ioctl - * - * This routine processes the ioctl() system call. - * - * NOTE: No ioctl()'s are supported for in-memory files. - */ -int memfile_ioctl( - rtems_libio_t *iop, - uint32_t command, - void *buffer -) -{ - return 0; + return status; } /* diff --git a/cpukit/libfs/src/nfsclient/src/nfs.c b/cpukit/libfs/src/nfsclient/src/nfs.c index 1e25165bfc..372f078f14 100644 --- a/cpukit/libfs/src/nfsclient/src/nfs.c +++ b/cpukit/libfs/src/nfsclient/src/nfs.c @@ -1753,7 +1753,7 @@ char *path = mt_entry->dev; rootNode = 0; - mt_entry->mt_fs_root->location.ops = &nfs_fs_ops; + mt_entry->ops = &nfs_fs_ops; mt_entry->mt_fs_root->location.handlers = &nfs_dir_file_handlers; mt_entry->pathconf_limits_and_options = nfs_limits_and_options; @@ -2086,11 +2086,11 @@ static int nfs_rename( return rv; } -static void nfs_lock(rtems_filesystem_mount_table_entry_t *mt_entry) +static void nfs_lock(const rtems_filesystem_mount_table_entry_t *mt_entry) { } -static void nfs_unlock(rtems_filesystem_mount_table_entry_t *mt_entry) +static void nfs_unlock(const rtems_filesystem_mount_table_entry_t *mt_entry) { } @@ -2311,6 +2311,10 @@ static ssize_t nfs_file_read( } } while (count > 0); + if (rv > 0) { + iop->offset = offset; + } + return rv; } @@ -2419,6 +2423,8 @@ int e; node->age = nowSeconds(); + iop->offset += count; + return count; } diff --git a/cpukit/libfs/src/pipe/fifo.c b/cpukit/libfs/src/pipe/fifo.c index 20aa1ee4a2..d07346498a 100644 --- a/cpukit/libfs/src/pipe/fifo.c +++ b/cpukit/libfs/src/pipe/fifo.c @@ -612,10 +612,10 @@ static int pipe_select( * Interface to file system ioctl. */ int pipe_ioctl( - pipe_control_t *pipe, - uint32_t cmd, - void *buffer, - rtems_libio_t *iop + pipe_control_t *pipe, + ioctl_command_t cmd, + void *buffer, + rtems_libio_t *iop ) { int rv = 0; diff --git a/cpukit/libfs/src/pipe/pipe.h b/cpukit/libfs/src/pipe/pipe.h index 48ce183b4b..5795093497 100644 --- a/cpukit/libfs/src/pipe/pipe.h +++ b/cpukit/libfs/src/pipe/pipe.h @@ -98,10 +98,10 @@ extern ssize_t pipe_write( * Interface to file system ioctl. */ extern int pipe_ioctl( - pipe_control_t *pipe, - uint32_t cmd, - void *buffer, - rtems_libio_t *iop + pipe_control_t *pipe, + ioctl_command_t cmd, + void *buffer, + rtems_libio_t *iop ); #ifdef __cplusplus diff --git a/cpukit/libfs/src/rfs/rtems-rfs-rtems-dev.c b/cpukit/libfs/src/rfs/rtems-rfs-rtems-dev.c index 27d9962daa..ced234a796 100644 --- a/cpukit/libfs/src/rfs/rtems-rfs-rtems-dev.c +++ b/cpukit/libfs/src/rfs/rtems-rfs-rtems-dev.c @@ -18,12 +18,22 @@ */ #if HAVE_CONFIG_H -#include "config.h" + #include "config.h" #endif -#include <rtems/devfs.h> #include "rtems-rfs-rtems.h" +#include <rtems/deviceio.h> + +static void +rtems_rfs_rtems_device_get_major_and_minor ( const rtems_libio_t *iop, + rtems_device_major_number *major, + rtems_device_minor_number *minor) +{ + *major = iop->data0; + *minor = (rtems_device_minor_number) iop->data1; +} + /** * This handler maps an open() operation onto rtems_io_open(). * @@ -39,13 +49,11 @@ rtems_rfs_rtems_device_open ( rtems_libio_t *iop, int oflag, mode_t mode) { - rtems_libio_open_close_args_t args; rtems_rfs_file_system* fs = rtems_rfs_rtems_pathloc_dev (&iop->pathinfo); rtems_rfs_ino ino = rtems_rfs_rtems_get_iop_ino (iop); rtems_rfs_inode_handle inode; - int major; - int minor; - rtems_status_code status; + rtems_device_major_number major; + rtems_device_minor_number minor; int rc; rtems_rfs_rtems_lock (fs); @@ -70,15 +78,9 @@ rtems_rfs_rtems_device_open ( rtems_libio_t *iop, rtems_rfs_rtems_unlock (fs); iop->data0 = major; - iop->data1 = (void*)((intptr_t) minor); + iop->data1 = (void *) minor; - args.iop = iop; - args.flags = iop->flags; - args.mode = mode; - - status = rtems_io_open (major, minor, (void *) &args); - - return rtems_deviceio_errno (status); + return rtems_deviceio_open (iop, pathname, oflag, mode, minor, major); } /** @@ -91,21 +93,12 @@ rtems_rfs_rtems_device_open ( rtems_libio_t *iop, static int rtems_rfs_rtems_device_close (rtems_libio_t* iop) { - rtems_libio_open_close_args_t args; - rtems_status_code status; - int major; - int minor; - - major = (int) iop->data0; - minor = (intptr_t) iop->data1; + rtems_device_major_number major; + rtems_device_minor_number minor; - args.iop = iop; - args.flags = 0; - args.mode = 0; + rtems_rfs_rtems_device_get_major_and_minor (iop, &major, &minor); - status = rtems_io_close (major, minor, (void *) &args); - - return rtems_deviceio_errno (status); + return rtems_deviceio_close (iop, major, minor); } /** @@ -120,26 +113,12 @@ rtems_rfs_rtems_device_close (rtems_libio_t* iop) static ssize_t rtems_rfs_rtems_device_read (rtems_libio_t* iop, void* buffer, size_t count) { - rtems_libio_rw_args_t args; - rtems_status_code status; - int major; - int minor; - - major = (int) iop->data0; - minor = (intptr_t) iop->data1; - - args.iop = iop; - args.offset = iop->offset; - args.buffer = buffer; - args.count = count; - args.flags = iop->flags; - args.bytes_moved = 0; - - status = rtems_io_read (major, minor, (void *) &args); - if (status) - return rtems_deviceio_errno (status); - - return (ssize_t) args.bytes_moved; + rtems_device_major_number major; + rtems_device_minor_number minor; + + rtems_rfs_rtems_device_get_major_and_minor (iop, &major, &minor); + + return rtems_deviceio_read (iop, buffer, count, major, minor); } /* @@ -156,26 +135,12 @@ rtems_rfs_rtems_device_write (rtems_libio_t* iop, const void* buffer, size_t count) { - rtems_libio_rw_args_t args; - rtems_status_code status; - int major; - int minor; - - major = (int) iop->data0; - minor = (intptr_t) iop->data1; - - args.iop = iop; - args.offset = iop->offset; - args.buffer = (void *) buffer; - args.count = count; - args.flags = iop->flags; - args.bytes_moved = 0; - - status = rtems_io_write (major, minor, (void *) &args); - if (status) - return rtems_deviceio_errno (status); - - return (ssize_t) args.bytes_moved; + rtems_device_major_number major; + rtems_device_minor_number minor; + + rtems_rfs_rtems_device_get_major_and_minor (iop, &major, &minor); + + return rtems_deviceio_write (iop, buffer, count, major, minor); } /** @@ -188,27 +153,16 @@ rtems_rfs_rtems_device_write (rtems_libio_t* iop, */ static int -rtems_rfs_rtems_device_ioctl (rtems_libio_t* iop, - uint32_t command, - void* buffer) +rtems_rfs_rtems_device_ioctl (rtems_libio_t* iop, + ioctl_command_t command, + void* buffer) { - rtems_libio_ioctl_args_t args; - rtems_status_code status; - int major; - int minor; - - major = (int) iop->data0; - minor = (intptr_t) iop->data1; - - args.iop = iop; - args.command = command; - args.buffer = buffer; + rtems_device_major_number major; + rtems_device_minor_number minor; - status = rtems_io_control (major, minor, (void *) &args); - if (status) - return rtems_deviceio_errno (status); + rtems_rfs_rtems_device_get_major_and_minor (iop, &major, &minor); - return args.ioctl_return; + return rtems_deviceio_control (iop, command, buffer, major, minor); } /** diff --git a/cpukit/libfs/src/rfs/rtems-rfs-rtems-file.c b/cpukit/libfs/src/rfs/rtems-rfs-rtems-file.c index cf864c7347..7de04038e7 100644 --- a/cpukit/libfs/src/rfs/rtems-rfs-rtems-file.c +++ b/cpukit/libfs/src/rfs/rtems-rfs-rtems-file.c @@ -163,6 +163,9 @@ rtems_rfs_rtems_file_read (rtems_libio_t* iop, } } + if (read >= 0) + iop->offset = pos + read; + rtems_rfs_rtems_unlock (rtems_rfs_file_fs (file)); return read; @@ -220,7 +223,6 @@ rtems_rfs_rtems_file_write (rtems_libio_t* iop, rtems_rfs_rtems_unlock (rtems_rfs_file_fs (file)); return rtems_rfs_rtems_error ("file-write: write append seek", rc); } - iop->offset = pos; } while (count) @@ -251,28 +253,15 @@ rtems_rfs_rtems_file_write (rtems_libio_t* iop, } } + if (write >= 0) + iop->offset = pos + write; + rtems_rfs_rtems_unlock (rtems_rfs_file_fs (file)); return write; } /** - * This routine processes the ioctl() system call. - * - * @note No ioctl()'s are currently supported for RFS files. - * - * @param iop - * @param command - * @param buffer - */ - -static int -rtems_rfs_rtems_file_ioctl (rtems_libio_t* iop, uint32_t command, void* buffer) -{ - return 0; -} - -/** * This routine processes the lseek() system call. * * @param iop @@ -351,7 +340,7 @@ const rtems_filesystem_file_handlers_r rtems_rfs_rtems_file_handlers = { .close_h = rtems_rfs_rtems_file_close, .read_h = rtems_rfs_rtems_file_read, .write_h = rtems_rfs_rtems_file_write, - .ioctl_h = rtems_rfs_rtems_file_ioctl, + .ioctl_h = rtems_filesystem_default_ioctl, .lseek_h = rtems_rfs_rtems_file_lseek, .fstat_h = rtems_rfs_rtems_fstat, .ftruncate_h = rtems_rfs_rtems_file_ftruncate, diff --git a/cpukit/libfs/src/rfs/rtems-rfs-rtems.c b/cpukit/libfs/src/rfs/rtems-rfs-rtems.c index 6f6d3287c3..ba6c9056e6 100644 --- a/cpukit/libfs/src/rfs/rtems-rfs-rtems.c +++ b/cpukit/libfs/src/rfs/rtems-rfs-rtems.c @@ -73,7 +73,9 @@ rtems_rfs_rtems_node_type_by_inode (rtems_rfs_inode_handle* inode) } static void -rtems_rfs_rtems_lock_by_mt_entry (rtems_filesystem_mount_table_entry_t *mt_entry) +rtems_rfs_rtems_lock_by_mt_entry ( + const rtems_filesystem_mount_table_entry_t *mt_entry +) { rtems_rfs_file_system* fs = mt_entry->fs_info; @@ -81,7 +83,9 @@ rtems_rfs_rtems_lock_by_mt_entry (rtems_filesystem_mount_table_entry_t *mt_entry } static void -rtems_rfs_rtems_unlock_by_mt_entry (rtems_filesystem_mount_table_entry_t *mt_entry) +rtems_rfs_rtems_unlock_by_mt_entry ( + const rtems_filesystem_mount_table_entry_t *mt_entry +) { rtems_rfs_file_system* fs = mt_entry->fs_info; @@ -914,11 +918,10 @@ rtems_rfs_rtems_initialise (rtems_filesystem_mount_table_entry_t* mt_entry, return rtems_rfs_rtems_error ("initialise: open", rc); } - mt_entry->fs_info = fs; - + mt_entry->fs_info = fs; + mt_entry->ops = &rtems_rfs_ops; mt_entry->mt_fs_root->location.node_access = (void*) RTEMS_RFS_ROOT_INO; mt_entry->mt_fs_root->location.handlers = &rtems_rfs_rtems_dir_handlers; - mt_entry->mt_fs_root->location.ops = &rtems_rfs_ops; rtems_rfs_rtems_unlock (fs); diff --git a/cpukit/libnetworking/lib/ftpfs.c b/cpukit/libnetworking/lib/ftpfs.c index fad8f48a24..8c5f4db091 100644 --- a/cpukit/libnetworking/lib/ftpfs.c +++ b/cpukit/libnetworking/lib/ftpfs.c @@ -1194,7 +1194,7 @@ int rtems_ftpfs_initialize( /* Set handler and oparations table */ e->mt_fs_root->location.handlers = &rtems_ftpfs_root_handlers; - e->mt_fs_root->location.ops = &rtems_ftpfs_ops; + e->ops = &rtems_ftpfs_ops; /* We maintain no real file system nodes, so there is no real root */ e->mt_fs_root->location.node_access = NULL; diff --git a/cpukit/libnetworking/lib/tftpDriver.c b/cpukit/libnetworking/lib/tftpDriver.c index 3b81f54692..d549436c46 100644 --- a/cpukit/libnetworking/lib/tftpDriver.c +++ b/cpukit/libnetworking/lib/tftpDriver.c @@ -205,7 +205,7 @@ int rtems_tftpfs_initialize( mt_entry->fs_info = fs; mt_entry->mt_fs_root->location.node_access = root_path; mt_entry->mt_fs_root->location.handlers = &rtems_tftp_handlers; - mt_entry->mt_fs_root->location.ops = &rtems_tftp_ops; + mt_entry->ops = &rtems_tftp_ops; /* * Now allocate a semaphore for mutual exclusion. diff --git a/cpukit/libnetworking/rtems/rtems_bsdnet_internal.h b/cpukit/libnetworking/rtems/rtems_bsdnet_internal.h index faf601c735..d9be5af2d3 100644 --- a/cpukit/libnetworking/rtems/rtems_bsdnet_internal.h +++ b/cpukit/libnetworking/rtems/rtems_bsdnet_internal.h @@ -22,12 +22,6 @@ typedef long long vm_ooffset_t; typedef unsigned int vm_pindex_t; typedef unsigned int vm_size_t; -#ifndef __ioctl_command_defined -typedef u_int32_t ioctl_command_t; -#define __ioctl_command_defined -#endif - - #define _BSD_OFF_T_ int32_t #define _BSD_PID_T_ rtems_id #define _BSD_VA_LIST_ char * @@ -38,6 +32,7 @@ typedef u_int32_t ioctl_command_t; #include <sys/cdefs.h> #include <sys/time.h> +#include <sys/ioctl.h> struct mdproc { int md_flags; diff --git a/cpukit/libnetworking/rtems/rtems_syscall.c b/cpukit/libnetworking/rtems/rtems_syscall.c index d4a9e57b4f..727eac6ad2 100644 --- a/cpukit/libnetworking/rtems/rtems_syscall.c +++ b/cpukit/libnetworking/rtems/rtems_syscall.c @@ -88,7 +88,6 @@ rtems_bsdnet_makeFdForSocket (void *so) iop->data0 = fd; iop->data1 = so; iop->pathinfo.handlers = &socket_handlers; - iop->pathinfo.ops = &rtems_filesystem_operations_default; iop->pathinfo.mt_entry = &rtems_filesystem_null_mt_entry; rtems_filesystem_location_add_to_mt_entry(&iop->pathinfo); return fd; diff --git a/testsuites/fstests/fsnofs01/init.c b/testsuites/fstests/fsnofs01/init.c index 3ddc615ba2..9d7f98b053 100644 --- a/testsuites/fstests/fsnofs01/init.c +++ b/testsuites/fstests/fsnofs01/init.c @@ -53,7 +53,6 @@ static void rtems_test_assert_equal_to_null_loc( rtems_test_assert(null_loc->location.node_access == local_loc->node_access); rtems_test_assert(null_loc->location.node_access_2 == local_loc->node_access_2); rtems_test_assert(null_loc->location.handlers == local_loc->handlers); - rtems_test_assert(null_loc->location.ops == local_loc->ops); rtems_test_assert(null_loc->location.mt_entry == local_loc->mt_entry); } diff --git a/testsuites/libtests/Makefile.am b/testsuites/libtests/Makefile.am index 9724c1ab2b..1274f2637b 100644 --- a/testsuites/libtests/Makefile.am +++ b/testsuites/libtests/Makefile.am @@ -11,7 +11,7 @@ SUBDIRS += bspcmdline01 cpuuse devfs01 devfs02 devfs03 devfs04 \ termios termios01 termios02 termios03 termios04 termios05 \ termios06 termios07 termios08 \ rtems++ tztest block01 block02 block03 block04 block05 block06 block07 \ - block08 block09 block10 block11 stringto01 \ + block08 block09 block10 block11 block12 stringto01 \ tar01 tar02 tar03 \ math mathf mathl complex \ mouse01 diff --git a/testsuites/libtests/block12/Makefile.am b/testsuites/libtests/block12/Makefile.am new file mode 100644 index 0000000000..510cd1c4e7 --- /dev/null +++ b/testsuites/libtests/block12/Makefile.am @@ -0,0 +1,19 @@ +rtems_tests_PROGRAMS = block12 +block12_SOURCES = init.c + +dist_rtems_tests_DATA = block12.scn block12.doc + +include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg +include $(top_srcdir)/../automake/compile.am +include $(top_srcdir)/../automake/leaf.am + +AM_CPPFLAGS += -I$(top_srcdir)/../support/include + +LINK_OBJS = $(block12_OBJECTS) +LINK_LIBS = $(block12_LDLIBS) + +block12$(EXEEXT): $(block12_OBJECTS) $(block12_DEPENDENCIES) + @rm -f block12$(EXEEXT) + $(make-exe) + +include $(top_srcdir)/../automake/local.am diff --git a/testsuites/libtests/block12/block12.doc b/testsuites/libtests/block12/block12.doc new file mode 100644 index 0000000000..b5a345b91a --- /dev/null +++ b/testsuites/libtests/block12/block12.doc @@ -0,0 +1,11 @@ +This file describes the directives and concepts tested by this test set. + +test set name: block12 + +directives: + + rtems_bdbuf_purge_dev + +concepts: + + Ensures that the purge operation traverses the complete block tree diff --git a/testsuites/libtests/block12/block12.scn b/testsuites/libtests/block12/block12.scn new file mode 100644 index 0000000000..c27babbd26 --- /dev/null +++ b/testsuites/libtests/block12/block12.scn @@ -0,0 +1,2 @@ +*** TEST BLOCK 12 *** +*** END OF TEST BLOCK 12 *** diff --git a/testsuites/libtests/block12/init.c b/testsuites/libtests/block12/init.c new file mode 100644 index 0000000000..27bf631b2f --- /dev/null +++ b/testsuites/libtests/block12/init.c @@ -0,0 +1,153 @@ +/* + * Copyright (c) 2012 embedded brains GmbH. All rights reserved. + * + * embedded brains GmbH + * Obere Lagerstr. 30 + * 82178 Puchheim + * Germany + * <rtems@embedded-brains.de> + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.com/license/LICENSE. + */ + +#ifdef HAVE_CONFIG_H + #include "config.h" +#endif + +#include "tmacros.h" + +#include <errno.h> +#include <string.h> + +#include <rtems/blkdev.h> +#include <rtems/bdbuf.h> + +#define BLOCK_COUNT 15 + +static int block_access_counts [BLOCK_COUNT]; + +static int expected_block_access_counts [BLOCK_COUNT] = { + 2, 0, 2, 0, 2, 0, 2, 2, 2, 0, 2, 0, 2, 0, 2 +}; + +static const rtems_blkdev_bnum read_sequence [] = { + 0, 2, 4, 6, 8, 10, 12, 14, 7 +}; + +static int test_disk_ioctl(rtems_disk_device *dd, uint32_t req, void *arg) +{ + int rv = 0; + + if (req == RTEMS_BLKIO_REQUEST) { + rtems_blkdev_request *breq = arg; + rtems_blkdev_sg_buffer *sg = breq->bufs; + uint32_t i; + + rtems_test_assert(breq->req == RTEMS_BLKDEV_REQ_READ); + + for (i = 0; i < breq->bufnum; ++i) { + rtems_blkdev_bnum block = sg [i].block; + + rtems_test_assert(block < BLOCK_COUNT); + + ++block_access_counts [block]; + } + + breq->req_done(breq->done_arg, RTEMS_SUCCESSFUL); + } else { + errno = EINVAL; + rv = -1; + } + + return rv; +} + +static void do_read_sequence(rtems_disk_device *dd) +{ + size_t i; + + for (i = 0; i < sizeof(read_sequence) / sizeof(read_sequence [0]); ++i) { + rtems_status_code sc; + rtems_bdbuf_buffer *bd; + + sc = rtems_bdbuf_read(dd, read_sequence [i], &bd); + rtems_test_assert(sc == RTEMS_SUCCESSFUL); + + sc = rtems_bdbuf_release(bd); + rtems_test_assert(sc == RTEMS_SUCCESSFUL); + } +} + +static void test(void) +{ + rtems_status_code sc; + dev_t dev = 0; + rtems_disk_device *dd; + + sc = rtems_disk_io_initialize(); + rtems_test_assert(sc == RTEMS_SUCCESSFUL); + + sc = rtems_disk_create_phys( + dev, + 1, + BLOCK_COUNT, + test_disk_ioctl, + NULL, + NULL + ); + rtems_test_assert(sc == RTEMS_SUCCESSFUL); + + dd = rtems_disk_obtain(dev); + rtems_test_assert(dd != NULL); + + do_read_sequence(dd); + rtems_bdbuf_purge_dev(dd); + do_read_sequence(dd); + + rtems_test_assert( + memcmp( + block_access_counts, + expected_block_access_counts, + sizeof(block_access_counts) + ) == 0 + ); + + sc = rtems_disk_release(dd); + rtems_test_assert(sc == RTEMS_SUCCESSFUL); + + sc = rtems_disk_delete(dev); + rtems_test_assert(sc == RTEMS_SUCCESSFUL); +} + +static void Init(rtems_task_argument arg) +{ + puts("\n\n*** TEST BLOCK 12 ***"); + + test(); + + puts("*** END OF TEST BLOCK 12 ***"); + + rtems_test_exit(0); +} + +#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER +#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER +#define CONFIGURE_APPLICATION_NEEDS_LIBBLOCK + +#define CONFIGURE_BDBUF_BUFFER_MIN_SIZE 1 +#define CONFIGURE_BDBUF_BUFFER_MAX_SIZE 1 +#define CONFIGURE_BDBUF_CACHE_MEMORY_SIZE BLOCK_COUNT + +#define CONFIGURE_USE_IMFS_AS_BASE_FILESYSTEM + +#define CONFIGURE_MAXIMUM_TASKS 2 + +#define CONFIGURE_EXTRA_TASK_STACKS (8 * 1024) + +#define CONFIGURE_RTEMS_INIT_TASKS_TABLE + +#define CONFIGURE_INIT + +#include <rtems/confdefs.h> diff --git a/testsuites/libtests/configure.ac b/testsuites/libtests/configure.ac index 12ba1943e8..f6af3b11cd 100644 --- a/testsuites/libtests/configure.ac +++ b/testsuites/libtests/configure.ac @@ -55,6 +55,7 @@ block08/Makefile block09/Makefile block10/Makefile block11/Makefile +block12/Makefile bspcmdline01/Makefile cpuuse/Makefile devfs01/Makefile diff --git a/testsuites/psxtests/psxfile01/test.c b/testsuites/psxtests/psxfile01/test.c index 20a079277e..d817e655ab 100644 --- a/testsuites/psxtests/psxfile01/test.c +++ b/testsuites/psxtests/psxfile01/test.c @@ -334,9 +334,7 @@ int main( puts("create /tmp/john"); fd = open( "/tmp/john", O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO ); rtems_test_assert( fd != -1 ); - - puts("tcdrain /tmp/john" ); - status = tcdrain( fd ); + status = close( fd ); rtems_test_assert( status == 0 ); /* |