summaryrefslogtreecommitdiffstats
path: root/cpukit/libfs/src/imfs
diff options
context:
space:
mode:
authorChris Johns <chrisj@rtems.org>2009-06-12 01:53:33 +0000
committerChris Johns <chrisj@rtems.org>2009-06-12 01:53:33 +0000
commit7baa484300d36a9ced34f6642501f91fd1428461 (patch)
tree583b6d8fd3b82ea830bbb4c3b474d6aae1466ebb /cpukit/libfs/src/imfs
parent2009-06-11 Roxana Leontie <roxana.leontie@gmail.com> (diff)
downloadrtems-7baa484300d36a9ced34f6642501f91fd1428461.tar.bz2
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.
Diffstat (limited to 'cpukit/libfs/src/imfs')
-rw-r--r--cpukit/libfs/src/imfs/imfs.h14
-rw-r--r--cpukit/libfs/src/imfs/imfs_directory.c3
-rw-r--r--cpukit/libfs/src/imfs/imfs_eval.c29
-rw-r--r--cpukit/libfs/src/imfs/imfs_fchmod.c6
-rw-r--r--cpukit/libfs/src/imfs/imfs_fsunmount.c4
-rw-r--r--cpukit/libfs/src/imfs/imfs_gtkn.c5
-rw-r--r--cpukit/libfs/src/imfs/imfs_link.c2
-rw-r--r--cpukit/libfs/src/imfs/imfs_load_tar.c3
-rw-r--r--cpukit/libfs/src/imfs/imfs_mknod.c2
-rw-r--r--cpukit/libfs/src/imfs/imfs_rmnod.c3
-rw-r--r--cpukit/libfs/src/imfs/imfs_stat.c4
-rw-r--r--cpukit/libfs/src/imfs/imfs_symlink.c2
-rw-r--r--cpukit/libfs/src/imfs/imfs_unlink.c7
-rw-r--r--cpukit/libfs/src/imfs/ioman.c2
-rw-r--r--cpukit/libfs/src/imfs/memfile.c3
15 files changed, 57 insertions, 32 deletions
diff --git a/cpukit/libfs/src/imfs/imfs.h b/cpukit/libfs/src/imfs/imfs.h
index 355e494248..5345269dcb 100644
--- a/cpukit/libfs/src/imfs/imfs.h
+++ b/cpukit/libfs/src/imfs/imfs.h
@@ -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
diff --git a/cpukit/libfs/src/imfs/imfs_directory.c b/cpukit/libfs/src/imfs/imfs_directory.c
index 1107da9221..71a6d4be41 100644
--- a/cpukit/libfs/src/imfs/imfs_directory.c
+++ b/cpukit/libfs/src/imfs/imfs_directory.c
@@ -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;
diff --git a/cpukit/libfs/src/imfs/imfs_eval.c b/cpukit/libfs/src/imfs/imfs_eval.c
index 62d02f964e..5dcf7576a5 100644
--- a/cpukit/libfs/src/imfs/imfs_eval.c
+++ b/cpukit/libfs/src/imfs/imfs_eval.c
@@ -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;
/*
@@ -303,12 +305,17 @@ 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 );
}
diff --git a/cpukit/libfs/src/imfs/imfs_fchmod.c b/cpukit/libfs/src/imfs/imfs_fchmod.c
index 6cb56aa629..54a093de2f 100644
--- a/cpukit/libfs/src/imfs/imfs_fchmod.c
+++ b/cpukit/libfs/src/imfs/imfs_fchmod.c
@@ -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 );
diff --git a/cpukit/libfs/src/imfs/imfs_fsunmount.c b/cpukit/libfs/src/imfs/imfs_fsunmount.c
index c3a12efb14..19a26ffd04 100644
--- a/cpukit/libfs/src/imfs/imfs_fsunmount.c
+++ b/cpukit/libfs/src/imfs/imfs_fsunmount.c
@@ -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;
diff --git a/cpukit/libfs/src/imfs/imfs_gtkn.c b/cpukit/libfs/src/imfs/imfs_gtkn.c
index 09f1ab0174..b15b2f1136 100644
--- a/cpukit/libfs/src/imfs/imfs_gtkn.c
+++ b/cpukit/libfs/src/imfs/imfs_gtkn.c
@@ -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 {
diff --git a/cpukit/libfs/src/imfs/imfs_link.c b/cpukit/libfs/src/imfs/imfs_link.c
index 43c1613cfc..db8659db75 100644
--- a/cpukit/libfs/src/imfs/imfs_link.c
+++ b/cpukit/libfs/src/imfs/imfs_link.c
@@ -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.
diff --git a/cpukit/libfs/src/imfs/imfs_load_tar.c b/cpukit/libfs/src/imfs/imfs_load_tar.c
index 0846f2e1ee..531359162e 100644
--- a/cpukit/libfs/src/imfs/imfs_load_tar.c
+++ b/cpukit/libfs/src/imfs/imfs_load_tar.c
@@ -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);
diff --git a/cpukit/libfs/src/imfs/imfs_mknod.c b/cpukit/libfs/src/imfs/imfs_mknod.c
index 9d35e61922..f7b8ac9998 100644
--- a/cpukit/libfs/src/imfs/imfs_mknod.c
+++ b/cpukit/libfs/src/imfs/imfs_mknod.c
@@ -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.
diff --git a/cpukit/libfs/src/imfs/imfs_rmnod.c b/cpukit/libfs/src/imfs/imfs_rmnod.c
index 85202b2c87..ed6001a691 100644
--- a/cpukit/libfs/src/imfs/imfs_rmnod.c
+++ b/cpukit/libfs/src/imfs/imfs_rmnod.c
@@ -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;
diff --git a/cpukit/libfs/src/imfs/imfs_stat.c b/cpukit/libfs/src/imfs/imfs_stat.c
index 76564811e9..533899e259 100644
--- a/cpukit/libfs/src/imfs/imfs_stat.c
+++ b/cpukit/libfs/src/imfs/imfs_stat.c
@@ -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:
diff --git a/cpukit/libfs/src/imfs/imfs_symlink.c b/cpukit/libfs/src/imfs/imfs_symlink.c
index e946f3dc66..36a52e50fb 100644
--- a/cpukit/libfs/src/imfs/imfs_symlink.c
+++ b/cpukit/libfs/src/imfs/imfs_symlink.c
@@ -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
diff --git a/cpukit/libfs/src/imfs/imfs_unlink.c b/cpukit/libfs/src/imfs/imfs_unlink.c
index b416a09b8e..0ec176ed03 100644
--- a/cpukit/libfs/src/imfs/imfs_unlink.c
+++ b/cpukit/libfs/src/imfs/imfs_unlink.c
@@ -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;
}
diff --git a/cpukit/libfs/src/imfs/ioman.c b/cpukit/libfs/src/imfs/ioman.c
index ef5d4cf614..cbfcabb3a3 100644
--- a/cpukit/libfs/src/imfs/ioman.c
+++ b/cpukit/libfs/src/imfs/ioman.c
@@ -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 ) {
diff --git a/cpukit/libfs/src/imfs/memfile.c b/cpukit/libfs/src/imfs/memfile.c
index e9b4d70f97..08c426d5da 100644
--- a/cpukit/libfs/src/imfs/memfile.c
+++ b/cpukit/libfs/src/imfs/memfile.c
@@ -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;