summaryrefslogtreecommitdiffstats
path: root/cpukit/libfs/src/rfs/rtems-rfs-rtems.c
diff options
context:
space:
mode:
authorChris Johns <chrisj@rtems.org>2010-03-04 06:36:51 +0000
committerChris Johns <chrisj@rtems.org>2010-03-04 06:36:51 +0000
commit8ec7abb551a23bdf47509189145885a364810006 (patch)
tree7b5fa486b93583479b97f05a51c7370dd0c2d69f /cpukit/libfs/src/rfs/rtems-rfs-rtems.c
parentThis commit was generated by cvs2svn to compensate for changes in r22694, (diff)
downloadrtems-8ec7abb551a23bdf47509189145885a364810006.tar.bz2
010-03-04 Chris Johns <chrisj@rtems.org>
* libcsupport/include/rtems/libio.h, libcsupport/src/_rename_r.c: Add a rename file op and have rename use it. * libfs/Makefile.am, libfs/src/dosfs/msdos_rename.c, libfs/src/imfs/imfs_rename.c: New files to support the rename file op. * libfs/src/imfs/imfs.h: Add rename interface. * libfs/src/imfs/imfs_init.c: Add rename handler. * libfs/src/imfs/miniimfs_init.c: Fix up ops struct. * libfs/src/dosfs/msdos.h: Add msdos_rename and remove msdos_file_link. * libfs/src/dosfs/msdos_create.c: Remove the link call. * libfs/src/dosfs/msdos_eval.c: Fix a path parsing bug. * libfs/src/dosfs/msdos_init.c: Add rename handler and clean up the struct naming. * libfs/src/rfs/rtems-rfs-link.c, libfs/src/rfs/rtems-rfs-link.h: Change the link call to allow linking of directories if told to and change the unlink to handle unlink directories that are not empty so rename can be supported. * libfs/src/rfs/rtems-rfs-rtems-dir.c: Fix the link/unlink calls. * libfs/src/rfs/rtems-rfs-rtems.c: Add a rename handler. Fix the link/unlink calls. * libfs/src/dosfs/msdos_dir.c, libfs/src/dosfs/msdos_format.c, libfs/src/dosfs/msdos_misc.c, httpd/asp.c, libfs/src/nfsclient/src/nfs.c: Work around a newlib warning when using the is*() family of calls.
Diffstat (limited to 'cpukit/libfs/src/rfs/rtems-rfs-rtems.c')
-rw-r--r--cpukit/libfs/src/rfs/rtems-rfs-rtems.c73
1 files changed, 69 insertions, 4 deletions
diff --git a/cpukit/libfs/src/rfs/rtems-rfs-rtems.c b/cpukit/libfs/src/rfs/rtems-rfs-rtems.c
index 97e803a615..081f97646d 100644
--- a/cpukit/libfs/src/rfs/rtems-rfs-rtems.c
+++ b/cpukit/libfs/src/rfs/rtems-rfs-rtems.c
@@ -478,7 +478,7 @@ rtems_rfs_rtems_link (rtems_filesystem_location_info_t* to_loc,
rtems_rfs_rtems_lock (fs);
- rc = rtems_rfs_link (fs, name, strlen (name), parent, target);
+ rc = rtems_rfs_link (fs, name, strlen (name), parent, target, false);
if (rc)
{
rtems_rfs_rtems_unlock (fs);
@@ -514,7 +514,7 @@ rtems_rfs_rtems_unlink (rtems_filesystem_location_info_t* parent_loc,
printf("rtems-rfs-rtems: unlink: parent:%ld doff:%lu ino:%ld\n",
parent, doff, ino);
- rc = rtems_rfs_unlink (fs, parent, ino, doff, false);
+ rc = rtems_rfs_unlink (fs, parent, ino, doff, rtems_rfs_unlink_dir_denied);
if (rc)
{
rtems_rfs_rtems_unlock (fs);
@@ -1043,6 +1043,7 @@ rtems_rfs_rtems_mknod (const char *name,
*
* @param parent_pathloc
* @param pathloc
+ * @return int
*/
int
rtems_rfs_rtems_rmnod (rtems_filesystem_location_info_t* parent_pathloc,
@@ -1060,7 +1061,7 @@ rtems_rfs_rtems_rmnod (rtems_filesystem_location_info_t* parent_pathloc,
rtems_rfs_rtems_lock (fs);
- rc = rtems_rfs_unlink (fs, parent, ino, doff, false);
+ rc = rtems_rfs_unlink (fs, parent, ino, doff, rtems_rfs_unlink_dir_denied);
if (rc)
{
rtems_rfs_rtems_unlock (fs);
@@ -1076,6 +1077,7 @@ rtems_rfs_rtems_rmnod (rtems_filesystem_location_info_t* parent_pathloc,
* everything related to this device.
*
* @param iop
+ * @return int
*/
int
rtems_rfs_rtems_fdatasync (rtems_libio_t* iop)
@@ -1090,6 +1092,68 @@ rtems_rfs_rtems_fdatasync (rtems_libio_t* iop)
}
/**
+ * Rename the node.
+ *
+ * @param old_parent_loc The old name's parent location.
+ * @param old_loc The old name's location.
+ * @param new_parent_loc The new name's parent location.
+ * @param new_name The new name.
+ * @return int
+ */
+int
+rtems_rfs_rtems_rename(rtems_filesystem_location_info_t* old_parent_loc,
+ rtems_filesystem_location_info_t* old_loc,
+ rtems_filesystem_location_info_t* new_parent_loc,
+ const char* new_name)
+{
+ rtems_rfs_file_system* fs = rtems_rfs_rtems_pathloc_dev (old_loc);
+ rtems_rfs_ino old_parent;
+ rtems_rfs_ino new_parent;
+ rtems_rfs_ino ino;
+ uint32_t doff;
+ int rc;
+
+ old_parent = rtems_rfs_rtems_get_pathloc_ino (old_parent_loc);
+ new_parent = rtems_rfs_rtems_get_pathloc_ino (new_parent_loc);
+
+ ino = rtems_rfs_rtems_get_pathloc_ino (old_loc);
+ doff = rtems_rfs_rtems_get_pathloc_doff (old_loc);
+
+ if (rtems_rfs_rtems_trace (RTEMS_RFS_RTEMS_DEBUG_RENAME))
+ printf ("rtems-rfs: rename: ino:%ld doff:%lu, new parent:%ld new name:%s\n",
+ ino, doff, new_parent, new_name);
+
+ rtems_rfs_rtems_lock (fs);
+
+ /*
+ * Link to the inode before unlinking so the inode is not erased when
+ * unlinked.
+ */
+ rc = rtems_rfs_link (fs, new_name, strlen (new_name), new_parent, ino, true);
+ if (rc)
+ {
+ rtems_rfs_rtems_unlock (fs);
+ return rtems_rfs_rtems_error ("rename: linking", rc);
+ }
+
+ /*
+ * Unlink all inodes even directories with the dir option as false because a
+ * directory may not be empty.
+ */
+ rc = rtems_rfs_unlink (fs, old_parent, ino, doff,
+ rtems_rfs_unlink_dir_allowed);
+ if (rc)
+ {
+ rtems_rfs_rtems_unlock (fs);
+ return rtems_rfs_rtems_error ("rename: unlinking", rc);
+ }
+
+ rtems_rfs_rtems_unlock (fs);
+
+ return 0;
+}
+
+/**
* Return the file system stat data.
*
* @param pathloc
@@ -1150,7 +1214,7 @@ int rtems_rfs_rtems_initialise (rtems_filesystem_mount_table_entry_t *mt_entry);
int rtems_rfs_rtems_shutdown (rtems_filesystem_mount_table_entry_t *mt_entry);
/**
- * RFS file system operations table
+ * RFS file system operations table.
*/
const rtems_filesystem_operations_table rtems_rfs_ops =
{
@@ -1170,6 +1234,7 @@ const rtems_filesystem_operations_table rtems_rfs_ops =
.eval_link_h = NULL, /* never called cause we lie in the node type */
.symlink_h = rtems_rfs_rtems_symlink,
.readlink_h = rtems_rfs_rtems_readlink,
+ .rename_h = rtems_rfs_rtems_rename,
.statvfs_h = rtems_rfs_rtems_statvfs
};