summaryrefslogtreecommitdiffstats
path: root/cpukit/libfs/src/devfs
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2012-03-13 11:33:51 +0100
committerSebastian Huber <sebastian.huber@embedded-brains.de>2012-03-13 12:23:37 +0100
commit3b7c123c8d910eb60ab3b38dec6224e2de9847c9 (patch)
treea67335010c15af5efb5e27224ae9204883c2b5b8 /cpukit/libfs/src/devfs
parentAdd missing BSD sections. (diff)
downloadrtems-3b7c123c8d910eb60ab3b38dec6224e2de9847c9.tar.bz2
Filesystem: Reference counting for locations
o A new data structure rtems_filesystem_global_location_t was introduced to be used for o the mount point location in the mount table entry, o the file system root location in the mount table entry, o the root directory location in the user environment, and o the current directory location in the user environment. During the path evaluation global start locations are obtained to ensure that the current file system instance will be not unmounted in the meantime. o The user environment uses now reference counting and is protected from concurrent access. o The path evaluation process was completely rewritten and simplified. The IMFS, RFS, NFS, and DOSFS use now a generic path evaluation method. Recursive calls in the path evaluation have been replaced with iteration to avoid stack overflows. Only the evaluation of symbolic links is recursive. No dynamic memory allocations and intermediate buffers are used in the high level path evaluation. No global locks are held during the file system instance specific path evaluation process. o Recursive symbolic link evaluation is now limited by RTEMS_FILESYSTEM_SYMLOOP_MAX. Applications can retrieve this value via sysconf(). o The device file system (devFS) uses now no global variables and allocation from the workspace. Node names are allocated from the heap. o The upper layer lseek() performs now some parameter checks. o The upper layer ftruncate() performs now some parameter checks. o unmask() is now restricted to the RWX flags and protected from concurrent access. o The fchmod_h and rmnod_h file system node handlers are now a file system operation. o The unlink_h operation has been removed. All nodes are now destroyed with the rmnod_h operation. o New lock_h, unlock_h, clonenod_h, and are_nodes_equal_h file system operations. o The path evaluation and file system operations are now protected by per file system instance lock and unlock operations. o Fix and test file descriptor duplicate in fcntl(). o New test fstests/fsnofs01.
Diffstat (limited to 'cpukit/libfs/src/devfs')
-rw-r--r--cpukit/libfs/src/devfs/devclose.c4
-rw-r--r--cpukit/libfs/src/devfs/devfs.h126
-rw-r--r--cpukit/libfs/src/devfs/devfs_eval.c131
-rw-r--r--cpukit/libfs/src/devfs/devfs_init.c114
-rw-r--r--cpukit/libfs/src/devfs/devfs_mknod.c95
-rw-r--r--cpukit/libfs/src/devfs/devfs_node_type.c2
-rw-r--r--cpukit/libfs/src/devfs/devfs_show.c42
-rw-r--r--cpukit/libfs/src/devfs/devioctl.c4
-rw-r--r--cpukit/libfs/src/devfs/devopen.c8
-rw-r--r--cpukit/libfs/src/devfs/devread.c4
-rw-r--r--cpukit/libfs/src/devfs/devstat.c39
-rw-r--r--cpukit/libfs/src/devfs/devwrite.c4
12 files changed, 239 insertions, 334 deletions
diff --git a/cpukit/libfs/src/devfs/devclose.c b/cpukit/libfs/src/devfs/devclose.c
index 773cade5c6..f69ac291fe 100644
--- a/cpukit/libfs/src/devfs/devclose.c
+++ b/cpukit/libfs/src/devfs/devclose.c
@@ -21,9 +21,7 @@ int devFS_close(
{
rtems_libio_open_close_args_t args;
rtems_status_code status;
- rtems_device_name_t *np;
-
- np = (rtems_device_name_t *)iop->pathinfo.node_access;
+ const devFS_node *np = iop->pathinfo.node_access;
args.iop = iop;
args.flags = 0;
diff --git a/cpukit/libfs/src/devfs/devfs.h b/cpukit/libfs/src/devfs/devfs.h
index 6e4f2478c7..758edf932b 100644
--- a/cpukit/libfs/src/devfs/devfs.h
+++ b/cpukit/libfs/src/devfs/devfs.h
@@ -17,38 +17,54 @@ extern "C" {
/**
* This structure define the type of device table
*/
-
-typedef struct
-{
- /** This member points to device name which is a null-terminated string */
- const char *device_name;
+typedef struct {
+ /** This member points to device name which is not a null-terminated string */
+ const char *name;
/** This member is the name length of a device */
- uint32_t device_name_length;
+ size_t namelen;
/** major number of a device */
rtems_device_major_number major;
/** minor number of a device */
rtems_device_minor_number minor;
/** device creation mode, only device file can be created */
mode_t mode;
+} devFS_node;
-} rtems_device_name_t;
+typedef struct {
+ devFS_node *nodes;
+ size_t count;
+} devFS_data;
+/**
+ * The following defines the device-only filesystem operating
+ * operations.
+ */
+extern const rtems_filesystem_operations_table devFS_ops;
/**
- * This routine associates RTEMS status code with errno
+ * The following defines the device-only filesystem operating
+ * handlers.
*/
-extern int rtems_deviceio_errno(rtems_status_code code);
-
+extern const rtems_filesystem_file_handlers_r devFS_file_handlers;
/**
- * The following defines the device table size. This values
- * is configured during application configuration time by
- * the user. The default value is set to 4.
+ * This routine associates RTEMS status code with errno
*/
-extern uint32_t rtems_device_table_size;
+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;
+}
+
+extern void devFS_eval_path(
+ rtems_filesystem_eval_path_context_t *ctx
+);
/**
* This handler maps open operation to rtems_io_open.
@@ -62,8 +78,8 @@ extern uint32_t rtems_device_table_size;
extern int devFS_open(
rtems_libio_t *iop,
const char *pathname,
- uint32_t flag,
- uint32_t mode
+ int oflag,
+ mode_t mode
);
@@ -142,8 +158,8 @@ extern int devFS_ioctl(
*/
extern int devFS_stat(
- rtems_filesystem_location_info_t *loc,
- struct stat *buf
+ const rtems_filesystem_location_info_t *loc,
+ struct stat *buf
);
@@ -153,63 +169,15 @@ extern int devFS_stat(
* Since this is a device-only filesystem, so there is only
* one node type in the system.
*
- * @param pathloc contains filesytem access information, this
+ * @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(
- rtems_filesystem_location_info_t *pathloc
+ const rtems_filesystem_location_info_t*loc
);
-
-
-/**
- * This routine is invoked to determine if 'pathname' exists.
- * This routine first check access flags, then it searches
- * the device table to get the information.
- *
- * @param pathname device name to be searched
- * @param flags access flags
- * @param pathloc contains filesystem access information
- * @retval upon success(pathname exists), this routines
- * returns 0; if 'flag' is invalid, it returns -1 and errno
- * is set to EIO; otherwise, it returns -1 and errno is set to ENOENT
- */
-
-extern int devFS_evaluate_path(
- const char *pathname,
- size_t pathnamelen,
- int flags,
- rtems_filesystem_location_info_t *pathloc
-);
-
-
-/**
- * This routine is given a path to evaluate and a valid start
- * location. It is responsible for finding the parent node for
- * a requested make command, setting pathloc information to
- * identify the parent node, and setting the name pointer to
- * the first character of the name of the new node. In device
- * only filesystem, devices do not has a tree hierarchy, there
- * are no parent-child relationship. So this routine is rather
- * simple, it just set *name to path and returns
- *
- * @param path device path to be evaluated
- * @param pathloc contains filesystem access information, this
- * parameter is ignored
- * @param name
- * @retval always returns 0
- */
-
-extern int devFS_evaluate_for_make(
- const char *path,
- rtems_filesystem_location_info_t *pathloc,
- const char **name
-);
-
-
-
/**
* This routine is invoked upon registration of a new device
* file. It is responsible for creating a item in the main
@@ -217,21 +185,15 @@ extern int devFS_evaluate_for_make(
* sequential order, when found a empty slot, it fills the slot
* with proper values.
*
- * @param path the device file name to be registered
- * @param mode file mode, this parameter is ignored
- * @param dev device major and minor number
- * @param pathloc contains filesystem access information
- * @retval upon success, this routine returns 0; if 'path'
- * already exist, it returns -1 and errno is set to EEXIST;
- * if device table is full, it returns -1 and errno is set
- * to ENOMEM
+ * @see rtems_filesystem_mknod_t.
*/
extern int devFS_mknod(
- const char *path,
- mode_t mode,
- dev_t dev,
- rtems_filesystem_location_info_t *pathloc
+ const rtems_filesystem_location_info_t *parentloc,
+ const char *name,
+ size_t namelen,
+ mode_t mode,
+ dev_t dev
);
@@ -266,11 +228,9 @@ extern int devFS_initialize(
*
* This routine is intended for debugging, and can be used by shell
* program to provide user with the system information.
- *
- * @retval 0
*/
-extern int devFS_Show(void);
+extern void devFS_Show(void);
#ifdef __cplusplus
}
diff --git a/cpukit/libfs/src/devfs/devfs_eval.c b/cpukit/libfs/src/devfs/devfs_eval.c
index a3169fb3fa..b7a31ee921 100644
--- a/cpukit/libfs/src/devfs/devfs_eval.c
+++ b/cpukit/libfs/src/devfs/devfs_eval.c
@@ -7,79 +7,84 @@
*/
#if HAVE_CONFIG_H
-#include "config.h"
+ #include "config.h"
#endif
-#include <rtems/seterr.h>
-#include <fcntl.h>
-#include <assert.h>
-#include "devfs.h"
-
-/**
- * The following defines the device-only filesystem operating
- * handlers.
- */
+#include <string.h>
-extern rtems_filesystem_operations_table devFS_ops;
-
-/**
- * The following defines the device-only filesystem operating
- * handlers.
- */
-
-extern rtems_filesystem_file_handlers_r devFS_file_handlers;
+#include "devfs.h"
-int devFS_evaluate_path(
- const char *pathname,
- size_t pathnamelen,
- int flags,
- rtems_filesystem_location_info_t *pathloc
+static devFS_node *devFS_search_node(
+ const devFS_data *data,
+ const char *path,
+ size_t pathlen,
+ devFS_node **free_node_ptr
)
{
- int i;
- rtems_device_name_t *device_name_table;
-
- /* see if 'flags' is valid */
- if ( !rtems_libio_is_valid_perms( flags ) )
- rtems_set_errno_and_return_minus_one( EPERM );
-
- /* get the device name table */
- device_name_table = (rtems_device_name_t *)pathloc->node_access;
- if (!device_name_table)
- rtems_set_errno_and_return_minus_one( EFAULT );
-
- for (i = 0; i < rtems_device_table_size; i++) {
- if (!device_name_table[i].device_name)
- continue;
-
- if (strncmp(pathname, device_name_table[i].device_name, pathnamelen) != 0)
- continue;
-
- if (device_name_table[i].device_name[pathnamelen] != '\0')
- continue;
-
- /* find the device, set proper values */
- pathloc->node_access = (void *)&device_name_table[i];
- pathloc->handlers = &devFS_file_handlers;
- pathloc->ops = &devFS_ops;
- pathloc->mt_entry = rtems_filesystem_root.mt_entry;
- return 0;
+ size_t i = 0;
+ size_t n = data->count;
+ devFS_node *nodes = data->nodes;
+ devFS_node *node = NULL;
+ devFS_node *free_node = NULL;
+
+ for (i = 0; (free_node == NULL || node == NULL) && i < n; ++i) {
+ devFS_node *current = nodes + i;
+
+ if (current->name != NULL) {
+ if (
+ current->namelen == pathlen
+ && memcmp(current->name, path, pathlen) == 0
+ ) {
+ node = current;
+ }
+ } else {
+ free_node = current;
+ }
}
- /* no such file or directory */
- rtems_set_errno_and_return_minus_one( ENOENT );
-}
-
+ *free_node_ptr = free_node;
+ return node;
+}
-int devFS_evaluate_for_make(
- const char *path,
- rtems_filesystem_location_info_t *pathloc,
- const char **name
+void devFS_eval_path(
+ rtems_filesystem_eval_path_context_t *ctx
)
{
- /* we do nothing, just set name to path */
- *name = path;
- return 0;
+ rtems_filesystem_location_info_t *currentloc =
+ rtems_filesystem_eval_path_get_currentloc(ctx);
+ devFS_node *free_node;
+ devFS_node *node = devFS_search_node(
+ devFS_get_data(currentloc),
+ rtems_filesystem_eval_path_get_path(ctx),
+ rtems_filesystem_eval_path_get_pathlen(ctx),
+ &free_node
+ );
+ int eval_flags = rtems_filesystem_eval_path_get_flags(ctx);
+
+ if (node != NULL) {
+ if ((eval_flags & RTEMS_LIBIO_EXCLUSIVE) == 0) {
+ currentloc->node_access = node;
+ rtems_filesystem_eval_path_clear_path(ctx);
+ } else {
+ rtems_filesystem_eval_path_error(ctx, EEXIST);
+ }
+ } else {
+ if ((eval_flags & RTEMS_LIBIO_MAKE) != 0) {
+ if (free_node != NULL) {
+ free_node->mode = S_IRWXU | S_IRWXG | S_IRWXO;
+ currentloc->node_access = free_node;
+ rtems_filesystem_eval_path_set_token(
+ ctx,
+ rtems_filesystem_eval_path_get_path(ctx),
+ rtems_filesystem_eval_path_get_pathlen(ctx)
+ );
+ rtems_filesystem_eval_path_clear_path(ctx);
+ } else {
+ rtems_filesystem_eval_path_error(ctx, ENOSPC);
+ }
+ } else {
+ rtems_filesystem_eval_path_error(ctx, ENOENT);
+ }
+ }
}
-
diff --git a/cpukit/libfs/src/devfs/devfs_init.c b/cpukit/libfs/src/devfs/devfs_init.c
index bd741e41a2..070aced2a4 100644
--- a/cpukit/libfs/src/devfs/devfs_init.c
+++ b/cpukit/libfs/src/devfs/devfs_init.c
@@ -7,85 +7,65 @@
*/
#if HAVE_CONFIG_H
-#include "config.h"
+ #include "config.h"
#endif
-#include <stdlib.h>
-#include <rtems.h>
-#include <rtems/seterr.h>
-#include <rtems/score/wkspace.h>
#include "devfs.h"
-rtems_filesystem_operations_table devFS_ops =
-{
- devFS_evaluate_path,
- devFS_evaluate_for_make,
- rtems_filesystem_default_link,
- rtems_filesystem_default_unlink,
- devFS_node_type,
- devFS_mknod,
- rtems_filesystem_default_chown,
- rtems_filesystem_default_freenode,
- rtems_filesystem_default_mount,
- devFS_initialize,
- rtems_filesystem_default_unmount,
- rtems_filesystem_default_fsunmount,
- rtems_filesystem_default_utime,
- rtems_filesystem_default_evaluate_link,
- rtems_filesystem_default_symlink,
- rtems_filesystem_default_readlink,
- rtems_filesystem_default_rename,
- rtems_filesystem_default_statvfs
+const rtems_filesystem_operations_table devFS_ops = {
+ .lock_h = rtems_filesystem_default_lock,
+ .unlock_h = rtems_filesystem_default_unlock,
+ .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,
+ .chown_h = rtems_filesystem_default_chown,
+ .clonenod_h = rtems_filesystem_default_clonenode,
+ .freenod_h = rtems_filesystem_default_freenode,
+ .mount_h = rtems_filesystem_default_mount,
+ .fsmount_me_h = devFS_initialize,
+ .unmount_h = rtems_filesystem_default_unmount,
+ .fsunmount_me_h = rtems_filesystem_default_fsunmount,
+ .utime_h = rtems_filesystem_default_utime,
+ .symlink_h = rtems_filesystem_default_symlink,
+ .readlink_h = rtems_filesystem_default_readlink,
+ .rename_h = rtems_filesystem_default_rename,
+ .statvfs_h = rtems_filesystem_default_statvfs
};
-
-rtems_filesystem_file_handlers_r devFS_file_handlers =
-{
- devFS_open,
- devFS_close,
- devFS_read,
- devFS_write,
- devFS_ioctl,
- rtems_filesystem_default_lseek,
- devFS_stat,
- rtems_filesystem_default_fchmod,
- rtems_filesystem_default_ftruncate,
- rtems_filesystem_default_fsync,
- rtems_filesystem_default_fdatasync,
- rtems_filesystem_default_fcntl,
- rtems_filesystem_default_rmnod
+const rtems_filesystem_file_handlers_r devFS_file_handlers = {
+ .open_h = devFS_open,
+ .close_h = devFS_close,
+ .read_h = devFS_read,
+ .write_h = devFS_write,
+ .ioctl_h = devFS_ioctl,
+ .lseek_h = rtems_filesystem_default_lseek,
+ .fstat_h = devFS_stat,
+ .ftruncate_h = rtems_filesystem_default_ftruncate,
+ .fsync_h = rtems_filesystem_default_fsync,
+ .fdatasync_h = rtems_filesystem_default_fdatasync,
+ .fcntl_h = rtems_filesystem_default_fcntl
};
-
-
int devFS_initialize(
- rtems_filesystem_mount_table_entry_t *temp_mt_entry,
- const void *data
+ rtems_filesystem_mount_table_entry_t *mt_entry,
+ const void *data
)
{
- rtems_device_name_t *device_name_table;
-
- /* allocate device only filesystem name table */
- device_name_table = (rtems_device_name_t *)_Workspace_Allocate(
- sizeof( rtems_device_name_t ) * ( rtems_device_table_size )
- );
-
- /* no memory for device filesystem */
- if (!device_name_table)
- rtems_set_errno_and_return_minus_one( ENOMEM );
-
- memset(
- device_name_table, 0,
- sizeof( rtems_device_name_t ) * ( rtems_device_table_size )
- );
-
- /* set file handlers */
- temp_mt_entry->mt_fs_root.handlers = &devFS_file_handlers;
- temp_mt_entry->mt_fs_root.ops = &devFS_ops;
+ int rv = 0;
- /* Set the node_access to device name table */
- temp_mt_entry->mt_fs_root.node_access = (void *)device_name_table;
+ if (data != NULL) {
+ 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;
+ }
- return 0;
+ return rv;
}
diff --git a/cpukit/libfs/src/devfs/devfs_mknod.c b/cpukit/libfs/src/devfs/devfs_mknod.c
index 4a8b8b3523..9760c5e5c7 100644
--- a/cpukit/libfs/src/devfs/devfs_mknod.c
+++ b/cpukit/libfs/src/devfs/devfs_mknod.c
@@ -7,75 +7,52 @@
*/
#if HAVE_CONFIG_H
-#include "config.h"
+ #include "config.h"
#endif
-#include <sys/types.h>
#include <sys/stat.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <errno.h>
#include <stdlib.h>
+#include <string.h>
-#include <rtems/seterr.h>
#include "devfs.h"
int devFS_mknod(
- const char *path,
- mode_t mode,
- dev_t dev,
- rtems_filesystem_location_info_t *pathloc
+ const rtems_filesystem_location_info_t *parentloc,
+ const char *name,
+ size_t namelen,
+ mode_t mode,
+ dev_t dev
)
{
- int i;
- int slot;
- rtems_device_name_t *device_name_table;
- rtems_device_major_number major;
- rtems_device_minor_number minor;
- ISR_Level level;
-
- /*
- * This is a special case. In rtems_filesystem_initialize,
- * a special device '/dev' will be created. We check this
- * condition and do not create the '/dev' and the 'path'
- * actually passed in is 'dev', not '/dev'. Just return 0 to
- * indicate we are OK.
- */
-
- if ((path[0] == 'd') && (path[1] == 'e') &&
- (path[2] == 'v') && (path[3] == '\0'))
- return 0;
-
- /* must be a character device or a block device */
- if (!S_ISBLK(mode) && !S_ISCHR(mode))
- rtems_set_errno_and_return_minus_one( EINVAL );
- else
- rtems_filesystem_split_dev_t(dev, major, minor);
-
- /* Find an empty slot in device name table */
- device_name_table = (rtems_device_name_t *)pathloc->node_access;
- if (!device_name_table)
- rtems_set_errno_and_return_minus_one( EFAULT );
-
- for (slot = -1, i = 0; i < rtems_device_table_size; i++){
- if (device_name_table[i].device_name == NULL)
- slot = i;
- else
- if (strcmp(path, device_name_table[i].device_name) == 0)
- rtems_set_errno_and_return_minus_one( EEXIST );
+ int rv = 0;
+
+ if (namelen != 3 || name [0] != 'd' || name [1] != 'e' || name [2] != 'v') {
+ if (S_ISBLK(mode) || S_ISCHR(mode)) {
+ char *dupname = malloc(namelen);
+
+ if (dupname != NULL) {
+ devFS_node *node = parentloc->node_access;
+
+ node->name = dupname;
+ node->namelen = namelen;
+ node->major = rtems_filesystem_dev_major_t(dev);
+ node->minor = rtems_filesystem_dev_minor_t(dev);
+ node->mode = mode;
+ memcpy(dupname, name, namelen);
+ } else {
+ errno = ENOMEM;
+ rv = -1;
+ }
+ } else {
+ errno = ENOTSUP;
+ rv = -1;
+ }
+ } else {
+ if (!S_ISDIR(mode)) {
+ errno = ENOTSUP;
+ rv = -1;
+ }
}
- if (slot == -1)
- rtems_set_errno_and_return_minus_one( ENOMEM );
-
- _ISR_Disable(level);
- device_name_table[slot].device_name = path;
- device_name_table[slot].device_name_length = strlen(path);
- device_name_table[slot].major = major;
- device_name_table[slot].minor = minor;
- device_name_table[slot].mode = mode;
- _ISR_Enable(level);
-
- return 0;
+ return rv;
}
-
diff --git a/cpukit/libfs/src/devfs/devfs_node_type.c b/cpukit/libfs/src/devfs/devfs_node_type.c
index 0bede52d2d..c4bd488680 100644
--- a/cpukit/libfs/src/devfs/devfs_node_type.c
+++ b/cpukit/libfs/src/devfs/devfs_node_type.c
@@ -13,7 +13,7 @@
#include "devfs.h"
rtems_filesystem_node_types_t devFS_node_type(
- rtems_filesystem_location_info_t *pathloc
+ const rtems_filesystem_location_info_t *loc
)
{
/*
diff --git a/cpukit/libfs/src/devfs/devfs_show.c b/cpukit/libfs/src/devfs/devfs_show.c
index e449caf49f..6d30d3f5d6 100644
--- a/cpukit/libfs/src/devfs/devfs_show.c
+++ b/cpukit/libfs/src/devfs/devfs_show.c
@@ -7,30 +7,38 @@
*/
#if HAVE_CONFIG_H
-#include "config.h"
+ #include "config.h"
#endif
-#include <rtems/seterr.h>
#include "devfs.h"
-int devFS_Show(void)
+void devFS_Show(void)
{
- int i;
- rtems_filesystem_location_info_t *temp_loc;
- rtems_device_name_t *device_name_table;
+ rtems_filesystem_location_info_t *rootloc = &rtems_filesystem_root->location;
- temp_loc = &rtems_filesystem_root;
- device_name_table = (rtems_device_name_t *)temp_loc->node_access;
- if (!device_name_table)
- rtems_set_errno_and_return_minus_one( EFAULT );
+ if (rootloc->ops == &devFS_ops) {
+ const devFS_data *data = devFS_get_data(rootloc);
+ size_t i = 0;
+ size_t n = data->count;
+ devFS_node *nodes = data->nodes;
- for (i = 0; i < rtems_device_table_size; i++){
- if (device_name_table[i].device_name){
- printk("/%s %d %d\n", device_name_table[i].device_name,
- device_name_table[i].major, device_name_table[i].minor);
+ for (i = 0; i < n; ++i) {
+ devFS_node *current = nodes + i;
+
+ if (current->name != NULL) {
+ size_t j = 0;
+ size_t m = current->namelen;
+
+ printk("/");
+ for (j = 0; j < m; ++j) {
+ printk("%c", current->name [j]);
+ }
+ printk(
+ " %lu %lu\n",
+ (unsigned long) current->major,
+ (unsigned long) current->minor
+ );
+ }
}
}
- return 0;
}
-
-
diff --git a/cpukit/libfs/src/devfs/devioctl.c b/cpukit/libfs/src/devfs/devioctl.c
index 15965b8c0e..457596fdc4 100644
--- a/cpukit/libfs/src/devfs/devioctl.c
+++ b/cpukit/libfs/src/devfs/devioctl.c
@@ -23,9 +23,7 @@ int devFS_ioctl(
{
rtems_libio_ioctl_args_t args;
rtems_status_code status;
- rtems_device_name_t *np;
-
- np = (rtems_device_name_t *)iop->pathinfo.node_access;
+ const devFS_node *np = iop->pathinfo.node_access;
args.iop = iop;
args.command = command;
diff --git a/cpukit/libfs/src/devfs/devopen.c b/cpukit/libfs/src/devfs/devopen.c
index 67be3678e1..1b100e1cc7 100644
--- a/cpukit/libfs/src/devfs/devopen.c
+++ b/cpukit/libfs/src/devfs/devopen.c
@@ -18,15 +18,13 @@
int devFS_open(
rtems_libio_t *iop,
const char *pathname,
- uint32_t flag,
- uint32_t mode
+ int oflag,
+ mode_t mode
)
{
rtems_libio_open_close_args_t args;
rtems_status_code status;
- rtems_device_name_t *np;
-
- np = (rtems_device_name_t *)iop->pathinfo.node_access;
+ const devFS_node *np = iop->pathinfo.node_access;
args.iop = iop;
args.flags = iop->flags;
diff --git a/cpukit/libfs/src/devfs/devread.c b/cpukit/libfs/src/devfs/devread.c
index 10f74e81c9..31d3f35db9 100644
--- a/cpukit/libfs/src/devfs/devread.c
+++ b/cpukit/libfs/src/devfs/devread.c
@@ -23,9 +23,7 @@ ssize_t devFS_read(
{
rtems_libio_rw_args_t args;
rtems_status_code status;
- rtems_device_name_t *np;
-
- np = (rtems_device_name_t *)iop->pathinfo.node_access;
+ const devFS_node *np = iop->pathinfo.node_access;
args.iop = iop;
args.offset = iop->offset;
diff --git a/cpukit/libfs/src/devfs/devstat.c b/cpukit/libfs/src/devfs/devstat.c
index e0c52b8b3d..1b780cc58b 100644
--- a/cpukit/libfs/src/devfs/devstat.c
+++ b/cpukit/libfs/src/devfs/devstat.c
@@ -7,40 +7,25 @@
*/
#if HAVE_CONFIG_H
-#include "config.h"
+ #include "config.h"
#endif
-#include <rtems.h>
-#include <rtems/io.h>
-#include <rtems/seterr.h>
-#include <rtems/libio.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-
#include "devfs.h"
int devFS_stat(
- rtems_filesystem_location_info_t *loc,
- struct stat *buf
+ const rtems_filesystem_location_info_t *loc,
+ struct stat *buf
)
{
- rtems_device_name_t *the_dev;
-
- the_dev = (rtems_device_name_t *)loc->node_access;
+ int rv = 0;
+ const devFS_node *the_dev = loc->node_access;
- /*
- * stat() invokes devFS_evaluate_path() which checks that node_access
- * is not NULL. So this should NEVER be NULL unless someone breaks
- * other code in this filesystem.
- */
- #if defined(RTEMS_DEBUG)
- if (!the_dev)
- rtems_set_errno_and_return_minus_one( EFAULT );
- #endif
+ if (the_dev != NULL) {
+ buf->st_rdev = rtems_filesystem_make_dev_t( the_dev->major, the_dev->minor );
+ buf->st_mode = the_dev->mode;
+ } else {
+ rv = rtems_filesystem_default_fstat(loc, buf);
+ }
- buf->st_rdev = rtems_filesystem_make_dev_t( the_dev->major, the_dev->minor );
- buf->st_mode = the_dev->mode;
- return 0;
+ return rv;
}
-
-
diff --git a/cpukit/libfs/src/devfs/devwrite.c b/cpukit/libfs/src/devfs/devwrite.c
index 5389c69bc5..2b3aac412b 100644
--- a/cpukit/libfs/src/devfs/devwrite.c
+++ b/cpukit/libfs/src/devfs/devwrite.c
@@ -23,9 +23,7 @@ ssize_t devFS_write(
{
rtems_libio_rw_args_t args;
rtems_status_code status;
- rtems_device_name_t *np;
-
- np = (rtems_device_name_t *)iop->pathinfo.node_access;
+ const devFS_node *np = iop->pathinfo.node_access;
args.iop = iop;
args.offset = iop->offset;