summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2012-05-04 13:30:53 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2012-05-04 13:30:53 +0200
commit6fe700c80a634315a0eb6780c03ff17d328a2e0a (patch)
tree6ba5474e6974b515771d70ba35bacead423be30f
parentMerge branch 'upstream' (diff)
parentnfsclient: Add rename operation (diff)
downloadrtems-6fe700c80a634315a0eb6780c03ff17d328a2e0a.tar.bz2
Merge branch 'upstream'
-rw-r--r--cpukit/libfs/src/nfsclient/src/nfs.c48
1 files changed, 46 insertions, 2 deletions
diff --git a/cpukit/libfs/src/nfsclient/src/nfs.c b/cpukit/libfs/src/nfsclient/src/nfs.c
index b3e24a95b6..15b6def0d2 100644
--- a/cpukit/libfs/src/nfsclient/src/nfs.c
+++ b/cpukit/libfs/src/nfsclient/src/nfs.c
@@ -1493,7 +1493,7 @@ static int nfs_link(
)
{
int rv = 0;
-NfsNode pNode;
+NfsNode pNode = parentloc->node_access;
nfsstat status;
NfsNode tNode = targetloc->node_access;
char *dupname;
@@ -2044,6 +2044,50 @@ static ssize_t nfs_readlink(
return (ssize_t) strlen(rr.strbuf.buf);
}
+static int nfs_rename(
+ const rtems_filesystem_location_info_t *oldparentloc,
+ const rtems_filesystem_location_info_t *oldloc,
+ const rtems_filesystem_location_info_t *newparentloc,
+ const char *name,
+ size_t namelen
+)
+{
+ int rv = 0;
+ char *dupname = nfs_dupname(name, namelen);
+
+ if (dupname != NULL) {
+ NfsNode oldParentNode = oldparentloc->node_access;
+ NfsNode oldNode = oldloc->node_access;
+ NfsNode newParentNode = newparentloc->node_access;
+ Nfs nfs = oldParentNode->nfs;
+ const nfs_fh *toDirSrc = &SERP_FILE(newParentNode);
+ nfs_fh *toDirDst = &SERP_ARGS(oldParentNode).renamearg.to.dir;
+ nfsstat status;
+
+ SERP_ARGS(oldParentNode).renamearg.name = oldNode->str;
+ SERP_ARGS(oldParentNode).renamearg.to.name = dupname;
+ memcpy(toDirDst, toDirSrc, sizeof(*toDirDst));
+
+ rv = nfscall(
+ nfs->server,
+ NFSPROC_RENAME,
+ (xdrproc_t) xdr_renameargs,
+ &SERP_FILE(oldParentNode),
+ (xdrproc_t) xdr_nfsstat,
+ &status
+ );
+ if (rv == 0 && (errno = status) != NFS_OK) {
+ rv = -1;
+ }
+
+ free(dupname);
+ } else {
+ rv = -1;
+ }
+
+ return rv;
+}
+
static void nfs_lock(rtems_filesystem_mount_table_entry_t *mt_entry)
{
}
@@ -2104,7 +2148,7 @@ const struct _rtems_filesystem_operations_table nfs_fs_ops = {
.utime_h = nfs_utime,
.symlink_h = nfs_symlink,
.readlink_h = nfs_readlink,
- .rename_h = rtems_filesystem_default_rename,
+ .rename_h = nfs_rename,
.statvfs_h = rtems_filesystem_default_statvfs
};