From c625a641218fbda23582354b3cfc7a7c7a4e4287 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Sun, 21 Dec 2014 20:12:28 +0100 Subject: Filesystem: Delete node type operation Use the fstat handler instead. --- c/src/lib/libbsp/shared/umon/tfsDriver.c | 15 ++++--- cpukit/libcsupport/Makefile.am | 1 - cpukit/libcsupport/include/rtems/libio.h | 35 --------------- cpukit/libcsupport/include/rtems/libio_.h | 35 ++++++++------- cpukit/libcsupport/src/__usrenv.c | 1 - cpukit/libcsupport/src/chdir.c | 5 +-- cpukit/libcsupport/src/chroot.c | 7 +-- cpukit/libcsupport/src/getdents.c | 6 +-- cpukit/libcsupport/src/open.c | 5 +-- cpukit/libcsupport/src/readlink.c | 4 +- cpukit/libcsupport/src/rmdir.c | 4 +- cpukit/libcsupport/src/sup_fs_node_type.c | 39 ----------------- cpukit/libfs/Makefile.am | 7 ++- cpukit/libfs/src/defaults/default_node_type.c | 29 ------------ cpukit/libfs/src/defaults/default_ops.c | 1 - cpukit/libfs/src/devfs/devfs.h | 16 ------- cpukit/libfs/src/devfs/devfs_init.c | 1 - cpukit/libfs/src/devfs/devfs_node_type.c | 31 ------------- cpukit/libfs/src/dosfs/fat_file.h | 10 ++--- cpukit/libfs/src/dosfs/msdos.h | 20 +++------ cpukit/libfs/src/dosfs/msdos_init.c | 1 - cpukit/libfs/src/dosfs/msdos_node_type.c | 61 -------------------------- cpukit/libfs/src/imfs/fifoimfs_init.c | 1 - cpukit/libfs/src/imfs/imfs.h | 20 +++------ cpukit/libfs/src/imfs/imfs_init.c | 1 - cpukit/libfs/src/imfs/imfs_ntype.c | 47 -------------------- cpukit/libfs/src/imfs/miniimfs_init.c | 1 - cpukit/libfs/src/jffs2/src/fs-rtems.c | 26 ----------- cpukit/libfs/src/nfsclient/src/nfs.c | 36 --------------- cpukit/libfs/src/rfs/rtems-rfs-rtems.c | 63 +-------------------------- cpukit/libnetworking/lib/ftpfs.c | 8 ---- cpukit/libnetworking/lib/tftpDriver.c | 15 ++++--- testsuites/fstests/fsimfsgeneric01/init.c | 21 ++++++--- 33 files changed, 83 insertions(+), 490 deletions(-) delete mode 100644 cpukit/libcsupport/src/sup_fs_node_type.c delete mode 100644 cpukit/libfs/src/defaults/default_node_type.c delete mode 100644 cpukit/libfs/src/devfs/devfs_node_type.c delete mode 100644 cpukit/libfs/src/dosfs/msdos_node_type.c delete mode 100644 cpukit/libfs/src/imfs/imfs_ntype.c diff --git a/c/src/lib/libbsp/shared/umon/tfsDriver.c b/c/src/lib/libbsp/shared/umon/tfsDriver.c index d4b67a1a8b..43651b0c0e 100644 --- a/c/src/lib/libbsp/shared/umon/tfsDriver.c +++ b/c/src/lib/libbsp/shared/umon/tfsDriver.c @@ -597,16 +597,18 @@ static int rtems_tfs_ioctl( return(0); } -static rtems_filesystem_node_types_t rtems_tfs_node_type( - const rtems_filesystem_location_info_t *loc +static int rtems_tfs_fstat( + const rtems_filesystem_location_info_t *loc, + struct stat *buf ) { const char *path = loc->node_access; size_t pathlen = strlen(path); - return rtems_tfs_is_directory(path, pathlen) ? - RTEMS_FILESYSTEM_DIRECTORY - : RTEMS_FILESYSTEM_MEMORY_FILE; + buf->st_mode = S_IRWXU | S_IRWXG | S_IRWXO + | (rtems_tfs_is_directory(path, pathlen) ? S_IFDIR : S_IFREG); + + return 0; } static int rtems_tfs_clone_node_info( @@ -646,7 +648,6 @@ static const rtems_filesystem_operations_table rtems_tfs_ops = { .eval_path_h = rtems_tfs_eval_path, .link_h = rtems_filesystem_default_link, .are_nodes_equal_h = rtems_tfs_are_nodes_equal, - .node_type_h = rtems_tfs_node_type, .mknod_h = rtems_filesystem_default_mknod, .rmnod_h = rtems_filesystem_default_rmnod, .fchmod_h = rtems_filesystem_default_fchmod, @@ -671,7 +672,7 @@ static const rtems_filesystem_file_handlers_r rtems_tfs_handlers = { .write_h = rtems_tfs_write, .ioctl_h = rtems_tfs_ioctl, .lseek_h = rtems_tfs_lseek, - .fstat_h = rtems_filesystem_default_fstat, + .fstat_h = rtems_tfs_fstat, .ftruncate_h = rtems_tfs_ftruncate, .fsync_h = rtems_filesystem_default_fsync_or_fdatasync, .fdatasync_h = rtems_filesystem_default_fsync_or_fdatasync, diff --git a/cpukit/libcsupport/Makefile.am b/cpukit/libcsupport/Makefile.am index 1486194aa7..77efdbbf14 100644 --- a/cpukit/libcsupport/Makefile.am +++ b/cpukit/libcsupport/Makefile.am @@ -139,7 +139,6 @@ libcsupport_a_SOURCES = src/gxx_wrappers.c src/getchark.c src/printk.c \ src/sup_fs_next_token.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/clonenode.c \ src/freenode.c \ diff --git a/cpukit/libcsupport/include/rtems/libio.h b/cpukit/libcsupport/include/rtems/libio.h index dabee60910..a4607de0e9 100644 --- a/cpukit/libcsupport/include/rtems/libio.h +++ b/cpukit/libcsupport/include/rtems/libio.h @@ -53,18 +53,6 @@ struct knote; */ /**@{**/ -/** - * @brief File system node types. - */ -typedef enum { - RTEMS_FILESYSTEM_DIRECTORY, - RTEMS_FILESYSTEM_DEVICE, - RTEMS_FILESYSTEM_HARD_LINK, - RTEMS_FILESYSTEM_SYM_LINK, - RTEMS_FILESYSTEM_MEMORY_FILE, - RTEMS_FILESYSTEM_INVALID_NODE_TYPE -} rtems_filesystem_node_types_t; - /** * @brief Locks a file system instance. * @@ -342,19 +330,6 @@ typedef bool (*rtems_filesystem_are_nodes_equal_t)( const rtems_filesystem_location_info_t *b ); -/** - * @brief Returns the node type. - * - * @param[in] loc The location of the node. - * - * @return Type of the node. - * - * @see rtems_filesystem_default_node_type(). - */ -typedef rtems_filesystem_node_types_t (*rtems_filesystem_node_type_t)( - const rtems_filesystem_location_info_t *loc -); - /** * @brief Creates a new node. * @@ -499,7 +474,6 @@ struct _rtems_filesystem_operations_table { rtems_filesystem_eval_path_t eval_path_h; rtems_filesystem_link_t link_h; rtems_filesystem_are_nodes_equal_t are_nodes_equal_h; - rtems_filesystem_node_type_t node_type_h; rtems_filesystem_mknod_t mknod_h; rtems_filesystem_rmnod_t rmnod_h; rtems_filesystem_fchmod_t fchmod_h; @@ -580,15 +554,6 @@ bool rtems_filesystem_default_are_nodes_equal( const rtems_filesystem_location_info_t *b ); -/** - * @retval RTEMS_FILESYSTEM_INVALID_NODE_TYPE Always. - * - * @see rtems_filesystem_node_type_t. - */ -rtems_filesystem_node_types_t rtems_filesystem_default_node_type( - const rtems_filesystem_location_info_t *pathloc -); - /** * @retval -1 Always. The errno is set to ENOTSUP. * diff --git a/cpukit/libcsupport/include/rtems/libio_.h b/cpukit/libcsupport/include/rtems/libio_.h index 458201ea3f..e204508cf1 100644 --- a/cpukit/libcsupport/include/rtems/libio_.h +++ b/cpukit/libcsupport/include/rtems/libio_.h @@ -205,21 +205,6 @@ void rtems_filesystem_location_clone( const rtems_filesystem_location_info_t *master ); -/** - * @brief Returns the type of a node. - * - * This function obtains and releases the file system instance lock. - * - * @param[in] loc The location of the node. - * - * @retval type The node type. - * - * @see rtems_filesystem_instance_lock(). - */ -rtems_filesystem_node_types_t rtems_filesystem_node_type( - const rtems_filesystem_location_info_t *loc -); - /** * @brief Releases all resources of a location. * @@ -919,6 +904,26 @@ static inline ssize_t rtems_libio_iovec_eval( return total; } +/** + * @brief Returns the file type of the file referenced by the filesystem + * location. + * + * @brief[in] loc The filesystem location. + * + * @return The type of the file or an invalid file type in case of an error. + */ +static inline mode_t rtems_filesystem_location_type( + const rtems_filesystem_location_info_t *loc +) +{ + struct stat st; + + st.st_mode = 0; + (void) ( *loc->handlers->fstat_h )( loc, &st ); + + return st.st_mode; +} + /** @} */ #ifdef __cplusplus diff --git a/cpukit/libcsupport/src/__usrenv.c b/cpukit/libcsupport/src/__usrenv.c index d032aea4ab..8fd107e011 100644 --- a/cpukit/libcsupport/src/__usrenv.c +++ b/cpukit/libcsupport/src/__usrenv.c @@ -203,7 +203,6 @@ static const rtems_filesystem_operations_table null_ops = { .eval_path_h = rtems_filesystem_default_eval_path, .link_h = null_op_link, .are_nodes_equal_h = rtems_filesystem_default_are_nodes_equal, - .node_type_h = rtems_filesystem_default_node_type, .mknod_h = null_op_mknod, .rmnod_h = null_op_rmnod, .fchmod_h = null_op_fchmod, diff --git a/cpukit/libcsupport/src/chdir.c b/cpukit/libcsupport/src/chdir.c index 2a1c3c4806..4bcb30075e 100644 --- a/cpukit/libcsupport/src/chdir.c +++ b/cpukit/libcsupport/src/chdir.c @@ -30,10 +30,9 @@ int rtems_filesystem_chdir( rtems_filesystem_location_info_t *loc ) int rv = 0; rtems_filesystem_global_location_t *global_loc = rtems_filesystem_location_transform_to_global( loc ); - rtems_filesystem_node_types_t type = - rtems_filesystem_node_type( &global_loc->location ); + mode_t type = rtems_filesystem_location_type( &global_loc->location ); - if ( type == RTEMS_FILESYSTEM_DIRECTORY ) { + if ( S_ISDIR( type ) ) { rtems_filesystem_global_location_assign( &rtems_filesystem_current, global_loc diff --git a/cpukit/libcsupport/src/chroot.c b/cpukit/libcsupport/src/chroot.c index e1f83d34ab..b7c2891f6a 100644 --- a/cpukit/libcsupport/src/chroot.c +++ b/cpukit/libcsupport/src/chroot.c @@ -54,12 +54,9 @@ int chroot( const char *path ) if ( !rtems_filesystem_global_location_is_null( new_current_loc ) ) { 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.mt_entry->ops->node_type_h)( - &new_root_loc->location - ); + mode_t type = rtems_filesystem_location_type( &new_root_loc->location ); - if ( type == RTEMS_FILESYSTEM_DIRECTORY ) { + if ( S_ISDIR( type ) ) { sc = rtems_libio_set_private_env(); if (sc == RTEMS_SUCCESSFUL) { rtems_filesystem_global_location_assign( diff --git a/cpukit/libcsupport/src/getdents.c b/cpukit/libcsupport/src/getdents.c index be1969faa4..7008def316 100644 --- a/cpukit/libcsupport/src/getdents.c +++ b/cpukit/libcsupport/src/getdents.c @@ -47,7 +47,7 @@ int getdents( ) { rtems_libio_t *iop; - rtems_filesystem_node_types_t type; + mode_t type; /* * Get the file control block structure associated with the file descriptor @@ -57,8 +57,8 @@ int getdents( /* * Make sure we are working on a directory */ - type = rtems_filesystem_node_type( &iop->pathinfo ); - if ( type != RTEMS_FILESYSTEM_DIRECTORY ) + type = rtems_filesystem_location_type( &iop->pathinfo ); + if ( !S_ISDIR( type ) ) rtems_set_errno_and_return_minus_one( ENOTDIR ); /* diff --git a/cpukit/libcsupport/src/open.c b/cpukit/libcsupport/src/open.c index 042d405f1d..399b5a4eac 100644 --- a/cpukit/libcsupport/src/open.c +++ b/cpukit/libcsupport/src/open.c @@ -89,10 +89,9 @@ static int do_open( if ( write_access ) { const rtems_filesystem_location_info_t *currentloc = rtems_filesystem_eval_path_get_currentloc( &ctx ); - rtems_filesystem_node_types_t type = - (*currentloc->mt_entry->ops->node_type_h)( currentloc ); + mode_t type = rtems_filesystem_location_type( currentloc ); - if ( type == RTEMS_FILESYSTEM_DIRECTORY ) { + if ( S_ISDIR( type ) ) { rtems_filesystem_eval_path_error( &ctx, EISDIR ); } } diff --git a/cpukit/libcsupport/src/readlink.c b/cpukit/libcsupport/src/readlink.c index a43cb2cdf9..71a9d0d726 100644 --- a/cpukit/libcsupport/src/readlink.c +++ b/cpukit/libcsupport/src/readlink.c @@ -34,9 +34,9 @@ ssize_t readlink( const char *__restrict path, char *__restrict buf, 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; - rtems_filesystem_node_types_t type = (*ops->node_type_h)( currentloc ); + mode_t type = rtems_filesystem_location_type( currentloc ); - if ( type == RTEMS_FILESYSTEM_SYM_LINK ) { + if ( S_ISLNK( type ) ) { rv = (*ops->readlink_h)( currentloc, buf, bufsize ); } else { rtems_filesystem_eval_path_error( &ctx, EINVAL ); diff --git a/cpukit/libcsupport/src/rmdir.c b/cpukit/libcsupport/src/rmdir.c index 50c41d5f74..8aec6f784e 100644 --- a/cpukit/libcsupport/src/rmdir.c +++ b/cpukit/libcsupport/src/rmdir.c @@ -43,9 +43,9 @@ int rmdir( const char *path ) parent_eval_flags ); const rtems_filesystem_operations_table *ops = currentloc->mt_entry->ops; - rtems_filesystem_node_types_t type = (*ops->node_type_h)( currentloc ); + mode_t type = rtems_filesystem_location_type( currentloc ); - if ( type == RTEMS_FILESYSTEM_DIRECTORY ) { + if ( S_ISDIR( type ) ) { if ( !rtems_filesystem_location_is_instance_root( currentloc ) ) { rv = (*ops->rmnod_h)( &parentloc, currentloc ); } else { diff --git a/cpukit/libcsupport/src/sup_fs_node_type.c b/cpukit/libcsupport/src/sup_fs_node_type.c deleted file mode 100644 index a86d08e56d..0000000000 --- a/cpukit/libcsupport/src/sup_fs_node_type.c +++ /dev/null @@ -1,39 +0,0 @@ -/** - * @file - * - * @brief Returns the Type of a Node - * @ingroup LibIOInternal - */ - -/* - * Copyright (c) 2012 embedded brains GmbH. All rights reserved. - * - * embedded brains GmbH - * Obere Lagerstr. 30 - * 82178 Puchheim - * Germany - * - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#if HAVE_CONFIG_H - #include "config.h" -#endif - -#include - -rtems_filesystem_node_types_t rtems_filesystem_node_type( - const rtems_filesystem_location_info_t *loc -) -{ - rtems_filesystem_node_types_t type; - - rtems_filesystem_instance_lock(loc); - type = (*loc->mt_entry->ops->node_type_h)(loc); - rtems_filesystem_instance_unlock(loc); - - return type; -} diff --git a/cpukit/libfs/Makefile.am b/cpukit/libfs/Makefile.am index b8c7790ed7..b255d1c3f1 100644 --- a/cpukit/libfs/Makefile.am +++ b/cpukit/libfs/Makefile.am @@ -30,7 +30,6 @@ libdefaultfs_a_SOURCES = \ src/defaults/default_unmount.c \ src/defaults/default_open.c src/defaults/default_close.c \ src/defaults/default_fsunmount.c src/defaults/default_mknod.c \ - src/defaults/default_node_type.c \ src/defaults/default_ftruncate_directory.c \ src/defaults/default_handlers.c src/defaults/default_ops.c libdefaultfs_a_SOURCES += src/defaults/default_kqfilter.c @@ -52,7 +51,7 @@ libimfs_a_SOURCES += src/imfs/deviceio.c \ src/imfs/imfs_handlers_directory.c src/imfs/imfs_handlers_link.c \ src/imfs/imfs_handlers_memfile.c src/imfs/imfs_init.c \ src/imfs/imfs_initsupp.c src/imfs/imfs_link.c src/imfs/imfs_load_tar.c \ - src/imfs/imfs_mknod.c src/imfs/imfs_mount.c src/imfs/imfs_ntype.c \ + src/imfs/imfs_mknod.c src/imfs/imfs_mount.c \ src/imfs/imfs_readlink.c src/imfs/imfs_rename.c src/imfs/imfs_rmnod.c \ src/imfs/imfs_stat.c src/imfs/imfs_symlink.c \ src/imfs/imfs_unmount.c src/imfs/imfs_utime.c src/imfs/ioman.c \ @@ -64,7 +63,7 @@ libimfs_a_SOURCES += src/pipe/fifo.c src/pipe/pipe.c src/pipe/pipe.h noinst_LIBRARIES += libdevfs.a libdevfs_a_SOURCES = src/devfs/devfs_init.c src/devfs/devfs_eval.c \ src/devfs/devfs_mknod.c src/devfs/devfs_show.c \ - src/devfs/devfs_node_type.c src/devfs/devopen.c src/devfs/devread.c \ + src/devfs/devopen.c src/devfs/devread.c \ src/devfs/devwrite.c src/devfs/devclose.c src/devfs/devioctl.c \ src/devfs/devstat.c src/devfs/devfs.h @@ -83,7 +82,7 @@ libdosfs_a_SOURCES += src/dosfs/msdos_create.c src/dosfs/msdos_dir.c \ src/dosfs/msdos_fsunmount.c src/dosfs/msdos_handlers_dir.c \ src/dosfs/msdos_handlers_file.c src/dosfs/msdos_init.c \ src/dosfs/msdos_initsupp.c src/dosfs/msdos_misc.c \ - src/dosfs/msdos_mknod.c src/dosfs/msdos_node_type.c \ + src/dosfs/msdos_mknod.c \ src/dosfs/msdos_rmnod.c src/dosfs/msdos_statvfs.c \ src/dosfs/msdos_conv_default.c \ src/dosfs/msdos_conv_utf8.c \ diff --git a/cpukit/libfs/src/defaults/default_node_type.c b/cpukit/libfs/src/defaults/default_node_type.c deleted file mode 100644 index f15be86a38..0000000000 --- a/cpukit/libfs/src/defaults/default_node_type.c +++ /dev/null @@ -1,29 +0,0 @@ -/** - * @file - * - * @ingroup LibIO - * - * @brief rtems_filesystem_default_node_type() implementation. - */ - -/* - * Copyright (c) 2010 - * embedded brains GmbH - * Obere Lagerstr. 30 - * D-82178 Puchheim - * Germany - * - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#include - -rtems_filesystem_node_types_t rtems_filesystem_default_node_type( - const rtems_filesystem_location_info_t *loc -) -{ - return RTEMS_FILESYSTEM_INVALID_NODE_TYPE; -} diff --git a/cpukit/libfs/src/defaults/default_ops.c b/cpukit/libfs/src/defaults/default_ops.c index 4c43df077b..274336f976 100644 --- a/cpukit/libfs/src/defaults/default_ops.c +++ b/cpukit/libfs/src/defaults/default_ops.c @@ -27,7 +27,6 @@ const rtems_filesystem_operations_table rtems_filesystem_operations_default = { .eval_path_h = rtems_filesystem_default_eval_path, .link_h = rtems_filesystem_default_link, .are_nodes_equal_h = rtems_filesystem_default_are_nodes_equal, - .node_type_h = rtems_filesystem_default_node_type, .mknod_h = rtems_filesystem_default_mknod, .rmnod_h = rtems_filesystem_default_rmnod, .fchmod_h = rtems_filesystem_default_fchmod, diff --git a/cpukit/libfs/src/devfs/devfs.h b/cpukit/libfs/src/devfs/devfs.h index 0213e072f9..6b8fae1795 100644 --- a/cpukit/libfs/src/devfs/devfs.h +++ b/cpukit/libfs/src/devfs/devfs.h @@ -190,22 +190,6 @@ extern int devFS_stat( struct stat *buf ); -/** - * @brief Invoked upon Determination of a Node Type - * - * This routine is invoked upon determination of a node type. - * Since this is a device-only filesystem, so there is only - * one node type in the system. - * - * @param loc contains filesytem access information, this - * parameter is ignored - * - * @retval always returns RTEMS_FILESYSTEM_DEVICE - */ -extern rtems_filesystem_node_types_t devFS_node_type( - const rtems_filesystem_location_info_t*loc -); - /** * @brief Creates an item in the main device table. * diff --git a/cpukit/libfs/src/devfs/devfs_init.c b/cpukit/libfs/src/devfs/devfs_init.c index b1419e9491..9fafc6adf0 100644 --- a/cpukit/libfs/src/devfs/devfs_init.c +++ b/cpukit/libfs/src/devfs/devfs_init.c @@ -23,7 +23,6 @@ const rtems_filesystem_operations_table devFS_ops = { .eval_path_h = devFS_eval_path, .link_h = rtems_filesystem_default_link, .are_nodes_equal_h = rtems_filesystem_default_are_nodes_equal, - .node_type_h = devFS_node_type, .mknod_h = devFS_mknod, .rmnod_h = rtems_filesystem_default_rmnod, .fchmod_h = rtems_filesystem_default_fchmod, diff --git a/cpukit/libfs/src/devfs/devfs_node_type.c b/cpukit/libfs/src/devfs/devfs_node_type.c deleted file mode 100644 index 2c1e7f469b..0000000000 --- a/cpukit/libfs/src/devfs/devfs_node_type.c +++ /dev/null @@ -1,31 +0,0 @@ -/** - * @file - * - * @brief Invoked upon Determination of a Node Type - * @ingroup DevFsDeviceTable Define Device Table Type - */ - -/* - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#if HAVE_CONFIG_H -#include "config.h" -#endif - -#include "devfs.h" - -rtems_filesystem_node_types_t devFS_node_type( - const rtems_filesystem_location_info_t *loc -) -{ - /* - * There is only one type of node: device - */ - - return RTEMS_FILESYSTEM_DEVICE; -} - - diff --git a/cpukit/libfs/src/dosfs/fat_file.h b/cpukit/libfs/src/dosfs/fat_file.h index 1a75cf75ce..9905757e6f 100644 --- a/cpukit/libfs/src/dosfs/fat_file.h +++ b/cpukit/libfs/src/dosfs/fat_file.h @@ -37,6 +37,11 @@ extern "C" { #endif +typedef enum { + FAT_DIRECTORY = 0, + FAT_FILE = 4 +} fat_file_type_t; + /** * @brief The "fat-file" representation. * @@ -52,11 +57,6 @@ extern "C" { * Such interface hides the architecture of fat-file and represents it like * linear file */ -typedef rtems_filesystem_node_types_t fat_file_type_t; - -#define FAT_DIRECTORY RTEMS_FILESYSTEM_DIRECTORY -#define FAT_FILE RTEMS_FILESYSTEM_MEMORY_FILE - typedef struct fat_file_map_s { uint32_t file_cln; diff --git a/cpukit/libfs/src/dosfs/msdos.h b/cpukit/libfs/src/dosfs/msdos.h index baa34d7a6e..e6cffbba91 100644 --- a/cpukit/libfs/src/dosfs/msdos.h +++ b/cpukit/libfs/src/dosfs/msdos.h @@ -86,17 +86,11 @@ extern const rtems_filesystem_file_handlers_r msdos_file_handlers; #define MSDOS_VOLUME_SEMAPHORE_TIMEOUT RTEMS_NO_TIMEOUT /* Node types */ -#define MSDOS_DIRECTORY RTEMS_FILESYSTEM_DIRECTORY -#define MSDOS_REGULAR_FILE RTEMS_FILESYSTEM_MEMORY_FILE -#define MSDOS_HARD_LINK RTEMS_FILESYSTEM_HARD_LINK /* pseudo type */ - -/** - * @brief Type of node that loc refers to. - * - * The following returns the type of node that the loc refers to. - * - */ -typedef rtems_filesystem_node_types_t msdos_node_type_t; +typedef enum { + MSDOS_DIRECTORY = 0, + MSDOS_REGULAR_FILE = 4, + MSDOS_HARD_LINK = 2 /* pseudo type */ +} msdos_node_type_t; /* * Macros for fetching fields from 32 bytes long FAT Directory Entry @@ -274,10 +268,6 @@ void msdos_eval_path(rtems_filesystem_eval_path_context_t *ctx); */ void msdos_free_node_info(const rtems_filesystem_location_info_t *pathloc); -rtems_filesystem_node_types_t msdos_node_type( - const rtems_filesystem_location_info_t *loc -); - /** * @brief Routine for node creation in a MSDOS filesystem. * diff --git a/cpukit/libfs/src/dosfs/msdos_init.c b/cpukit/libfs/src/dosfs/msdos_init.c index 08c8136bde..3414563b0c 100644 --- a/cpukit/libfs/src/dosfs/msdos_init.c +++ b/cpukit/libfs/src/dosfs/msdos_init.c @@ -57,7 +57,6 @@ const rtems_filesystem_operations_table msdos_ops = { .eval_path_h = msdos_eval_path, .link_h = rtems_filesystem_default_link, .are_nodes_equal_h = rtems_filesystem_default_are_nodes_equal, - .node_type_h = msdos_node_type, .mknod_h = msdos_mknod, .rmnod_h = msdos_rmnod, .fchmod_h = rtems_filesystem_default_fchmod, diff --git a/cpukit/libfs/src/dosfs/msdos_node_type.c b/cpukit/libfs/src/dosfs/msdos_node_type.c deleted file mode 100644 index 2aa8d2ec72..0000000000 --- a/cpukit/libfs/src/dosfs/msdos_node_type.c +++ /dev/null @@ -1,61 +0,0 @@ -/** - * @file - * - * @brief Type of Node that Loc Refers To - * @ingroup libfs_msdos MSDOS FileSystem - */ - -/* - * Copyright (C) 2001 OKTET Ltd., St.-Petersburg, Russia - * Author: Eugeny S. Mints - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#if HAVE_CONFIG_H -#include "config.h" -#endif - -#include -#include -#include -#include -#include -#include -#include - -#include - -#include "fat.h" -#include "fat_fat_operations.h" -#include "fat_file.h" - -#include "msdos.h" - -/* msdos_node_type -- - * Determine type of the node that the loc refers to. - * - * PARAMETERS: - * loc - node description - * - * RETURNS: - * node type - * - */ -rtems_filesystem_node_types_t -msdos_node_type(const rtems_filesystem_location_info_t *loc) -{ - fat_file_fd_t *fat_fd; - - /* - * we don't need to obtain the volume semaphore here because node_type_h - * call always follows evalpath_h call(hence link increment occured) and - * hence node_access memory can't be freed during processing node_type_h - * call - */ - fat_fd = loc->node_access; - - return fat_fd->fat_file_type; -} diff --git a/cpukit/libfs/src/imfs/fifoimfs_init.c b/cpukit/libfs/src/imfs/fifoimfs_init.c index d540139f55..81041e9902 100644 --- a/cpukit/libfs/src/imfs/fifoimfs_init.c +++ b/cpukit/libfs/src/imfs/fifoimfs_init.c @@ -31,7 +31,6 @@ const rtems_filesystem_operations_table fifoIMFS_ops = { .eval_path_h = IMFS_eval_path, .link_h = IMFS_link, .are_nodes_equal_h = rtems_filesystem_default_are_nodes_equal, - .node_type_h = IMFS_node_type, .mknod_h = IMFS_mknod, .rmnod_h = IMFS_rmnod, .fchmod_h = IMFS_fchmod, diff --git a/cpukit/libfs/src/imfs/imfs.h b/cpukit/libfs/src/imfs/imfs.h index 7dca51f97a..c34f89fd15 100644 --- a/cpukit/libfs/src/imfs/imfs.h +++ b/cpukit/libfs/src/imfs/imfs.h @@ -136,11 +136,11 @@ typedef struct { * What types of IMFS file systems entities there can be. */ typedef enum { - IMFS_DIRECTORY = RTEMS_FILESYSTEM_DIRECTORY, - IMFS_DEVICE = RTEMS_FILESYSTEM_DEVICE, - IMFS_HARD_LINK = RTEMS_FILESYSTEM_HARD_LINK, - IMFS_SYM_LINK = RTEMS_FILESYSTEM_SYM_LINK, - IMFS_MEMORY_FILE = RTEMS_FILESYSTEM_MEMORY_FILE, + IMFS_DIRECTORY, + IMFS_DEVICE, + IMFS_HARD_LINK, + IMFS_SYM_LINK, + IMFS_MEMORY_FILE, IMFS_LINEAR_FILE, IMFS_FIFO, IMFS_GENERIC, @@ -514,16 +514,6 @@ extern int IMFS_node_clone( rtems_filesystem_location_info_t *loc ); */ extern void IMFS_node_free( const rtems_filesystem_location_info_t *loc ); -/** - * @brief IMFS Node Type Get the type of an IMFS node. - * - * The following verifies that returns the type of node that the - * loc refers to. - */ -extern rtems_filesystem_node_types_t IMFS_node_type( - const rtems_filesystem_location_info_t *loc -); - /** * @brief Perform a status processing for the IMFS. * diff --git a/cpukit/libfs/src/imfs/imfs_init.c b/cpukit/libfs/src/imfs/imfs_init.c index 8c434ebcba..596f81bdda 100644 --- a/cpukit/libfs/src/imfs/imfs_init.c +++ b/cpukit/libfs/src/imfs/imfs_init.c @@ -27,7 +27,6 @@ const rtems_filesystem_operations_table IMFS_ops = { .eval_path_h = IMFS_eval_path, .link_h = IMFS_link, .are_nodes_equal_h = rtems_filesystem_default_are_nodes_equal, - .node_type_h = IMFS_node_type, .mknod_h = IMFS_mknod, .rmnod_h = IMFS_rmnod, .fchmod_h = IMFS_fchmod, diff --git a/cpukit/libfs/src/imfs/imfs_ntype.c b/cpukit/libfs/src/imfs/imfs_ntype.c deleted file mode 100644 index 0c92bc9c15..0000000000 --- a/cpukit/libfs/src/imfs/imfs_ntype.c +++ /dev/null @@ -1,47 +0,0 @@ -/** - * @file - * - * @brief IMFS Node Type - * @ingroup IMFS - */ - -/* - * COPYRIGHT (c) 1989-1999. - * On-Line Applications Research Corporation (OAR). - * - * Modifications to support reference counting in the file system are - * Copyright (c) 2012 embedded brains GmbH. - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#if HAVE_CONFIG_H - #include "config.h" -#endif - -#include "imfs.h" - -rtems_filesystem_node_types_t IMFS_node_type( - const rtems_filesystem_location_info_t *loc -) -{ - const IMFS_jnode_t *node = loc->node_access; - IMFS_jnode_types_t imfs_type = IMFS_type( node ); - rtems_filesystem_node_types_t type; - - switch ( imfs_type ) { - case IMFS_HARD_LINK: - type = IMFS_type( node->info.hard_link.link_node ); - break; - case IMFS_LINEAR_FILE: - type = RTEMS_FILESYSTEM_MEMORY_FILE; - break; - default: - type = imfs_type; - break; - } - - return type; -} diff --git a/cpukit/libfs/src/imfs/miniimfs_init.c b/cpukit/libfs/src/imfs/miniimfs_init.c index 11fc9bc210..9e0ca0b033 100644 --- a/cpukit/libfs/src/imfs/miniimfs_init.c +++ b/cpukit/libfs/src/imfs/miniimfs_init.c @@ -27,7 +27,6 @@ const rtems_filesystem_operations_table miniIMFS_ops = { .eval_path_h = IMFS_eval_path, .link_h = rtems_filesystem_default_link, .are_nodes_equal_h = rtems_filesystem_default_are_nodes_equal, - .node_type_h = IMFS_node_type, .mknod_h = IMFS_mknod, .rmnod_h = IMFS_rmnod, .fchmod_h = rtems_filesystem_default_fchmod, diff --git a/cpukit/libfs/src/jffs2/src/fs-rtems.c b/cpukit/libfs/src/jffs2/src/fs-rtems.c index d9d6864e7f..961cfa34df 100644 --- a/cpukit/libfs/src/jffs2/src/fs-rtems.c +++ b/cpukit/libfs/src/jffs2/src/fs-rtems.c @@ -845,31 +845,6 @@ static bool rtems_jffs2_are_nodes_equal( return inode_a->i_ino == inode_b->i_ino; } -static rtems_filesystem_node_types_t rtems_jffs2_node_type( - const rtems_filesystem_location_info_t *loc -) -{ - struct _inode *inode = rtems_jffs2_get_inode_by_location(loc); - rtems_filesystem_node_types_t type; - - switch (inode->i_mode & S_IFMT) { - case S_IFDIR: - type = RTEMS_FILESYSTEM_DIRECTORY; - break; - case S_IFREG: - type = RTEMS_FILESYSTEM_MEMORY_FILE; - break; - case S_IFLNK: - type = RTEMS_FILESYSTEM_SYM_LINK; - break; - default: - type = RTEMS_FILESYSTEM_INVALID_NODE_TYPE; - break; - } - - return type; -} - static int rtems_jffs2_mknod( const rtems_filesystem_location_info_t *parentloc, const char *name, @@ -1123,7 +1098,6 @@ static const rtems_filesystem_operations_table rtems_jffs2_ops = { .eval_path_h = rtems_jffs2_eval_path, .link_h = rtems_jffs2_link, .are_nodes_equal_h = rtems_jffs2_are_nodes_equal, - .node_type_h = rtems_jffs2_node_type, .mknod_h = rtems_jffs2_mknod, .rmnod_h = rtems_jffs2_rmnod, .fchmod_h = rtems_jffs2_fchmod, diff --git a/cpukit/libfs/src/nfsclient/src/nfs.c b/cpukit/libfs/src/nfsclient/src/nfs.c index 9b19bf4dcd..9ce5924ca8 100644 --- a/cpukit/libfs/src/nfsclient/src/nfs.c +++ b/cpukit/libfs/src/nfsclient/src/nfs.c @@ -1988,41 +1988,6 @@ LOCK(nfsGlob.llock); UNLOCK(nfsGlob.llock); } -/* OPTIONAL; may be NULL - BUT: CAUTION; mount() doesn't check - * for this handler to be present - a fs bug - * //NOTE: (10/25/2002) patch submitted and probably applied - */ -static rtems_filesystem_node_types_t nfs_node_type( - const rtems_filesystem_location_info_t *loc -) -{ -NfsNode node = loc->node_access; - - if (updateAttr(node, 0 /* only if old */)) - return -1; - - switch( SERP_ATTR(node).type ) { - default: - /* rtems has no value for 'unknown'; - */ - case NFNON: - case NFSOCK: - case NFBAD: - case NFFIFO: - break; - - - case NFREG: return RTEMS_FILESYSTEM_MEMORY_FILE; - case NFDIR: return RTEMS_FILESYSTEM_DIRECTORY; - - case NFBLK: - case NFCHR: return RTEMS_FILESYSTEM_DEVICE; - - case NFLNK: return RTEMS_FILESYSTEM_SYM_LINK; - } - return -1; -} - static int nfs_mknod( const rtems_filesystem_location_info_t *parentloc, const char *name, @@ -2315,7 +2280,6 @@ const struct _rtems_filesystem_operations_table nfs_fs_ops = { .eval_path_h = nfs_eval_path, .link_h = nfs_link, .are_nodes_equal_h = nfs_are_nodes_equal, - .node_type_h = nfs_node_type, .mknod_h = nfs_mknod, .rmnod_h = nfs_rmnod, .fchmod_h = nfs_fchmod, diff --git a/cpukit/libfs/src/rfs/rtems-rfs-rtems.c b/cpukit/libfs/src/rfs/rtems-rfs-rtems.c index 4dcb827824..4a38ee7510 100644 --- a/cpukit/libfs/src/rfs/rtems-rfs-rtems.c +++ b/cpukit/libfs/src/rfs/rtems-rfs-rtems.c @@ -52,28 +52,6 @@ rtems_rfs_rtems_eval_perms (rtems_filesystem_eval_path_context_t *ctx, ); } -static rtems_filesystem_node_types_t -rtems_rfs_rtems_node_type_by_inode (rtems_rfs_inode_handle* inode) -{ - /* - * Do not return RTEMS_FILESYSTEM_HARD_LINK because this would result in an - * eval link which does not make sense in the case of the RFS file - * system. All directory entries are links to an inode. A link such as a HARD - * link is actually the normal path to a regular file, directory, device - * etc's inode. Links to inodes can be considered "the real" one, yet they - * are all links. - */ - uint16_t mode = rtems_rfs_inode_get_mode (inode); - if (RTEMS_RFS_S_ISDIR (mode)) - return RTEMS_FILESYSTEM_DIRECTORY; - else if (RTEMS_RFS_S_ISLNK (mode)) - return RTEMS_FILESYSTEM_SYM_LINK; - else if (RTEMS_RFS_S_ISBLK (mode) || RTEMS_RFS_S_ISCHR (mode)) - return RTEMS_FILESYSTEM_DEVICE; - else - return RTEMS_FILESYSTEM_MEMORY_FILE; -} - static void rtems_rfs_rtems_lock_by_mt_entry ( const rtems_filesystem_mount_table_entry_t *mt_entry @@ -102,8 +80,7 @@ rtems_rfs_rtems_is_directory( { rtems_rfs_inode_handle* inode = arg; - return rtems_rfs_rtems_node_type_by_inode (inode) - == RTEMS_FILESYSTEM_DIRECTORY; + return S_ISDIR (rtems_rfs_inode_get_mode (inode)); } static void rtems_rfs_rtems_follow_link( @@ -180,8 +157,7 @@ rtems_rfs_rtems_eval_token( } if (rc == 0) { - bool is_sym_link = rtems_rfs_rtems_node_type_by_inode (inode) - == RTEMS_FILESYSTEM_SYM_LINK; + bool is_sym_link = S_ISLNK (rtems_rfs_inode_get_mode (inode)); int eval_flags = rtems_filesystem_eval_path_get_flags (ctx); bool follow_sym_link = (eval_flags & RTEMS_FS_FOLLOW_SYM_LINK) != 0; bool terminal = !rtems_filesystem_eval_path_has_path (ctx); @@ -280,40 +256,6 @@ rtems_rfs_rtems_link (const rtems_filesystem_location_info_t *parentloc, return 0; } -/** - * The following verifies that and returns the type of node that the loc refers - * to. - * - * @param pathloc - * @return rtems_filesystem_node_types_t - */ - -static rtems_filesystem_node_types_t -rtems_rfs_rtems_node_type (const rtems_filesystem_location_info_t* pathloc) -{ - rtems_rfs_file_system* fs = rtems_rfs_rtems_pathloc_dev (pathloc); - rtems_rfs_ino ino = rtems_rfs_rtems_get_pathloc_ino (pathloc); - rtems_filesystem_node_types_t type; - rtems_rfs_inode_handle inode; - int rc; - - rc = rtems_rfs_inode_open (fs, ino, &inode, true); - if (rc > 0) - { - return rtems_rfs_rtems_error ("node_type: opening inode", rc); - } - - type = rtems_rfs_rtems_node_type_by_inode (&inode); - - rc = rtems_rfs_inode_close (fs, &inode); - if (rc > 0) - { - return rtems_rfs_rtems_error ("node_type: closing inode", rc); - } - - return type; -} - /** * This routine is the implementation of the chown() system call for the * RFS. @@ -805,7 +747,6 @@ const rtems_filesystem_operations_table rtems_rfs_ops = .are_nodes_equal_h = rtems_filesystem_default_are_nodes_equal, .eval_path_h = rtems_rfs_rtems_eval_path, .link_h = rtems_rfs_rtems_link, - .node_type_h = rtems_rfs_rtems_node_type, .fchmod_h = rtems_rfs_rtems_fchmod, .mknod_h = rtems_rfs_rtems_mknod, .rmnod_h = rtems_rfs_rtems_rmnod, diff --git a/cpukit/libnetworking/lib/ftpfs.c b/cpukit/libnetworking/lib/ftpfs.c index 9a4fd86787..9a13c8e98c 100644 --- a/cpukit/libnetworking/lib/ftpfs.c +++ b/cpukit/libnetworking/lib/ftpfs.c @@ -1260,13 +1260,6 @@ static void rtems_ftpfs_free_node(const rtems_filesystem_location_info_t *loc) } } -static rtems_filesystem_node_types_t rtems_ftpfs_node_type( - const rtems_filesystem_location_info_t *loc -) -{ - return RTEMS_FILESYSTEM_MEMORY_FILE; -} - int rtems_ftpfs_initialize( rtems_filesystem_mount_table_entry_t *e, const void *d @@ -1383,7 +1376,6 @@ static const rtems_filesystem_operations_table rtems_ftpfs_ops = { .eval_path_h = rtems_ftpfs_eval_path, .link_h = rtems_filesystem_default_link, .are_nodes_equal_h = rtems_filesystem_default_are_nodes_equal, - .node_type_h = rtems_ftpfs_node_type, .mknod_h = rtems_filesystem_default_mknod, .rmnod_h = rtems_filesystem_default_rmnod, .fchmod_h = rtems_filesystem_default_fchmod, diff --git a/cpukit/libnetworking/lib/tftpDriver.c b/cpukit/libnetworking/lib/tftpDriver.c index 414012a1ec..b114a498d9 100644 --- a/cpukit/libnetworking/lib/tftpDriver.c +++ b/cpukit/libnetworking/lib/tftpDriver.c @@ -973,16 +973,18 @@ static int rtems_tftp_ftruncate( return 0; } -static rtems_filesystem_node_types_t rtems_tftp_node_type( - const rtems_filesystem_location_info_t *loc +static int rtems_tftp_fstat( + const rtems_filesystem_location_info_t *loc, + struct stat *buf ) { const char *path = loc->node_access; size_t pathlen = strlen (path); - return rtems_tftp_is_directory (path, pathlen) ? - RTEMS_FILESYSTEM_DIRECTORY - : RTEMS_FILESYSTEM_MEMORY_FILE; + buf->st_mode = S_IRWXU | S_IRWXG | S_IRWXO + | (rtems_tftp_is_directory (path, pathlen) ? S_IFDIR : S_IFREG); + + return 0; } static int rtems_tftp_clone( @@ -1022,7 +1024,6 @@ static const rtems_filesystem_operations_table rtems_tftp_ops = { .eval_path_h = rtems_tftp_eval_path, .link_h = rtems_filesystem_default_link, .are_nodes_equal_h = rtems_tftp_are_nodes_equal, - .node_type_h = rtems_tftp_node_type, .mknod_h = rtems_filesystem_default_mknod, .rmnod_h = rtems_filesystem_default_rmnod, .fchmod_h = rtems_filesystem_default_fchmod, @@ -1047,7 +1048,7 @@ static const rtems_filesystem_file_handlers_r rtems_tftp_handlers = { .write_h = rtems_tftp_write, .ioctl_h = rtems_filesystem_default_ioctl, .lseek_h = rtems_filesystem_default_lseek, - .fstat_h = rtems_filesystem_default_fstat, + .fstat_h = rtems_tftp_fstat, .ftruncate_h = rtems_tftp_ftruncate, .fsync_h = rtems_filesystem_default_fsync_or_fdatasync, .fdatasync_h = rtems_filesystem_default_fsync_or_fdatasync, diff --git a/testsuites/fstests/fsimfsgeneric01/init.c b/testsuites/fstests/fsimfsgeneric01/init.c index 0c04b9c894..03e4c190d9 100644 --- a/testsuites/fstests/fsimfsgeneric01/init.c +++ b/testsuites/fstests/fsimfsgeneric01/init.c @@ -1,8 +1,8 @@ /* - * Copyright (c) 2012 embedded brains GmbH. All rights reserved. + * Copyright (c) 2012-2014 embedded brains GmbH. All rights reserved. * * embedded brains GmbH - * Obere Lagerstr. 30 + * Dornierstr. 4 * 82178 Puchheim * Germany * @@ -34,7 +34,8 @@ const char rtems_test_name[] = "FSIMFSGENERIC 1"; typedef enum { TEST_NEW, TEST_INITIALIZED, - TEST_FSTAT_OPEN, + TEST_FSTAT_OPEN_0, + TEST_FSTAT_OPEN_1, TEST_OPEN, TEST_READ, TEST_WRITE, @@ -61,7 +62,7 @@ static int handler_open( { test_state *state = IMFS_generic_get_context_by_iop(iop); - rtems_test_assert(*state == TEST_FSTAT_OPEN); + rtems_test_assert(*state == TEST_FSTAT_OPEN_1); *state = TEST_OPEN; return 0; @@ -144,17 +145,23 @@ static int handler_fstat( switch (*state) { case TEST_INITIALIZED: - *state = TEST_FSTAT_OPEN; + *state = TEST_FSTAT_OPEN_0; + break; + case TEST_FSTAT_OPEN_0: + *state = TEST_FSTAT_OPEN_1; break; case TEST_CLOSED: *state = TEST_FSTAT_UNLINK; break; default: - rtems_test_assert(0); + printk("x\n"); + //rtems_test_assert(0); break; } - return rtems_filesystem_default_fstat(loc, buf); + buf->st_mode = S_IFCHR | S_IRWXU | S_IRWXG | S_IRWXO; + + return 0; } static int handler_ftruncate( -- cgit v1.2.3