summaryrefslogtreecommitdiffstats
path: root/cpukit/libfs
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
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')
-rw-r--r--cpukit/libfs/src/devfs/devfs.h1
-rw-r--r--cpukit/libfs/src/devfs/devfs_eval.c3
-rw-r--r--cpukit/libfs/src/devfs/devstat.c2
-rw-r--r--cpukit/libfs/src/dosfs/fat.c4
-rw-r--r--cpukit/libfs/src/dosfs/msdos.h14
-rw-r--r--cpukit/libfs/src/dosfs/msdos_create.c2
-rw-r--r--cpukit/libfs/src/dosfs/msdos_dir.c3
-rw-r--r--cpukit/libfs/src/dosfs/msdos_eval.c7
-rw-r--r--cpukit/libfs/src/dosfs/msdos_file.c3
-rw-r--r--cpukit/libfs/src/dosfs/msdos_format.c2
-rw-r--r--cpukit/libfs/src/dosfs/msdos_misc.c9
-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
-rw-r--r--cpukit/libfs/src/nfsclient/src/nfs.c28
-rw-r--r--cpukit/libfs/src/pipe/pipe.c2
28 files changed, 107 insertions, 62 deletions
diff --git a/cpukit/libfs/src/devfs/devfs.h b/cpukit/libfs/src/devfs/devfs.h
index b065489455..2a666204d3 100644
--- a/cpukit/libfs/src/devfs/devfs.h
+++ b/cpukit/libfs/src/devfs/devfs.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
);
diff --git a/cpukit/libfs/src/devfs/devfs_eval.c b/cpukit/libfs/src/devfs/devfs_eval.c
index 5d9423b007..dd69fd802d 100644
--- a/cpukit/libfs/src/devfs/devfs_eval.c
+++ b/cpukit/libfs/src/devfs/devfs_eval.c
@@ -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;
diff --git a/cpukit/libfs/src/devfs/devstat.c b/cpukit/libfs/src/devfs/devstat.c
index 6c6ee3e6b1..7bfdfec00c 100644
--- a/cpukit/libfs/src/devfs/devstat.c
+++ b/cpukit/libfs/src/devfs/devstat.c
@@ -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;
diff --git a/cpukit/libfs/src/dosfs/fat.c b/cpukit/libfs/src/dosfs/fat.c
index d5a3a7907d..0bf3d29d28 100644
--- a/cpukit/libfs/src/dosfs/fat.c
+++ b/cpukit/libfs/src/dosfs/fat.c
@@ -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 */
diff --git a/cpukit/libfs/src/dosfs/msdos.h b/cpukit/libfs/src/dosfs/msdos.h
index 374210d9b7..1ea54d90c3 100644
--- a/cpukit/libfs/src/dosfs/msdos.h
+++ b/cpukit/libfs/src/dosfs/msdos.h
@@ -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);
diff --git a/cpukit/libfs/src/dosfs/msdos_create.c b/cpukit/libfs/src/dosfs/msdos_create.c
index bbdf137600..f7bd97196c 100644
--- a/cpukit/libfs/src/dosfs/msdos_create.c
+++ b/cpukit/libfs/src/dosfs/msdos_create.c
@@ -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);
}
/*
diff --git a/cpukit/libfs/src/dosfs/msdos_dir.c b/cpukit/libfs/src/dosfs/msdos_dir.c
index b897a192e3..43ff65291b 100644
--- a/cpukit/libfs/src/dosfs/msdos_dir.c
+++ b/cpukit/libfs/src/dosfs/msdos_dir.c
@@ -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;
diff --git a/cpukit/libfs/src/dosfs/msdos_eval.c b/cpukit/libfs/src/dosfs/msdos_eval.c
index 5eabedb2a4..a97c245ed0 100644
--- a/cpukit/libfs/src/dosfs/msdos_eval.c
+++ b/cpukit/libfs/src/dosfs/msdos_eval.c
@@ -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;
diff --git a/cpukit/libfs/src/dosfs/msdos_file.c b/cpukit/libfs/src/dosfs/msdos_file.c
index 817897f845..8519412984 100644
--- a/cpukit/libfs/src/dosfs/msdos_file.c
+++ b/cpukit/libfs/src/dosfs/msdos_file.c
@@ -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;
diff --git a/cpukit/libfs/src/dosfs/msdos_format.c b/cpukit/libfs/src/dosfs/msdos_format.c
index 9319c87a87..af4a109892 100644
--- a/cpukit/libfs/src/dosfs/msdos_format.c
+++ b/cpukit/libfs/src/dosfs/msdos_format.c
@@ -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;
diff --git a/cpukit/libfs/src/dosfs/msdos_misc.c b/cpukit/libfs/src/dosfs/msdos_misc.c
index 17928077e4..ef4f6c0e56 100644
--- a/cpukit/libfs/src/dosfs/msdos_misc.c
+++ b/cpukit/libfs/src/dosfs/msdos_misc.c
@@ -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;
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;
diff --git a/cpukit/libfs/src/nfsclient/src/nfs.c b/cpukit/libfs/src/nfsclient/src/nfs.c
index daafac8c87..50c125ad28 100644
--- a/cpukit/libfs/src/nfsclient/src/nfs.c
+++ b/cpukit/libfs/src/nfsclient/src/nfs.c
@@ -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 */
diff --git a/cpukit/libfs/src/pipe/pipe.c b/cpukit/libfs/src/pipe/pipe.c
index 339aa42f4e..54628898ac 100644
--- a/cpukit/libfs/src/pipe/pipe.c
+++ b/cpukit/libfs/src/pipe/pipe.c
@@ -30,7 +30,7 @@ int pipe_create(
int err = 0;
/* Create /tmp if not exists */
- if (rtems_filesystem_evaluate_path("/tmp", RTEMS_LIBIO_PERMS_RWX, &loc, TRUE)
+ if (rtems_filesystem_evaluate_path("/tmp", 3, RTEMS_LIBIO_PERMS_RWX, &loc, TRUE)
!= 0) {
if (errno != ENOENT)
return -1;