mirror of
https://gitlab.rtems.org/rtems/rtos/rtems.git
synced 2026-09-20 15:27:48 +08:00
2009-06-12 Chris Johns <chrisj@rtems.org>
* libblock/src/bdbuf.c: Update comments.
* libblock/src/bdpart.c, libblock/src/ide_part_table.c: Get the
device from the rdev field of the stat buf.
* libcsupport/include/rtems/libio.h: Add a path length to evalpath
handler. Add parent locations to rmmod and unlink handlers.
* libcsupport/include/rtems/libio_.h: Add a path length to
rtems_filesystem_evaluate_path. Add
rtems_filesystem_evaluate_relative_path, rtems_filesystem_dirname,
and rtems_filesystem_prefix_separators. Remove
rtems_filesystem_evaluate_parent.
* libcsupport/src/base_fs.c, libcsupport/src/chdir.c,
libcsupport/src/chmod.c, libcsupport/src/chown.c,
libcsupport/src/chroot.c, libcsupport/src/fchdir.c,
libcsupport/src/link.c, libcsupport/src/mount.c,
libcsupport/src/open.c, libcsupport/src/privateenv.c,
libcsupport/src/readlink.c, libcsupport/src/unmount.c,
libcsupport/src/utime.c, libcsupport/src/unmount.c,
libcsupport/src/utime.c, libfs/src/devfs/devfs.h,
libfs/src/devfs/devfs_eval.c, libfs/src/devfs/devstat.c,
libfs/src/dosfs/msdos_create.c, libfs/src/dosfs/msdos_misc.c,
libfs/src/imfs/imfs.h, libfs/src/imfs/imfs_eval.c,
libfs/src/imfs/imfs_load_tar.c, libfs/src/imfs/ioman.c,
libfs/src/pipe/pipe.c, libmisc/fsmount/fsmount.c,
libnetworking/lib/ftpfs.c: Add the length parameter to the eval
call.
* libcsupport/src/eval.c: Add rtems_filesystem_prefix_separators,
rtems_filesystem_dirname,
rtems_filesystem_evaluate_relative_path. Add the length parameter
to the eval call.
* libcsupport/src/rmdir.c: Find the parent pathloc then the node
pathloc from that node. Remove the call to find the parent given
the node pathloc.
* libcsupport/src/stat.c: Add the length parameter to the eval
call. Set the device into the rdev field.
* libcsupport/src/unlink.c: Find the parent pathloc then the node
pathloc from that node. Remove the call to find the parent given
the node pathloc.
* libfs/src/dosfs/fat.c, libfs/src/dosfs/msdos_format.c: Get the
disk device number from the stat rdev field.
* libfs/src/dosfs/msdos.h: Add the length parameter to the eval
call. Add the parent pathloc to the rmnod handler.
* libfs/src/dosfs/msdos_dir.c: Add the parent pathloc to the rmnod
handler.
* libfs/src/dosfs/msdos_eval.c: Add the length parameter to the
eval and token call.
* libfs/src/imfs/imfs_directory.c: Add the parent pathloc to the
rmnod handler.
* libfs/src/imfs/imfs_fchmod.c: Do not test the mode flags for
only the allowed flags. Add the missing flags spec'ed in the POSIX
standard.
* libfs/src/imfs/imfs_fsunmount.c, libfs/src/imfs/imfs_rmnod.c,
libfs/src/imfs/imfs_unlink.c, libfs/src/imfs/memfile.c: Add the
parent node. Currently ignored in the IMFS.
* libfs/src/imfs/imfs_stat.c: Return the device number in the rdev
field.
* libfs/src/imfs/imfs_mknod.c, libfs/src/imfs/imfs_symlink.c : Add
the length parameter to the token call.
* libfs/src/nfsclient/src/nfs.c: Add the length parameter to the
eval call and parent node to the rmnod and unlink command.
* libmisc/shell/internal.h: Remove the libc mounter decl to make
public.
* libmisc/shell/main_mount.c: Add support for hooking external
mount support for new file systems.
* libmisc/shell/shell.h: Add helper functions for the mount
command.
This commit is contained in:
@@ -1,3 +1,71 @@
|
||||
2009-06-12 Chris Johns <chrisj@rtems.org>
|
||||
|
||||
* libblock/src/bdbuf.c: Update comments.
|
||||
* libblock/src/bdpart.c, libblock/src/ide_part_table.c: Get the
|
||||
device from the rdev field of the stat buf.
|
||||
* libcsupport/include/rtems/libio.h: Add a path length to evalpath
|
||||
handler. Add parent locations to rmmod and unlink handlers.
|
||||
* libcsupport/include/rtems/libio_.h: Add a path length to
|
||||
rtems_filesystem_evaluate_path. Add
|
||||
rtems_filesystem_evaluate_relative_path, rtems_filesystem_dirname,
|
||||
and rtems_filesystem_prefix_separators. Remove
|
||||
rtems_filesystem_evaluate_parent.
|
||||
* libcsupport/src/base_fs.c, libcsupport/src/chdir.c,
|
||||
libcsupport/src/chmod.c, libcsupport/src/chown.c,
|
||||
libcsupport/src/chroot.c, libcsupport/src/fchdir.c,
|
||||
libcsupport/src/link.c, libcsupport/src/mount.c,
|
||||
libcsupport/src/open.c, libcsupport/src/privateenv.c,
|
||||
libcsupport/src/readlink.c, libcsupport/src/unmount.c,
|
||||
libcsupport/src/utime.c, libcsupport/src/unmount.c,
|
||||
libcsupport/src/utime.c, libfs/src/devfs/devfs.h,
|
||||
libfs/src/devfs/devfs_eval.c, libfs/src/devfs/devstat.c,
|
||||
libfs/src/dosfs/msdos_create.c, libfs/src/dosfs/msdos_misc.c,
|
||||
libfs/src/imfs/imfs.h, libfs/src/imfs/imfs_eval.c,
|
||||
libfs/src/imfs/imfs_load_tar.c, libfs/src/imfs/ioman.c,
|
||||
libfs/src/pipe/pipe.c, libmisc/fsmount/fsmount.c,
|
||||
libnetworking/lib/ftpfs.c: Add the length parameter to the eval
|
||||
call.
|
||||
* libcsupport/src/eval.c: Add rtems_filesystem_prefix_separators,
|
||||
rtems_filesystem_dirname,
|
||||
rtems_filesystem_evaluate_relative_path. Add the length parameter
|
||||
to the eval call.
|
||||
* libcsupport/src/rmdir.c: Find the parent pathloc then the node
|
||||
pathloc from that node. Remove the call to find the parent given
|
||||
the node pathloc.
|
||||
* libcsupport/src/stat.c: Add the length parameter to the eval
|
||||
call. Set the device into the rdev field.
|
||||
* libcsupport/src/unlink.c: Find the parent pathloc then the node
|
||||
pathloc from that node. Remove the call to find the parent given
|
||||
the node pathloc.
|
||||
* libfs/src/dosfs/fat.c, libfs/src/dosfs/msdos_format.c: Get the
|
||||
disk device number from the stat rdev field.
|
||||
* libfs/src/dosfs/msdos.h: Add the length parameter to the eval
|
||||
call. Add the parent pathloc to the rmnod handler.
|
||||
* libfs/src/dosfs/msdos_dir.c: Add the parent pathloc to the rmnod
|
||||
handler.
|
||||
* libfs/src/dosfs/msdos_eval.c: Add the length parameter to the
|
||||
eval and token call.
|
||||
* libfs/src/imfs/imfs_directory.c: Add the parent pathloc to the
|
||||
rmnod handler.
|
||||
* libfs/src/imfs/imfs_fchmod.c: Do not test the mode flags for
|
||||
only the allowed flags. Add the missing flags spec'ed in the POSIX
|
||||
standard.
|
||||
* libfs/src/imfs/imfs_fsunmount.c, libfs/src/imfs/imfs_rmnod.c,
|
||||
libfs/src/imfs/imfs_unlink.c, libfs/src/imfs/memfile.c: Add the
|
||||
parent node. Currently ignored in the IMFS.
|
||||
* libfs/src/imfs/imfs_stat.c: Return the device number in the rdev
|
||||
field.
|
||||
* libfs/src/imfs/imfs_mknod.c, libfs/src/imfs/imfs_symlink.c : Add
|
||||
the length parameter to the token call.
|
||||
* libfs/src/nfsclient/src/nfs.c: Add the length parameter to the
|
||||
eval call and parent node to the rmnod and unlink command.
|
||||
* libmisc/shell/internal.h: Remove the libc mounter decl to make
|
||||
public.
|
||||
* libmisc/shell/main_mount.c: Add support for hooking external
|
||||
mount support for new file systems.
|
||||
* libmisc/shell/shell.h: Add helper functions for the mount
|
||||
command.
|
||||
|
||||
2009-06-11 Joel Sherrill <joel.sherrill@OARcorp.com>
|
||||
|
||||
* score/src/corespinlockwait.c: Mark timeout code which is not
|
||||
|
||||
+12
-13
@@ -1936,7 +1936,7 @@ rtems_bdbuf_swapout_modified_processing (rtems_bdpool_id pid,
|
||||
* a device at a time. The task level loop will repeat this operation while
|
||||
* there are buffers to be written. If the transfer fails place the buffers
|
||||
* back on the modified list and try again later. The pool is unlocked while
|
||||
* the buffers are beign written to disk.
|
||||
* the buffers are being written to disk.
|
||||
*
|
||||
* @param pid The pool id to process modified buffers on.
|
||||
* @param timer_delta It update_timers is true update the timers by this
|
||||
@@ -1965,14 +1965,14 @@ rtems_bdbuf_swapout_pool_processing (rtems_bdpool_id pid,
|
||||
|
||||
/*
|
||||
* When the sync is for a device limit the sync to that device. If the sync
|
||||
* is for a buffer handle the devices in the order on the sync list. This
|
||||
* means the dev is -1.
|
||||
* is for a buffer handle process the devices in the order on the sync
|
||||
* list. This means the dev is -1.
|
||||
*/
|
||||
if (pool->sync_active)
|
||||
dev = pool->sync_device;
|
||||
|
||||
/*
|
||||
* If we have any buffers in the sync queue move then to the modified
|
||||
* If we have any buffers in the sync queue move them to the modified
|
||||
* list. The first sync buffer will select the device we use.
|
||||
*/
|
||||
rtems_bdbuf_swapout_modified_processing (pid, &dev,
|
||||
@@ -1990,22 +1990,22 @@ rtems_bdbuf_swapout_pool_processing (rtems_bdpool_id pid,
|
||||
timer_delta);
|
||||
|
||||
/*
|
||||
* We have all the buffers that have been modified for this device so
|
||||
* the pool can be unlocked because the state is set to TRANSFER.
|
||||
* We have all the buffers that have been modified for this device so the
|
||||
* pool can be unlocked because the state of each buffer has been set to
|
||||
* TRANSFER.
|
||||
*/
|
||||
|
||||
rtems_bdbuf_unlock_pool (pool);
|
||||
|
||||
/*
|
||||
* If there are buffers to transfer to the media tranfer them.
|
||||
* If there are buffers to transfer to the media transfer them.
|
||||
*/
|
||||
if (rtems_chain_is_empty (&transfer))
|
||||
transfered_buffers = false;
|
||||
else
|
||||
{
|
||||
/*
|
||||
* Obtain the disk device. Release the pool mutex to avoid a dead
|
||||
* lock.
|
||||
* Obtain the disk device. The pool's mutex has been released to avoid a
|
||||
* dead lock.
|
||||
*/
|
||||
dd = rtems_disk_obtain (dev);
|
||||
if (dd == NULL)
|
||||
@@ -2020,14 +2020,13 @@ rtems_bdbuf_swapout_pool_processing (rtems_bdpool_id pid,
|
||||
|
||||
/*
|
||||
* Take as many buffers as configured and pass to the driver. Note, the
|
||||
* API to the drivers has the array of buffers and if a chain was passed
|
||||
* API to the drivers has an array of buffers and if a chain was passed
|
||||
* we could have just passed the list. If the driver API is updated it
|
||||
* should be possible to make this change with little effect in this
|
||||
* code. The array that is passed is broken in design and should be
|
||||
* removed. Merging to members of a struct into the first member is
|
||||
* removed. Merging members of a struct into the first member is
|
||||
* trouble waiting to happen.
|
||||
*/
|
||||
|
||||
write_req->status = RTEMS_RESOURCE_IN_USE;
|
||||
write_req->error = 0;
|
||||
write_req->bufnum = 0;
|
||||
|
||||
@@ -110,6 +110,9 @@ static void rtems_bdpart_type_to_string(
|
||||
uuid_unparse_lower( type, str);
|
||||
}
|
||||
|
||||
/*
|
||||
* FIXME: This code should the deviceio interface and not the bdbug interface.
|
||||
*/
|
||||
static rtems_status_code rtems_bdpart_get_disk_data(
|
||||
const char *disk_name,
|
||||
dev_t *disk,
|
||||
@@ -128,7 +131,7 @@ static rtems_status_code rtems_bdpart_get_disk_data(
|
||||
if (rv != 0) {
|
||||
return RTEMS_INVALID_NAME;
|
||||
}
|
||||
*disk = st.st_dev;
|
||||
*disk = st.st_rdev;
|
||||
|
||||
/* Get disk begin, end and block size */
|
||||
dd = rtems_disk_obtain( *disk);
|
||||
|
||||
@@ -467,7 +467,7 @@ rtems_ide_part_table_get(const char *dev_name, rtems_disk_desc_t *disk_desc)
|
||||
}
|
||||
|
||||
strncpy (disk_desc->dev_name, dev_name, 15);
|
||||
disk_desc->dev = dev_stat.st_dev;
|
||||
disk_desc->dev = dev_stat.st_rdev;
|
||||
disk_desc->sector_size = (dev_stat.st_blksize) ? dev_stat.st_blksize :
|
||||
RTEMS_IDE_SECTOR_SIZE;
|
||||
|
||||
|
||||
@@ -128,6 +128,7 @@ typedef int (*rtems_filesystem_fcntl_t)(
|
||||
);
|
||||
|
||||
typedef int (*rtems_filesystem_rmnod_t)(
|
||||
rtems_filesystem_location_info_t *parent_loc, /* IN */
|
||||
rtems_filesystem_location_info_t *pathloc /* IN */
|
||||
);
|
||||
|
||||
@@ -174,6 +175,7 @@ typedef int (*rtems_filesystem_mknod_t)(
|
||||
|
||||
typedef int (*rtems_filesystem_evalpath_t)(
|
||||
const char *pathname, /* IN */
|
||||
int pathnamelen, /* IN */
|
||||
int flags, /* IN */
|
||||
rtems_filesystem_location_info_t *pathloc /* IN/OUT */
|
||||
);
|
||||
@@ -191,7 +193,8 @@ typedef int (*rtems_filesystem_link_t)(
|
||||
);
|
||||
|
||||
typedef int (*rtems_filesystem_unlink_t)(
|
||||
rtems_filesystem_location_info_t *pathloc /* IN */
|
||||
rtems_filesystem_location_info_t *parent_pathloc, /* IN */
|
||||
rtems_filesystem_location_info_t *pathloc /* IN */
|
||||
);
|
||||
|
||||
typedef int (*rtems_filesystem_chown_t)(
|
||||
@@ -326,7 +329,8 @@ struct rtems_filesystem_mount_table_entry_tt {
|
||||
* When someone adds a mounted filesystem on a real device,
|
||||
* this will need to be used.
|
||||
*
|
||||
* The best option long term for this is probably an open file descriptor.
|
||||
* The lower layers can manage how this is managed. Leave as a
|
||||
* string.
|
||||
*/
|
||||
char *dev;
|
||||
};
|
||||
|
||||
@@ -234,16 +234,29 @@ int rtems_libio_is_file_open(
|
||||
* File System Routine Prototypes
|
||||
*/
|
||||
|
||||
int rtems_filesystem_evaluate_path(
|
||||
int rtems_filesystem_evaluate_relative_path(
|
||||
const char *pathname,
|
||||
int pathnamelen,
|
||||
int flags,
|
||||
rtems_filesystem_location_info_t *pathloc,
|
||||
int follow_link
|
||||
);
|
||||
|
||||
int rtems_filesystem_evaluate_parent(
|
||||
int rtems_filesystem_evaluate_path(
|
||||
const char *pathname,
|
||||
int pathnamelen,
|
||||
int flags,
|
||||
rtems_filesystem_location_info_t *pathloc
|
||||
rtems_filesystem_location_info_t *pathloc,
|
||||
int follow_link
|
||||
);
|
||||
|
||||
int rtems_filesystem_dirname(
|
||||
const char *pathname
|
||||
);
|
||||
|
||||
int rtems_filesystem_prefix_separators(
|
||||
const char *pathname,
|
||||
int pathnamelen
|
||||
);
|
||||
|
||||
void rtems_filesystem_initialize(void);
|
||||
|
||||
@@ -89,10 +89,10 @@ void rtems_filesystem_initialize( void )
|
||||
*/
|
||||
rtems_filesystem_root = entry->mt_fs_root;
|
||||
/* Clone the root pathloc */
|
||||
rtems_filesystem_evaluate_path("/", 0, &loc, 0);
|
||||
rtems_filesystem_evaluate_path("/", 1, 0, &loc, 0);
|
||||
rtems_filesystem_root = loc;
|
||||
/* One more clone for the current node */
|
||||
rtems_filesystem_evaluate_path("/", 0, &loc, 0);
|
||||
rtems_filesystem_evaluate_path("/", 1, 0, &loc, 0);
|
||||
rtems_filesystem_current = loc;
|
||||
|
||||
/* Note: the global_env's refcnt doesn't matter
|
||||
|
||||
@@ -35,7 +35,7 @@ int chdir(
|
||||
*/
|
||||
|
||||
result = rtems_filesystem_evaluate_path(
|
||||
pathname, RTEMS_LIBIO_PERMS_SEARCH, &loc, true );
|
||||
pathname, strlen( pathname ), RTEMS_LIBIO_PERMS_SEARCH, &loc, true );
|
||||
if ( result != 0 )
|
||||
return -1;
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ int chmod(
|
||||
rtems_filesystem_location_info_t loc;
|
||||
int result;
|
||||
|
||||
status = rtems_filesystem_evaluate_path( path, 0, &loc, true );
|
||||
status = rtems_filesystem_evaluate_path( path, strlen( path ), 0, &loc, true );
|
||||
if ( status != 0 )
|
||||
return -1;
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ int chown(
|
||||
rtems_filesystem_location_info_t loc;
|
||||
int result;
|
||||
|
||||
if ( rtems_filesystem_evaluate_path( path, 0x00, &loc, true ) )
|
||||
if ( rtems_filesystem_evaluate_path( path, strlen( path ), 0x00, &loc, true ) )
|
||||
return -1;
|
||||
|
||||
if ( !loc.ops->chown_h ) {
|
||||
|
||||
@@ -44,7 +44,7 @@ int chroot(
|
||||
}
|
||||
|
||||
/* clone the new root location */
|
||||
if (rtems_filesystem_evaluate_path(".", 0, &loc, 0)) {
|
||||
if (rtems_filesystem_evaluate_path(".", 1, 0, &loc, 0)) {
|
||||
/* our cwd has changed, though - but there is no easy way of return :-( */
|
||||
rtems_set_errno_and_return_minus_one( errno );
|
||||
}
|
||||
|
||||
@@ -21,8 +21,9 @@
|
||||
#include <rtems/libio_.h>
|
||||
#include <rtems/seterr.h>
|
||||
|
||||
int rtems_filesystem_evaluate_path(
|
||||
int rtems_filesystem_evaluate_relative_path(
|
||||
const char *pathname,
|
||||
int pathnamelen,
|
||||
int flags,
|
||||
rtems_filesystem_location_info_t *pathloc,
|
||||
int follow_link
|
||||
@@ -42,16 +43,10 @@ int rtems_filesystem_evaluate_path(
|
||||
if ( !pathloc )
|
||||
rtems_set_errno_and_return_minus_one( EIO ); /* should never happen */
|
||||
|
||||
/*
|
||||
* Evaluate the path using the optable evalpath.
|
||||
*/
|
||||
|
||||
rtems_filesystem_get_start_loc( pathname, &i, pathloc );
|
||||
|
||||
if ( !pathloc->ops->evalpath_h )
|
||||
rtems_set_errno_and_return_minus_one( ENOTSUP );
|
||||
|
||||
result = (*pathloc->ops->evalpath_h)( &pathname[i], flags, pathloc );
|
||||
result = (*pathloc->ops->evalpath_h)( &pathname[i], pathnamelen, flags, pathloc );
|
||||
|
||||
/*
|
||||
* Get the Node type and determine if you need to follow the link or
|
||||
@@ -90,34 +85,79 @@ int rtems_filesystem_evaluate_path(
|
||||
*/
|
||||
|
||||
result = (*pathloc->ops->eval_link_h)( pathloc, flags );
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
int rtems_filesystem_evaluate_parent(
|
||||
int rtems_filesystem_evaluate_path(
|
||||
const char *pathname,
|
||||
int pathnamelen,
|
||||
int flags,
|
||||
rtems_filesystem_location_info_t *pathloc
|
||||
rtems_filesystem_location_info_t *pathloc,
|
||||
int follow_link
|
||||
)
|
||||
{
|
||||
rtems_filesystem_location_info_t parent;
|
||||
int result;
|
||||
int i;
|
||||
int result;
|
||||
rtems_filesystem_node_types_t type;
|
||||
|
||||
/*
|
||||
* Verify Input parameters.
|
||||
*/
|
||||
|
||||
if ( !pathname )
|
||||
rtems_set_errno_and_return_minus_one( EFAULT );
|
||||
|
||||
if ( !pathloc )
|
||||
rtems_set_errno_and_return_minus_one( EIO ); /* should never happen */
|
||||
|
||||
if ( !pathloc->ops->evalpath_h )
|
||||
rtems_set_errno_and_return_minus_one( ENOTSUP );
|
||||
/*
|
||||
* Evaluate the path using the optable evalpath.
|
||||
*/
|
||||
|
||||
parent = *pathloc;
|
||||
result = (*pathloc->ops->evalpath_h)( "..", flags, &parent );
|
||||
if (result != 0){
|
||||
return -1;
|
||||
}
|
||||
rtems_filesystem_freenode( &parent );
|
||||
rtems_filesystem_get_start_loc( pathname, &i, pathloc );
|
||||
|
||||
return result;
|
||||
/*
|
||||
* We evaluation the path relative to the start location we get got.
|
||||
*/
|
||||
return rtems_filesystem_evaluate_relative_path( pathname,
|
||||
pathnamelen,
|
||||
flags,
|
||||
pathloc,
|
||||
follow_link );
|
||||
}
|
||||
|
||||
int rtems_filesystem_dirname(
|
||||
const char *pathname
|
||||
)
|
||||
{
|
||||
int len = strlen( pathname );
|
||||
|
||||
while ( len ) {
|
||||
len--;
|
||||
if ( rtems_filesystem_is_separator( pathname[len] ) )
|
||||
break;
|
||||
}
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
int rtems_filesystem_prefix_separators(
|
||||
const char *pathname,
|
||||
int pathnamelen
|
||||
)
|
||||
{
|
||||
/*
|
||||
* Eat any separators at start of the path.
|
||||
*/
|
||||
int stripped = 0;
|
||||
while ( *pathname && pathnamelen && rtems_filesystem_is_separator( *pathname ) )
|
||||
{
|
||||
pathname++;
|
||||
pathnamelen--;
|
||||
stripped++;
|
||||
}
|
||||
return stripped;
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ int fchdir(
|
||||
rtems_filesystem_current = iop->pathinfo;
|
||||
|
||||
/* clone the current node */
|
||||
if (rtems_filesystem_evaluate_path(".", 0, &loc, 0)) {
|
||||
if (rtems_filesystem_evaluate_path(".", 1, 0, &loc, 0)) {
|
||||
/* cloning failed; restore original and bail out */
|
||||
rtems_filesystem_current = saved;
|
||||
return -1;
|
||||
|
||||
@@ -37,7 +37,8 @@ int link(
|
||||
* Get the node we are linking to.
|
||||
*/
|
||||
|
||||
result = rtems_filesystem_evaluate_path( existing, 0, &existing_loc, true );
|
||||
result = rtems_filesystem_evaluate_path( existing, strlen( existing ),
|
||||
0, &existing_loc, true );
|
||||
if ( result != 0 )
|
||||
return -1;
|
||||
|
||||
|
||||
@@ -139,7 +139,7 @@ int mount(
|
||||
if ( mount_point ) {
|
||||
|
||||
if ( rtems_filesystem_evaluate_path(
|
||||
mount_point, RTEMS_LIBIO_PERMS_RWX, &loc, true ) == -1 )
|
||||
mount_point, strlen( mount_point ), RTEMS_LIBIO_PERMS_RWX, &loc, true ) == -1 )
|
||||
goto cleanup_and_bail;
|
||||
|
||||
loc_to_free = &loc;
|
||||
|
||||
@@ -111,7 +111,7 @@ int open(
|
||||
*/
|
||||
|
||||
status = rtems_filesystem_evaluate_path(
|
||||
pathname, eval_flags, &loc, true );
|
||||
pathname, strlen( pathname ), eval_flags, &loc, true );
|
||||
|
||||
if ( status == -1 ) {
|
||||
if ( errno != ENOENT ) {
|
||||
@@ -133,7 +133,7 @@ int open(
|
||||
}
|
||||
|
||||
/* Sanity check to see if the file name exists after the mknod() */
|
||||
status = rtems_filesystem_evaluate_path( pathname, 0x0, &loc, true );
|
||||
status = rtems_filesystem_evaluate_path( pathname, strlen( pathname ), 0x0, &loc, true );
|
||||
if ( status != 0 ) { /* The file did not exist */
|
||||
rc = EACCES;
|
||||
goto done;
|
||||
|
||||
@@ -91,9 +91,9 @@ rtems_status_code rtems_libio_set_private_env(void) {
|
||||
* clones.
|
||||
*/
|
||||
|
||||
rtems_filesystem_evaluate_path("/", 0, &loc, 0);
|
||||
rtems_filesystem_evaluate_path("/", 1, 0, &loc, 0);
|
||||
rtems_filesystem_root = loc;
|
||||
rtems_filesystem_evaluate_path("/", 0, &loc, 0);
|
||||
rtems_filesystem_evaluate_path("/", 1, 0, &loc, 0);
|
||||
rtems_filesystem_current = loc;
|
||||
|
||||
return RTEMS_SUCCESSFUL;
|
||||
|
||||
@@ -30,7 +30,8 @@ ssize_t readlink(
|
||||
if (!buf)
|
||||
rtems_set_errno_and_return_minus_one( EFAULT );
|
||||
|
||||
result = rtems_filesystem_evaluate_path( pathname, 0, &loc, false );
|
||||
result = rtems_filesystem_evaluate_path( pathname, strlen( pathname ),
|
||||
0, &loc, false );
|
||||
if ( result != 0 )
|
||||
return -1;
|
||||
|
||||
|
||||
@@ -28,20 +28,42 @@ int rmdir(
|
||||
const char *pathname
|
||||
)
|
||||
{
|
||||
int parentpathlen;
|
||||
const char *name;
|
||||
rtems_filesystem_location_info_t parentloc;
|
||||
rtems_filesystem_location_info_t loc;
|
||||
int i;
|
||||
int result;
|
||||
|
||||
|
||||
/*
|
||||
* Get the node where we wish to go.
|
||||
* Get the parent node of the node we wish to remove. Find the parent path.
|
||||
*/
|
||||
|
||||
result = rtems_filesystem_evaluate_path( pathname, 0, &loc, false );
|
||||
if ( result != 0 )
|
||||
return -1;
|
||||
parentpathlen = rtems_filesystem_dirname ( pathname );
|
||||
|
||||
result = rtems_filesystem_evaluate_parent(RTEMS_LIBIO_PERMS_WRITE, &loc );
|
||||
if (result != 0) {
|
||||
rtems_filesystem_freenode( &loc );
|
||||
if ( parentpathlen == 0 )
|
||||
rtems_filesystem_get_start_loc( pathname, &i, &parentloc );
|
||||
else {
|
||||
result = rtems_filesystem_evaluate_path(pathname, parentpathlen,
|
||||
RTEMS_LIBIO_PERMS_WRITE,
|
||||
&parentloc,
|
||||
false );
|
||||
if ( result != 0 )
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Start from the parent to find the node that should be under it.
|
||||
*/
|
||||
|
||||
loc = parentloc;
|
||||
name = pathname + parentpathlen;
|
||||
name += rtems_filesystem_prefix_separators( name, strlen( name ) );
|
||||
|
||||
result = rtems_filesystem_evaluate_relative_path( name , strlen( name ),
|
||||
0, &loc, false );
|
||||
if ( result != 0 ) {
|
||||
rtems_filesystem_freenode( &parentloc );
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -51,11 +73,13 @@ int rmdir(
|
||||
|
||||
if ( !loc.ops->node_type_h ){
|
||||
rtems_filesystem_freenode( &loc );
|
||||
rtems_filesystem_freenode( &parentloc );
|
||||
rtems_set_errno_and_return_minus_one( ENOTSUP );
|
||||
}
|
||||
|
||||
if ( (*loc.ops->node_type_h)( &loc ) != RTEMS_FILESYSTEM_DIRECTORY ){
|
||||
rtems_filesystem_freenode( &loc );
|
||||
rtems_filesystem_freenode( &parentloc );
|
||||
rtems_set_errno_and_return_minus_one( ENOTDIR );
|
||||
}
|
||||
|
||||
@@ -65,12 +89,14 @@ int rmdir(
|
||||
|
||||
if ( !loc.handlers->rmnod_h ){
|
||||
rtems_filesystem_freenode( &loc );
|
||||
rtems_filesystem_freenode( &parentloc );
|
||||
rtems_set_errno_and_return_minus_one( ENOTSUP );
|
||||
}
|
||||
|
||||
result = (*loc.handlers->rmnod_h)( &loc );
|
||||
result = (*loc.handlers->rmnod_h)( &parentloc, &loc );
|
||||
|
||||
rtems_filesystem_freenode( &loc );
|
||||
rtems_filesystem_freenode( &parentloc );
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -59,7 +59,8 @@ int _STAT_NAME(
|
||||
if ( !buf )
|
||||
rtems_set_errno_and_return_minus_one( EFAULT );
|
||||
|
||||
status = rtems_filesystem_evaluate_path( path, 0, &loc, _STAT_FOLLOW_LINKS );
|
||||
status = rtems_filesystem_evaluate_path( path, strlen( path ),
|
||||
0, &loc, _STAT_FOLLOW_LINKS );
|
||||
if ( status != 0 )
|
||||
return -1;
|
||||
|
||||
|
||||
@@ -24,41 +24,67 @@ int unlink(
|
||||
const char *path
|
||||
)
|
||||
{
|
||||
int parentpathlen;
|
||||
const char *name;
|
||||
rtems_filesystem_location_info_t parentloc;
|
||||
rtems_filesystem_location_info_t loc;
|
||||
int i;
|
||||
int result;
|
||||
|
||||
/*
|
||||
* Get the node to be unlinked.
|
||||
* Get the node to be unlinked. Find the parent path first.
|
||||
*/
|
||||
|
||||
result = rtems_filesystem_evaluate_path( path, 0, &loc, false );
|
||||
if ( result != 0 )
|
||||
return -1;
|
||||
|
||||
result = rtems_filesystem_evaluate_parent(RTEMS_LIBIO_PERMS_WRITE, &loc );
|
||||
if (result != 0 && errno != ENOTSUP) {
|
||||
rtems_filesystem_freenode( &loc );
|
||||
|
||||
parentpathlen = rtems_filesystem_dirname ( path );
|
||||
|
||||
if ( parentpathlen == 0 )
|
||||
rtems_filesystem_get_start_loc( path, &i, &parentloc );
|
||||
else {
|
||||
result = rtems_filesystem_evaluate_path( path, parentpathlen,
|
||||
RTEMS_LIBIO_PERMS_WRITE,
|
||||
&parentloc,
|
||||
false );
|
||||
if ( result != 0 )
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Start from the parent to find the node that should be under it.
|
||||
*/
|
||||
|
||||
loc = parentloc;
|
||||
name = path + parentpathlen;
|
||||
name += rtems_filesystem_prefix_separators( name, strlen( name ) );
|
||||
|
||||
result = rtems_filesystem_evaluate_relative_path( name , strlen( name ),
|
||||
0, &loc, false );
|
||||
if ( result != 0 ) {
|
||||
rtems_filesystem_freenode( &parentloc );
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
if ( !loc.ops->node_type_h ) {
|
||||
rtems_filesystem_freenode( &loc );
|
||||
rtems_filesystem_freenode( &parentloc );
|
||||
rtems_set_errno_and_return_minus_one( ENOTSUP );
|
||||
}
|
||||
|
||||
if ( (*loc.ops->node_type_h)( &loc ) == RTEMS_FILESYSTEM_DIRECTORY ) {
|
||||
rtems_filesystem_freenode( &loc );
|
||||
rtems_filesystem_freenode( &parentloc );
|
||||
rtems_set_errno_and_return_minus_one( EISDIR );
|
||||
}
|
||||
|
||||
if ( !loc.ops->unlink_h ) {
|
||||
rtems_filesystem_freenode( &loc );
|
||||
rtems_filesystem_freenode( &parentloc );
|
||||
rtems_set_errno_and_return_minus_one( ENOTSUP );
|
||||
}
|
||||
|
||||
result = (*loc.ops->unlink_h)( &loc );
|
||||
result = (*loc.ops->unlink_h)( &parentloc, &loc );
|
||||
|
||||
rtems_filesystem_freenode( &loc );
|
||||
rtems_filesystem_freenode( &parentloc );
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -113,7 +113,7 @@ int unmount(
|
||||
* The mount entry that is being refered to.
|
||||
*/
|
||||
|
||||
if ( rtems_filesystem_evaluate_path( path, 0x0, &loc, true ) )
|
||||
if ( rtems_filesystem_evaluate_path( path, strlen( path ), 0x0, &loc, true ) )
|
||||
return -1;
|
||||
|
||||
mt_entry = loc.mt_entry;
|
||||
|
||||
@@ -30,7 +30,7 @@ int utime(
|
||||
rtems_filesystem_location_info_t temp_loc;
|
||||
int result;
|
||||
|
||||
if ( rtems_filesystem_evaluate_path( path, 0x00, &temp_loc, true ) )
|
||||
if ( rtems_filesystem_evaluate_path( path, strlen( path ), 0x00, &temp_loc, true ) )
|
||||
return -1;
|
||||
|
||||
if ( !temp_loc.ops->utime_h ){
|
||||
|
||||
@@ -195,6 +195,7 @@ extern int devFS_node_type(
|
||||
|
||||
extern int devFS_evaluate_path(
|
||||
const char *pathname,
|
||||
int pathnamelen,
|
||||
int flags,
|
||||
rtems_filesystem_location_info_t *pathloc
|
||||
);
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
|
||||
int devFS_evaluate_path(
|
||||
const char *pathname,
|
||||
int pathnamelen,
|
||||
int flags,
|
||||
rtems_filesystem_location_info_t *pathloc
|
||||
)
|
||||
@@ -37,7 +38,7 @@ int devFS_evaluate_path(
|
||||
|
||||
for (i = 0; i < rtems_device_table_size; i++){
|
||||
if ((device_name_table[i].device_name) &&
|
||||
(strcmp(device_name_table[i].device_name, pathname) == 0)){
|
||||
(strncmp(pathname, device_name_table[i].device_name, pathnamelen) == 0)){
|
||||
/* find the device, set proper values */
|
||||
pathloc->node_access = (void *)&device_name_table[i];
|
||||
pathloc->handlers = &devFS_file_handlers;
|
||||
|
||||
@@ -30,7 +30,7 @@ int devFS_stat(
|
||||
if (!the_dev)
|
||||
rtems_set_errno_and_return_minus_one( EFAULT );
|
||||
|
||||
buf->st_dev = rtems_filesystem_make_dev_t( the_dev->major, the_dev->minor );
|
||||
buf->st_rdev = rtems_filesystem_make_dev_t( the_dev->major, the_dev->minor );
|
||||
|
||||
buf->st_mode = the_dev->mode;
|
||||
|
||||
|
||||
@@ -354,11 +354,11 @@ fat_init_volume_info(rtems_filesystem_mount_table_entry_t *mt_entry)
|
||||
rtems_set_errno_and_return_minus_one(ENOTBLK);
|
||||
|
||||
/* check that device is registred as block device and lock it */
|
||||
vol->dd = rtems_disk_obtain(stat_buf.st_dev);
|
||||
vol->dd = rtems_disk_obtain(stat_buf.st_rdev);
|
||||
if (vol->dd == NULL)
|
||||
rtems_set_errno_and_return_minus_one(ENOTBLK);
|
||||
|
||||
vol->dev = stat_buf.st_dev;
|
||||
vol->dev = stat_buf.st_rdev;
|
||||
|
||||
/* Read boot record */
|
||||
/* FIXME: Asserts FAT_MAX_BPB_SIZE < bdbuf block size */
|
||||
|
||||
@@ -228,9 +228,10 @@ int msdos_initialize(rtems_filesystem_mount_table_entry_t *temp_mt_entry);
|
||||
int msdos_shut_down(rtems_filesystem_mount_table_entry_t *temp_mt_entry);
|
||||
|
||||
int msdos_eval_path(
|
||||
const char *pathname, /* IN */
|
||||
int flags, /* IN */
|
||||
rtems_filesystem_location_info_t *pathloc /* IN/OUT */
|
||||
const char *pathname, /* IN */
|
||||
int pathnamelen, /* IN */
|
||||
int flags, /* IN */
|
||||
rtems_filesystem_location_info_t *pathloc /* IN/OUT */
|
||||
);
|
||||
|
||||
int msdos_eval4make(
|
||||
@@ -319,7 +320,8 @@ msdos_dir_chmod(
|
||||
mode_t mode /* IN */
|
||||
);
|
||||
|
||||
int msdos_file_rmnod(rtems_filesystem_location_info_t *pathloc /* IN */);
|
||||
int msdos_file_rmnod(rtems_filesystem_location_info_t *parent_pathloc, /* IN */
|
||||
rtems_filesystem_location_info_t *pathloc /* IN */);
|
||||
|
||||
int msdos_file_link(
|
||||
rtems_filesystem_location_info_t *to_loc,
|
||||
@@ -354,7 +356,8 @@ msdos_file_chmod(
|
||||
mode_t mode /* IN */
|
||||
);
|
||||
|
||||
int msdos_dir_rmnod(rtems_filesystem_location_info_t *pathloc /* IN */);
|
||||
int msdos_dir_rmnod(rtems_filesystem_location_info_t *parent_pathloc, /* IN */
|
||||
rtems_filesystem_location_info_t *pathloc /* IN */);
|
||||
|
||||
int msdos_dir_sync(rtems_libio_t *iop);
|
||||
|
||||
@@ -372,6 +375,7 @@ int msdos_creat_node(rtems_filesystem_location_info_t *parent_loc,
|
||||
|
||||
/* Misc prototypes */
|
||||
msdos_token_types_t msdos_get_token(const char *path,
|
||||
int pathlen,
|
||||
const char **token,
|
||||
int *token_len);
|
||||
|
||||
|
||||
@@ -310,7 +310,7 @@ msdos_file_link(rtems_filesystem_location_info_t *to_loc,
|
||||
/*
|
||||
* check spelling and format new node name
|
||||
*/
|
||||
if (MSDOS_NAME != msdos_get_token(name, &token, &len)) {
|
||||
if (MSDOS_NAME != msdos_get_token(name, strlen(name), &token, &len)) {
|
||||
rtems_set_errno_and_return_minus_one(ENAMETOOLONG);
|
||||
}
|
||||
/*
|
||||
|
||||
@@ -637,7 +637,8 @@ msdos_dir_chmod(rtems_filesystem_location_info_t *pathloc,
|
||||
* RC_OK on success, or -1 if error occured (errno set apropriately).
|
||||
*/
|
||||
int
|
||||
msdos_dir_rmnod(rtems_filesystem_location_info_t *pathloc)
|
||||
msdos_dir_rmnod(rtems_filesystem_location_info_t *parent_pathloc,
|
||||
rtems_filesystem_location_info_t *pathloc)
|
||||
{
|
||||
int rc = RC_OK;
|
||||
rtems_status_code sc = RTEMS_SUCCESSFUL;
|
||||
|
||||
@@ -72,6 +72,7 @@ msdos_set_handlers(rtems_filesystem_location_info_t *loc)
|
||||
int
|
||||
msdos_eval_path(
|
||||
const char *pathname,
|
||||
int pathnamelen,
|
||||
int flags,
|
||||
rtems_filesystem_location_info_t *pathloc
|
||||
)
|
||||
@@ -106,7 +107,8 @@ msdos_eval_path(
|
||||
|
||||
while ((type != MSDOS_NO_MORE_PATH) && (type != MSDOS_INVALID_TOKEN))
|
||||
{
|
||||
type = msdos_get_token(&pathname[i], &token, &token_len);
|
||||
type = msdos_get_token(&pathname[i], pathnamelen, &token, &token_len);
|
||||
pathnamelen += token_len;
|
||||
i += token_len;
|
||||
|
||||
fat_fd = pathloc->node_access;
|
||||
@@ -150,6 +152,7 @@ msdos_eval_path(
|
||||
|
||||
rtems_semaphore_release(fs_info->vol_sema);
|
||||
return (*pathloc->ops->evalpath_h)(&(pathname[i-token_len]),
|
||||
pathnamelen - token_len,
|
||||
flags, pathloc);
|
||||
}
|
||||
}
|
||||
@@ -288,7 +291,7 @@ msdos_eval4make(
|
||||
|
||||
while (!done)
|
||||
{
|
||||
type = msdos_get_token(&path[i], &token, &token_len);
|
||||
type = msdos_get_token(&path[i], strlen(&path[i]), &token, &token_len);
|
||||
i += token_len;
|
||||
fat_fd = pathloc->node_access;
|
||||
|
||||
|
||||
@@ -474,7 +474,8 @@ msdos_file_chmod(rtems_filesystem_location_info_t *pathloc,
|
||||
* RC_OK on success, or -1 if error occured (errno set appropriately)
|
||||
*/
|
||||
int
|
||||
msdos_file_rmnod(rtems_filesystem_location_info_t *pathloc)
|
||||
msdos_file_rmnod(rtems_filesystem_location_info_t *parent_pathloc,
|
||||
rtems_filesystem_location_info_t *pathloc)
|
||||
{
|
||||
int rc = RC_OK;
|
||||
rtems_status_code sc = RTEMS_SUCCESSFUL;
|
||||
|
||||
@@ -916,7 +916,7 @@ int msdos_format
|
||||
|
||||
/* check that device is registered as block device and lock it */
|
||||
if (ret_val == 0) {
|
||||
dd = rtems_disk_obtain(stat_buf.st_dev);
|
||||
dd = rtems_disk_obtain(stat_buf.st_rdev);
|
||||
if (dd == NULL) {
|
||||
errno = ENOTBLK;
|
||||
ret_val = -1;
|
||||
|
||||
@@ -227,7 +227,10 @@ msdos_long_to_short(const char *lfn, int lfn_len, char* sfn, int sfn_len)
|
||||
*
|
||||
*/
|
||||
msdos_token_types_t
|
||||
msdos_get_token(const char *path, const char **ret_token, int *ret_token_len)
|
||||
msdos_get_token(const char *path,
|
||||
int pathlen,
|
||||
const char **ret_token,
|
||||
int *ret_token_len)
|
||||
{
|
||||
msdos_token_types_t type = MSDOS_NAME;
|
||||
int i = 0;
|
||||
@@ -238,7 +241,7 @@ msdos_get_token(const char *path, const char **ret_token, int *ret_token_len)
|
||||
/*
|
||||
* Check for a separator.
|
||||
*/
|
||||
while (!msdos_is_separator(path[i]))
|
||||
while (!msdos_is_separator(path[i]) && (i < pathlen))
|
||||
{
|
||||
if ( !msdos_is_valid_name_char(path[i]) )
|
||||
return MSDOS_INVALID_TOKEN;
|
||||
@@ -254,7 +257,7 @@ msdos_get_token(const char *path, const char **ret_token, int *ret_token_len)
|
||||
*/
|
||||
if ( i == 0 )
|
||||
{
|
||||
if ( *path != '\0' )
|
||||
if ( (*path != '\0') && pathlen )
|
||||
{
|
||||
i++;
|
||||
type = MSDOS_CURRENT_DIR;
|
||||
|
||||
@@ -277,6 +277,7 @@ extern int rtems_tarfs_load(
|
||||
*/
|
||||
extern IMFS_token_types IMFS_get_token(
|
||||
const char *path,
|
||||
int pathlen,
|
||||
char *token,
|
||||
int *token_len
|
||||
);
|
||||
@@ -316,6 +317,7 @@ extern int IMFS_evaluate_link(
|
||||
|
||||
extern int IMFS_eval_path(
|
||||
const char *pathname, /* IN */
|
||||
int pathnamelen, /* IN */
|
||||
int flags, /* IN */
|
||||
rtems_filesystem_location_info_t *pathloc /* IN/OUT */
|
||||
);
|
||||
@@ -328,7 +330,8 @@ extern int IMFS_link(
|
||||
);
|
||||
|
||||
extern int IMFS_unlink(
|
||||
rtems_filesystem_location_info_t *pathloc /* IN */
|
||||
rtems_filesystem_location_info_t *parent_pathloc, /* IN */
|
||||
rtems_filesystem_location_info_t *pathloc /* IN */
|
||||
);
|
||||
|
||||
extern int IMFS_chown(
|
||||
@@ -412,7 +415,8 @@ extern int imfs_dir_fstat(
|
||||
);
|
||||
|
||||
extern int imfs_dir_rmnod(
|
||||
rtems_filesystem_location_info_t *pathloc /* IN */
|
||||
rtems_filesystem_location_info_t *parent_pathloc, /* IN */
|
||||
rtems_filesystem_location_info_t *pathloc /* IN */
|
||||
);
|
||||
|
||||
extern int memfile_open(
|
||||
@@ -451,7 +455,8 @@ extern rtems_off64_t memfile_lseek(
|
||||
);
|
||||
|
||||
extern int memfile_rmnod(
|
||||
rtems_filesystem_location_info_t *pathloc /* IN */
|
||||
rtems_filesystem_location_info_t *parent_pathloc, /* IN */
|
||||
rtems_filesystem_location_info_t *pathloc /* IN */
|
||||
);
|
||||
|
||||
extern int device_open(
|
||||
@@ -527,7 +532,8 @@ extern int IMFS_fcntl(
|
||||
);
|
||||
|
||||
extern int IMFS_rmnod(
|
||||
rtems_filesystem_location_info_t *pathloc /* IN */
|
||||
rtems_filesystem_location_info_t *parent_pathloc, /* IN */
|
||||
rtems_filesystem_location_info_t *pathloc /* IN */
|
||||
);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -282,7 +282,8 @@ int imfs_dir_fstat(
|
||||
*/
|
||||
|
||||
int imfs_dir_rmnod(
|
||||
rtems_filesystem_location_info_t *pathloc /* IN */
|
||||
rtems_filesystem_location_info_t *parent_pathloc, /* IN */
|
||||
rtems_filesystem_location_info_t *pathloc /* IN */
|
||||
)
|
||||
{
|
||||
IMFS_jnode_t *the_jnode;
|
||||
|
||||
@@ -206,6 +206,7 @@ int IMFS_evaluate_sym_link(
|
||||
|
||||
result = IMFS_eval_path(
|
||||
&jnode->info.sym_link.name[i],
|
||||
strlen( &jnode->info.sym_link.name[i] ),
|
||||
flags,
|
||||
node
|
||||
);
|
||||
@@ -294,6 +295,7 @@ int IMFS_evaluate_for_make(
|
||||
rtems_filesystem_location_info_t newloc;
|
||||
IMFS_jnode_t *node;
|
||||
bool done = false;
|
||||
int pathlen;
|
||||
int result;
|
||||
|
||||
/*
|
||||
@@ -302,13 +304,18 @@ int IMFS_evaluate_for_make(
|
||||
*/
|
||||
node = pathloc->node_access;
|
||||
|
||||
/*
|
||||
* Get the path length.
|
||||
*/
|
||||
pathlen = strlen( path );
|
||||
/*
|
||||
* Evaluate all tokens until we are done or an error occurs.
|
||||
*/
|
||||
|
||||
|
||||
while( !done ) {
|
||||
|
||||
type = IMFS_get_token( &path[i], token, &len );
|
||||
type = IMFS_get_token( &path[i], pathlen, token, &len );
|
||||
pathlen -= len;
|
||||
i += len;
|
||||
|
||||
if ( !pathloc->node_access )
|
||||
@@ -480,6 +487,7 @@ int IMFS_evaluate_for_make(
|
||||
|
||||
int IMFS_eval_path(
|
||||
const char *pathname, /* IN */
|
||||
int pathnamelen, /* IN */
|
||||
int flags, /* IN */
|
||||
rtems_filesystem_location_info_t *pathloc /* IN/OUT */
|
||||
)
|
||||
@@ -510,8 +518,9 @@ int IMFS_eval_path(
|
||||
|
||||
while( (type != IMFS_NO_MORE_PATH) && (type != IMFS_INVALID_TOKEN) ) {
|
||||
|
||||
type = IMFS_get_token( &pathname[i], token, &len );
|
||||
i += len;
|
||||
type = IMFS_get_token( &pathname[i], pathnamelen, token, &len );
|
||||
pathnamelen -= len;
|
||||
i += len;
|
||||
|
||||
if ( !pathloc->node_access )
|
||||
rtems_set_errno_and_return_minus_one( ENOENT );
|
||||
@@ -551,7 +560,9 @@ int IMFS_eval_path(
|
||||
} else {
|
||||
newloc = pathloc->mt_entry->mt_point_node;
|
||||
*pathloc = newloc;
|
||||
return (*pathloc->ops->evalpath_h)(&(pathname[i-len]),flags,pathloc);
|
||||
return (*pathloc->ops->evalpath_h)(&(pathname[i-len]),
|
||||
pathnamelen+len,
|
||||
flags,pathloc);
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -603,7 +614,9 @@ int IMFS_eval_path(
|
||||
if ( node->info.directory.mt_fs != NULL ) {
|
||||
newloc = node->info.directory.mt_fs->mt_fs_root;
|
||||
*pathloc = newloc;
|
||||
return (*pathloc->ops->evalpath_h)( &pathname[i-len], flags, pathloc );
|
||||
return (*pathloc->ops->evalpath_h)( &pathname[i-len],
|
||||
pathnamelen+len,
|
||||
flags, pathloc );
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -645,7 +658,9 @@ int IMFS_eval_path(
|
||||
if ( node->info.directory.mt_fs != NULL ) {
|
||||
newloc = node->info.directory.mt_fs->mt_fs_root;
|
||||
*pathloc = newloc;
|
||||
return (*pathloc->ops->evalpath_h)( &pathname[i-len], flags, pathloc );
|
||||
return (*pathloc->ops->evalpath_h)( &pathname[i-len],
|
||||
pathnamelen+len,
|
||||
flags, pathloc );
|
||||
} else {
|
||||
result = IMFS_Set_handlers( pathloc );
|
||||
}
|
||||
|
||||
@@ -46,11 +46,9 @@ int IMFS_fchmod(
|
||||
/*
|
||||
* Change only the RWX permissions on the jnode to mode.
|
||||
*/
|
||||
if ( mode & (~ (S_IRWXU | S_IRWXG | S_IRWXO ) ) )
|
||||
rtems_set_errno_and_return_minus_one( EPERM );
|
||||
|
||||
jnode->st_mode &= ~(S_IRWXU | S_IRWXG | S_IRWXO);
|
||||
jnode->st_mode |= mode;
|
||||
jnode->st_mode &= ~(S_IRWXU | S_IRWXG | S_IRWXO | S_ISUID | S_ISGID | S_ISVTX);
|
||||
jnode->st_mode |= mode & (S_IRWXU | S_IRWXG | S_IRWXO | S_ISUID | S_ISGID | S_ISVTX);
|
||||
|
||||
IMFS_update_ctime( jnode );
|
||||
|
||||
|
||||
@@ -74,12 +74,12 @@ int IMFS_fsunmount(
|
||||
IMFS_Set_handlers( &loc );
|
||||
|
||||
if ( jnode->type != IMFS_DIRECTORY ) {
|
||||
result = IMFS_unlink( &loc );
|
||||
result = IMFS_unlink( NULL, &loc );
|
||||
if (result != 0)
|
||||
return -1;
|
||||
jnode = next;
|
||||
} else if ( jnode_has_no_children( jnode ) ) {
|
||||
result = IMFS_unlink( &loc );
|
||||
result = IMFS_unlink( NULL, &loc );
|
||||
if (result != 0)
|
||||
return -1;
|
||||
jnode = next;
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
|
||||
IMFS_token_types IMFS_get_token(
|
||||
const char *path,
|
||||
int pathlen,
|
||||
char *token,
|
||||
int *token_len
|
||||
)
|
||||
@@ -38,7 +39,7 @@ IMFS_token_types IMFS_get_token(
|
||||
* Copy a name into token. (Remember NULL is a token.)
|
||||
*/
|
||||
c = path[i];
|
||||
while ( (!IMFS_is_separator(c)) && (i <= IMFS_NAME_MAX) ) {
|
||||
while ( (!IMFS_is_separator(c)) && (i < pathlen) && (i <= IMFS_NAME_MAX) ) {
|
||||
|
||||
token[i] = c;
|
||||
|
||||
@@ -58,7 +59,7 @@ IMFS_token_types IMFS_get_token(
|
||||
if ( i == 0 ) {
|
||||
token[i] = c;
|
||||
|
||||
if ( token[i] != '\0' ) {
|
||||
if ( (token[i] != '\0') && pathlen ) {
|
||||
i++;
|
||||
type = IMFS_CURRENT_DIR;
|
||||
} else {
|
||||
|
||||
@@ -47,7 +47,7 @@ int IMFS_link(
|
||||
* Remove any separators at the end of the string.
|
||||
*/
|
||||
|
||||
IMFS_get_token( token, new_name, &i );
|
||||
IMFS_get_token( token, strlen( token ), new_name, &i );
|
||||
|
||||
/*
|
||||
* Create a new link node.
|
||||
|
||||
@@ -92,7 +92,8 @@ rtems_tarfs_load(
|
||||
IMFS_jnode_t *node;
|
||||
int status;
|
||||
|
||||
status = rtems_filesystem_evaluate_path(mountpoint, 0, &root_loc, 0);
|
||||
status = rtems_filesystem_evaluate_path(mountpoint, strlen(mountpoint),
|
||||
0, &root_loc, 0);
|
||||
if (status != 0)
|
||||
return(-1);
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ int IMFS_mknod(
|
||||
char new_name[ IMFS_NAME_MAX + 1 ];
|
||||
IMFS_types_union info;
|
||||
|
||||
IMFS_get_token( token, new_name, &result );
|
||||
IMFS_get_token( token, strlen( token ), new_name, &result );
|
||||
|
||||
/*
|
||||
* Figure out what type of IMFS node this is.
|
||||
|
||||
@@ -31,7 +31,8 @@
|
||||
*/
|
||||
|
||||
int IMFS_rmnod(
|
||||
rtems_filesystem_location_info_t *pathloc /* IN */
|
||||
rtems_filesystem_location_info_t *parent_pathloc, /* IN */
|
||||
rtems_filesystem_location_info_t *pathloc /* IN */
|
||||
)
|
||||
{
|
||||
IMFS_jnode_t *the_jnode;
|
||||
|
||||
@@ -36,8 +36,8 @@ int IMFS_stat(
|
||||
switch ( the_jnode->type ) {
|
||||
|
||||
case IMFS_DEVICE:
|
||||
io = &the_jnode->info.device;
|
||||
buf->st_dev = rtems_filesystem_make_dev_t( io->major, io->minor );
|
||||
io = &the_jnode->info.device;
|
||||
buf->st_rdev = rtems_filesystem_make_dev_t( io->major, io->minor );
|
||||
break;
|
||||
|
||||
case IMFS_LINEAR_FILE:
|
||||
|
||||
@@ -41,7 +41,7 @@ int IMFS_symlink(
|
||||
* Remove any separators at the end of the string.
|
||||
*/
|
||||
|
||||
IMFS_get_token( node_name, new_name, &i );
|
||||
IMFS_get_token( node_name, strlen( node_name ), new_name, &i );
|
||||
|
||||
/*
|
||||
* Duplicate link name
|
||||
|
||||
@@ -25,7 +25,8 @@
|
||||
#include <rtems/seterr.h>
|
||||
|
||||
int IMFS_unlink(
|
||||
rtems_filesystem_location_info_t *loc /* IN */
|
||||
rtems_filesystem_location_info_t *parentloc, /* IN */
|
||||
rtems_filesystem_location_info_t *loc /* IN */
|
||||
)
|
||||
{
|
||||
IMFS_jnode_t *node;
|
||||
@@ -60,7 +61,7 @@ int IMFS_unlink(
|
||||
|
||||
if ( node->info.hard_link.link_node->st_nlink == 1)
|
||||
{
|
||||
result = (*the_link.handlers->rmnod_h)( &the_link );
|
||||
result = (*the_link.handlers->rmnod_h)( parentloc, &the_link );
|
||||
if ( result != 0 )
|
||||
return -1;
|
||||
}
|
||||
@@ -75,7 +76,7 @@ int IMFS_unlink(
|
||||
* Now actually free the node we were asked to free.
|
||||
*/
|
||||
|
||||
result = (*loc->handlers->rmnod_h)( loc );
|
||||
result = (*loc->handlers->rmnod_h)( parentloc, loc );
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ rtems_status_code rtems_io_lookup_name(
|
||||
int result;
|
||||
rtems_filesystem_node_types_t node_type;
|
||||
|
||||
result = rtems_filesystem_evaluate_path( name, 0x00, &loc, true );
|
||||
result = rtems_filesystem_evaluate_path( name, strlen( name ), 0x00, &loc, true );
|
||||
the_jnode = loc.node_access;
|
||||
|
||||
if ( !loc.ops->node_type_h ) {
|
||||
|
||||
@@ -1105,7 +1105,8 @@ fflush(stdout);
|
||||
*/
|
||||
|
||||
int memfile_rmnod(
|
||||
rtems_filesystem_location_info_t *pathloc /* IN */
|
||||
rtems_filesystem_location_info_t *parent_pathloc, /* IN */
|
||||
rtems_filesystem_location_info_t *pathloc /* IN */
|
||||
)
|
||||
{
|
||||
IMFS_jnode_t *the_jnode;
|
||||
|
||||
@@ -1355,6 +1355,7 @@ struct rtems_filesystem_location_info_tt
|
||||
|
||||
STATIC int nfs_do_evalpath(
|
||||
const char *pathname, /* IN */
|
||||
int pathnamelen, /* IN */
|
||||
void *arg,
|
||||
rtems_filesystem_location_info_t *pathloc, /* IN/OUT */
|
||||
int forMake
|
||||
@@ -1375,7 +1376,8 @@ unsigned long niu,siu;
|
||||
e = ENOMEM;
|
||||
goto cleanup;
|
||||
}
|
||||
strcpy(p, pathname);
|
||||
memset(p, 0, MAXPATHLEN+1);
|
||||
memcpy(p, pathname, pathnamelen);
|
||||
|
||||
LOCK(nfsGlob.lock);
|
||||
node = nfsNodeClone(node);
|
||||
@@ -1510,7 +1512,7 @@ unsigned long niu,siu;
|
||||
if (forMake)
|
||||
rval = pathloc->ops->evalformake_h(part, pathloc, (const char**)arg);
|
||||
else
|
||||
rval = pathloc->ops->evalpath_h(part, (int)arg, pathloc);
|
||||
rval = pathloc->ops->evalpath_h(part, strlen(part), (int)arg, pathloc);
|
||||
|
||||
free(p);
|
||||
return rval;
|
||||
@@ -1667,16 +1669,17 @@ static int nfs_evalformake(
|
||||
const char **pname /* OUT */
|
||||
)
|
||||
{
|
||||
return nfs_do_evalpath(path, (void*)pname, pathloc, 1 /*forMake*/);
|
||||
return nfs_do_evalpath(path, strlen(path), (void*)pname, pathloc, 1 /*forMake*/);
|
||||
}
|
||||
|
||||
static int nfs_evalpath(
|
||||
const char *path, /* IN */
|
||||
int pathlen, /* IN */
|
||||
int flags, /* IN */
|
||||
rtems_filesystem_location_info_t *pathloc /* IN/OUT */
|
||||
)
|
||||
{
|
||||
return nfs_do_evalpath(path, (void*)flags, pathloc, 0 /*not forMake*/);
|
||||
return nfs_do_evalpath(path, pathlen, (void*)flags, pathloc, 0 /*not forMake*/);
|
||||
}
|
||||
|
||||
|
||||
@@ -1729,7 +1732,8 @@ NfsNode tNode = to_loc->node_access;
|
||||
}
|
||||
|
||||
static int nfs_do_unlink(
|
||||
rtems_filesystem_location_info_t *loc, /* IN */
|
||||
rtems_filesystem_location_info_t *parent_loc,/* IN */
|
||||
rtems_filesystem_location_info_t *loc, /* IN */
|
||||
int proc
|
||||
)
|
||||
{
|
||||
@@ -1768,10 +1772,11 @@ char *name = NFSPROC_REMOVE == proc ?
|
||||
}
|
||||
|
||||
static int nfs_unlink(
|
||||
rtems_filesystem_location_info_t *loc /* IN */
|
||||
rtems_filesystem_location_info_t *parent_loc, /* IN */
|
||||
rtems_filesystem_location_info_t *loc /* IN */
|
||||
)
|
||||
{
|
||||
return nfs_do_unlink(loc, NFSPROC_REMOVE);
|
||||
return nfs_do_unlink(parent_loc, loc, NFSPROC_REMOVE);
|
||||
}
|
||||
|
||||
static int nfs_chown(
|
||||
@@ -2357,7 +2362,7 @@ int rval = RVAL_ERR_AND_DO_FREENODE;
|
||||
|
||||
pathloc->handlers = &nfs_dir_file_handlers;
|
||||
|
||||
err = nfs_evalpath(buf, flags, pathloc);
|
||||
err = nfs_evalpath(buf, strlen(buf), flags, pathloc);
|
||||
|
||||
/* according to its semantics,
|
||||
* nfs_evalpath cloned the node attached
|
||||
@@ -2398,7 +2403,7 @@ int rval = RVAL_ERR_AND_DO_FREENODE;
|
||||
*/
|
||||
rtems_filesystem_freenode(pathloc);
|
||||
|
||||
if (rtems_filesystem_evaluate_path(buf, flags, pathloc, 1)) {
|
||||
if (rtems_filesystem_evaluate_path(buf, strlen(buf), flags, pathloc, 1)) {
|
||||
/* If evalpath fails then there is no valid node
|
||||
* attached to pathloc; hence we must not attempt
|
||||
* to free the node
|
||||
@@ -3079,10 +3084,11 @@ static int nfs_file_fcntl(
|
||||
* call, though...
|
||||
*/
|
||||
static int nfs_dir_rmnod(
|
||||
rtems_filesystem_location_info_t *pathloc /* IN */
|
||||
rtems_filesystem_location_info_t *parentpathloc, /* IN */
|
||||
rtems_filesystem_location_info_t *pathloc /* IN */
|
||||
)
|
||||
{
|
||||
return nfs_do_unlink(pathloc, NFSPROC_RMDIR);
|
||||
return nfs_do_unlink(parentpathloc, pathloc, NFSPROC_RMDIR);
|
||||
}
|
||||
|
||||
/* the file handlers table */
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user