summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpatacongo <patacongo@7fd9a85b-ad96-42d3-883c-3090e2eb8679>2012-06-11 23:47:31 +0000
committerpatacongo <patacongo@7fd9a85b-ad96-42d3-883c-3090e2eb8679>2012-06-11 23:47:31 +0000
commita725960de9b2bf607078dcd7b3b1669a206b29e0 (patch)
tree19e791f957e0cd01c5bf7608a23e07bc07a58ed7
parent0a17ce6899fb7a92978ae152f867a9ce592e5063 (diff)
Add NSH mv command
git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@4830 7fd9a85b-ad96-42d3-883c-3090e2eb8679
-rwxr-xr-xapps/ChangeLog.txt3
-rw-r--r--apps/nshlib/README.txt18
-rw-r--r--apps/nshlib/nsh.h3
-rw-r--r--apps/nshlib/nsh_fscmds.c44
-rw-r--r--apps/nshlib/nsh_parse.c6
-rw-r--r--nuttx/Documentation/NuttShell.html84
-rw-r--r--nuttx/fs/nfs/nfs_vfsops.c103
-rw-r--r--nuttx/fs/nfs/rpc_clnt.c11
8 files changed, 205 insertions, 67 deletions
diff --git a/apps/ChangeLog.txt b/apps/ChangeLog.txt
index 9f5d7f71e3..aa2bd8236e 100755
--- a/apps/ChangeLog.txt
+++ b/apps/ChangeLog.txt
@@ -237,5 +237,6 @@
* apps/nshlib/nsh_usbdev.c: User now has to press ENTER 3 times before
USB console will start. Otherwise, the USB console starts before there
is anyone at the other end to listen.
- * apps/nshilib/nsh_usbdev.c and nsh_consolemain.c: Add support for the USB
+ * apps/nshlib/nsh_usbdev.c and nsh_consolemain.c: Add support for the USB
capability when a USB console is used.
+ * apps/nshlib/nsh_fscmds.c: Add the 'mv' command
diff --git a/apps/nshlib/README.txt b/apps/nshlib/README.txt
index 4f2a272396..2ac9dfb199 100644
--- a/apps/nshlib/README.txt
+++ b/apps/nshlib/README.txt
@@ -602,6 +602,11 @@ o mount -t <fstype> <block-device> <dir-path>
This is a test
nsh>
+o mv <old-path> <new-path>
+
+ Rename the file object at <old-path> to <new-path>. Both paths must
+ reside in the same mounted filesystem.
+
o ps
Show the currently active threads and tasks. For example,
@@ -802,6 +807,7 @@ Command Dependencies on Configuration Settings
mkfifo CONFIG_NFILE_DESCRIPTORS > 0
mkrd !CONFIG_DISABLE_MOUNTPOINT && CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_FS_WRITABLE (see note 4)
mount !CONFIG_DISABLE_MOUNTPOINT && CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_FS_READABLE (see note 3)
+ mv !CONFIG_DISABLE_MOUNTPOINT && CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_FS_WRITABLE (see note 4)
ping CONFIG_NET && CONFIG_NET_ICMP && CONFIG_NET_ICMP_PING && !CONFIG_DISABLE_CLOCK && !CONFIG_DISABLE_SIGNALS
ps --
put CONFIG_NET && CONFIG_NET_UDP && CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_NET_BUFSIZE >= 558 (see note 1,2)
@@ -840,12 +846,12 @@ also allow it to squeeze into very small memory footprints.
CONFIG_NSH_DISABLE_LOSETUP, CONFIG_NSH_DISABLE_LS, CONFIG_NSH_DISABLE_MB,
CONFIG_NSH_DISABLE_MKDIR, CONFIG_NSH_DISABLE_MKFATFS, CONFIG_NSH_DISABLE_MKFIFO,
CONFIG_NSH_DISABLE_MKRD, CONFIG_NSH_DISABLE_MH, CONFIG_NSH_DISABLE_MOUNT,
- CONFIG_NSH_DISABLE_MW, CONFIG_NSH_DISABLE_PS, CONFIG_NSH_DISABLE_PING,
- CONFIG_NSH_DISABLE_PUT, CONFIG_NSH_DISABLE_PWD, CONFIG_NSH_DISABLE_RM,
- CONFIG_NSH_DISABLE_RMDIR, CONFIG_NSH_DISABLE_SET, CONFIG_NSH_DISABLE_SH,
- CONFIG_NSH_DISABLE_SLEEP, CONFIG_NSH_DISABLE_TEST, CONFIG_NSH_DISABLE_UMOUNT,
- CONFIG_NSH_DISABLE_UNSET, CONFIG_NSH_DISABLE_USLEEP, CONFIG_NSH_DISABLE_WGET,
- CONFIG_NSH_DISABLE_XD
+ CONFIG_NSH_DISABLE_MW, CONFIG_NSH_DISABLE_MV, CONFIG_NSH_DISABLE_PS,
+ CONFIG_NSH_DISABLE_PING, CONFIG_NSH_DISABLE_PUT, CONFIG_NSH_DISABLE_PWD,
+ CONFIG_NSH_DISABLE_RM, CONFIG_NSH_DISABLE_RMDIR, CONFIG_NSH_DISABLE_SET,
+ CONFIG_NSH_DISABLE_SH, CONFIG_NSH_DISABLE_SLEEP, CONFIG_NSH_DISABLE_TEST,
+ CONFIG_NSH_DISABLE_UMOUNT, CONFIG_NSH_DISABLE_UNSET, CONFIG_NSH_DISABLE_USLEEP,
+ CONFIG_NSH_DISABLE_WGET, CONFIG_NSH_DISABLE_XD
NSH-Specific Configuration Settings
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
diff --git a/apps/nshlib/nsh.h b/apps/nshlib/nsh.h
index e31fa20f1c..988106f224 100644
--- a/apps/nshlib/nsh.h
+++ b/apps/nshlib/nsh.h
@@ -521,6 +521,9 @@ void nsh_usbtrace(void);
# ifndef CONFIG_NSH_DISABLE_MKRD
int cmd_mkrd(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv);
# endif
+# ifndef CONFIG_NSH_DISABLE_MV
+ int cmd_mv(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv);
+# endif
# ifndef CONFIG_NSH_DISABLE_RM
int cmd_rm(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv);
# endif
diff --git a/apps/nshlib/nsh_fscmds.c b/apps/nshlib/nsh_fscmds.c
index c67ccf3b23..b3b4ae770d 100644
--- a/apps/nshlib/nsh_fscmds.c
+++ b/apps/nshlib/nsh_fscmds.c
@@ -1213,6 +1213,50 @@ int cmd_mount(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
#endif
/****************************************************************************
+ * Name: cmd_mv
+ ****************************************************************************/
+
+#if !defined(CONFIG_DISABLE_MOUNTPOINT) && CONFIG_NFILE_DESCRIPTORS > 0 && defined(CONFIG_FS_WRITABLE)
+#ifndef CONFIG_NSH_DISABLE_MV
+int cmd_mv(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
+{
+ char *oldpath;
+ char *newpath;
+ int ret;
+
+ /* Get the full path to the old and new file paths */
+
+ oldpath = nsh_getfullpath(vtbl, argv[1]);
+ if (!oldpath)
+ {
+ return ERROR;
+ }
+
+ newpath = nsh_getfullpath(vtbl, argv[2]);
+ if (!newpath)
+ {
+ nsh_freefullpath(newpath);
+ return ERROR;
+ }
+
+ /* Perform the mount */
+
+ ret = rename(oldpath, newpath);
+ if (ret < 0)
+ {
+ nsh_output(vtbl, g_fmtcmdfailed, argv[0], "rename", NSH_ERRNO);
+ }
+
+ /* Free the file paths */
+
+ nsh_freefullpath(oldpath);
+ nsh_freefullpath(newpath);
+ return ret;
+}
+#endif
+#endif
+
+/****************************************************************************
* Name: cmd_nfsmount
****************************************************************************/
diff --git a/apps/nshlib/nsh_parse.c b/apps/nshlib/nsh_parse.c
index e497dc67fa..f95444f0b6 100644
--- a/apps/nshlib/nsh_parse.c
+++ b/apps/nshlib/nsh_parse.c
@@ -263,6 +263,12 @@ static const struct cmdmap_s g_cmdmap[] =
# endif
#endif
+#if !defined(CONFIG_DISABLE_MOUNTPOINT) && CONFIG_NFILE_DESCRIPTORS > 0 && defined(CONFIG_FS_WRITABLE)
+# ifndef CONFIG_NSH_DISABLE_MV
+ { "mv", cmd_mv, 3, 3, "<old-path> <new-path>" },
+# endif
+#endif
+
#ifndef CONFIG_NSH_DISABLE_MW
{ "mw", cmd_mw, 2, 3, "<hex-address>[=<hex-value>][ <hex-byte-count>]" },
#endif
diff --git a/nuttx/Documentation/NuttShell.html b/nuttx/Documentation/NuttShell.html
index 1a2a1da062..72629580f8 100644
--- a/nuttx/Documentation/NuttShell.html
+++ b/nuttx/Documentation/NuttShell.html
@@ -8,7 +8,7 @@
<tr align="center" bgcolor="#e4e4e4">
<td>
<h1><big><font color="#3c34ec"><i>NuttShell (NSH)</i></font></big></h1>
- <p>Last Updated: May 25, 2012</p>
+ <p>Last Updated: June 11, 2012</p>
</td>
</tr>
</table>
@@ -221,79 +221,85 @@
<tr>
<td><br></td>
<td>
- <a href="#cmdping">2.24 Check Network Peer (ping)</a>
+ <a href="#cmdmv">2.24 Rename a File (mv)</a>
</td>
</tr>
<tr>
<td><br></td>
<td>
- <a href="#cmdput">2.25 Send File Via TFTP (put)</a>
+ <a href="#cmdping">2.25 Check Network Peer (ping)</a>
</td>
</tr>
<tr>
<td><br></td>
<td>
- <a href="#cmdpwd">2.26 Show Current Working Directory (pwd)</a>
+ <a href="#cmdput">2.26 Send File Via TFTP (put)</a>
</td>
</tr>
<tr>
<td><br></td>
<td>
- <a href="#cmdrm">2.27 Remove a File (rm)</a>
+ <a href="#cmdpwd">2.27 Show Current Working Directory (pwd)</a>
</td>
</tr>
<tr>
<td><br></td>
<td>
- <a href="#cmdrmdir">2.28 Remove a Directory (rmdir)</a>
+ <a href="#cmdrm">2.28 Remove a File (rm)</a>
</td>
</tr>
<tr>
<td><br></td>
<td>
- <a href="#cmdset">2.29 Set an Environment Variable (set)</a>
+ <a href="#cmdrmdir">2.29 Remove a Directory (rmdir)</a>
</td>
</tr>
<tr>
<td><br></td>
<td>
- <a href="#cmdsh">2.30 Execute an NSH Script (sh)</a>
+ <a href="#cmdset">2.30 Set an Environment Variable (set)</a>
</td>
</tr>
<tr>
<td><br></td>
<td>
- <a href="#cmdsleep">2.31 Wait for Seconds (sleep)</a>
+ <a href="#cmdsh">2.31 Execute an NSH Script (sh)</a>
</td>
</tr>
<tr>
<td><br></td>
<td>
- <a href="#cmdunmount">2.32 Unmount a File System (umount)</a>
+ <a href="#cmdsleep">2.32 Wait for Seconds (sleep)</a>
</td>
</tr>
<tr>
<td><br></td>
<td>
- <a href="#cmdunset">2.33 Unset an Environment Variable (unset)</a>
+ <a href="#cmdunmount">2.33 Unmount a File System (umount)</a>
</td>
</tr>
<tr>
<td><br></td>
<td>
- <a href="#cmdusleep">2.34 Wait for Microseconds (usleep)</a>
+ <a href="#cmdunset">2.34 Unset an Environment Variable (unset)</a>
</td>
</tr>
<tr>
<td><br></td>
<td>
- <a href="#cmdwget">2.35 Get File Via HTTP (wget)</a>
+ <a href="#cmdusleep">2.35 Wait for Microseconds (usleep)</a>
</td>
</tr>
<tr>
<td><br></td>
<td>
- <a href="#cmdxd">2.36 Hexadecimal Dump (xd)</a>
+ <a href="#cmdwget">2.36 Get File Via HTTP (wget)</a>
+ </td>
+</tr>
+<tr>
+ <td><br></td>
+ <td>
+ <a href="#cmdxd">2.37 Hexadecimal Dump (xd)</a>
</td>
</tr>
<tr>
@@ -1483,7 +1489,25 @@ nsh>
<table width ="100%">
<tr bgcolor="#e4e4e4">
<td>
- <a name="cmdping"><h2>2.24 Check Network Peer (ping)</h2></a>
+ <a name="cmdmv"><h2>2.24 Rename a File (mv)</h2></a>
+ </td>
+ </tr>
+</table>
+
+<p><b>Command Syntax:</b></p>
+<ul><pre>
+mv &lt;old-path&gt; &lt;new-path&gt;
+</pre></ul>
+<p>
+ <b>Synopsis</b>.
+ Rename the file object at <code>&lt;old-path&gt;</code> to <code>&lt;new-path&gt;</code>.
+ Both paths must reside in the same mounted filesystem.
+</p>
+
+<table width ="100%">
+ <tr bgcolor="#e4e4e4">
+ <td>
+ <a name="cmdping"><h2>2.25 Check Network Peer (ping)</h2></a>
</td>
</tr>
</table>
@@ -1516,7 +1540,7 @@ nsh&gt;
<table width ="100%">
<tr bgcolor="#e4e4e4">
<td>
- <a name="cmdput"><h2>2.25 Send File Via TFTP (put)</h2></a>
+ <a name="cmdput"><h2>2.26 Send File Via TFTP (put)</h2></a>
</td>
</tr>
</table>
@@ -1551,7 +1575,7 @@ put [-b|-n] [-f &lt;remote-path&gt;] -h &lt;ip-address&gt; &lt;local-path&gt;
<table width ="100%">
<tr bgcolor="#e4e4e4">
<td>
- <a name="cmdpwd"><h2>2.26 Show Current Working Directory (pwd)</h2></a>
+ <a name="cmdpwd"><h2>2.27 Show Current Working Directory (pwd)</h2></a>
</td>
</tr>
</table>
@@ -1581,7 +1605,7 @@ nsh&gt;
<table width ="100%">
<tr bgcolor="#e4e4e4">
<td>
- <a name="cmdrm"><h2>2.27 Remove a File (rm)</h2></a>
+ <a name="cmdrm"><h2>2.28 Remove a File (rm)</h2></a>
</td>
</tr>
</table>
@@ -1615,7 +1639,7 @@ nsh>
<table width ="100%">
<tr bgcolor="#e4e4e4">
<td>
- <a name="cmdrmdir"><h2>2.28 Remove a Directory (rmdir)</h2></a>
+ <a name="cmdrmdir"><h2>2.29 Remove a Directory (rmdir)</h2></a>
</td>
</tr>
</table>
@@ -1650,7 +1674,7 @@ nsh>
<table width ="100%">
<tr bgcolor="#e4e4e4">
<td>
- <a name="cmdset"><h2>2.29 Set an Environment Variable (set)</h2></a>
+ <a name="cmdset"><h2>2.30 Set an Environment Variable (set)</h2></a>
</td>
</tr>
</table>
@@ -1676,7 +1700,7 @@ nsh&gt;
<table width ="100%">
<tr bgcolor="#e4e4e4">
<td>
- <a name="cmdsh"><h2>2.30 Execute an NSH Script (sh)</h2></a>
+ <a name="cmdsh"><h2>2.31 Execute an NSH Script (sh)</h2></a>
</td>
</tr>
</table>
@@ -1694,7 +1718,7 @@ sh &lt;script-path&gt;
<table width ="100%">
<tr bgcolor="#e4e4e4">
<td>
- <a name="cmdsleep"><h2>2.31 Wait for Seconds (sleep)</h2></a>
+ <a name="cmdsleep"><h2>2.32 Wait for Seconds (sleep)</h2></a>
</td>
</tr>
</table>
@@ -1711,7 +1735,7 @@ sleep &lt;sec&gt;
<table width ="100%">
<tr bgcolor="#e4e4e4">
<td>
- <a name="cmdunmount"><h2>2.32 Unmount a File System (umount)</h2></a>
+ <a name="cmdunmount"><h2>2.33 Unmount a File System (umount)</h2></a>
</td>
</tr>
</table>
@@ -1741,7 +1765,7 @@ nsh>
<table width ="100%">
<tr bgcolor="#e4e4e4">
<td>
- <a name="cmdunset"><h2>2.33 Unset an Environment Variable (unset)</h2></a>
+ <a name="cmdunset"><h2>2.34 Unset an Environment Variable (unset)</h2></a>
</td>
</tr>
</table>
@@ -1767,7 +1791,7 @@ nsh&gt;
<table width ="100%">
<tr bgcolor="#e4e4e4">
<td>
- <a name="cmdusleep"><h2>2.34 Wait for Microseconds (usleep)</h2></a>
+ <a name="cmdusleep"><h2>2.35 Wait for Microseconds (usleep)</h2></a>
</td>
</tr>
</table>
@@ -1784,7 +1808,7 @@ usleep &lt;usec&gt;
<table width ="100%">
<tr bgcolor="#e4e4e4">
<td>
- <a name="cmdwget">2.35 Get File Via HTTP (wget)</a>
+ <a name="cmdwget">2.36 Get File Via HTTP (wget)</a>
</td>
</tr>
</table>
@@ -1811,7 +1835,7 @@ wget [-o &lt;local-path&gt;] &lt;url&gt;
<table width ="100%">
<tr bgcolor="#e4e4e4">
<td>
- <a name="cmdxd"><h2>2.36 Hexadecimal dump (xd)</h2></a>
+ <a name="cmdxd"><h2>2.37 Hexadecimal dump (xd)</h2></a>
</td>
</tr>
</table>
@@ -1990,6 +2014,11 @@ nsh>
<td><code>CONFIG_NSH_DISABLE_MOUNT</code></td>
</tr>
<tr>
+ <td><b><code>mv</code></b></td>
+ <td>!<code>CONFIG_DISABLE_MOUNTPOINT</code> &amp;&amp; <code>CONFIG_NFILE_DESCRIPTORS</code> &gt; 0 &amp;&amp; <code>CONFIG_FS_WRITABLE</code><sup>3</sup></td>
+ <td><code>CONFIG_NSH_DISABLE_MV</code></td>
+ </tr>
+ <tr>
<td><b><code>ping</code></b></td>
<td><code>CONFIG_NET</code> &amp;&amp; <code>CONFIG_NET_ICMP</code> &amp;&amp;
<code>CONFIG_NET_ICMP_PING</code> &amp;&amp; !<code>CONFIG_DISABLE_CLOCK</code> &amp;&amp;
@@ -2590,6 +2619,7 @@ nsh>
<li><a href="#cmdmkfifo"><code>mkfifo</code></a></li>
<li><a href="#cmdmkrd"><code>mkrd</code></a></li>
<li><a href="#cmdmount"><code>mount</code></a></li>
+ <li><a href="#cmdmv"><code>mv</code></a></li>
<li><a href="#cmdoverview"><code>nice</code></a></li>
<li><a href="#environvars"><code>OLDPWD</code></a></li>
<li><a href="#overview">Overview</a></li>
diff --git a/nuttx/fs/nfs/nfs_vfsops.c b/nuttx/fs/nfs/nfs_vfsops.c
index ea40e02eea..6d78a2cec0 100644
--- a/nuttx/fs/nfs/nfs_vfsops.c
+++ b/nuttx/fs/nfs/nfs_vfsops.c
@@ -2239,11 +2239,18 @@ errout_with_semaphore:
static int nfs_rename(struct inode *mountpt, const char *oldrelpath,
const char *newrelpath)
{
- struct nfsmount *nmp;
- struct nfsnode *np;
- struct RENAME3args rename;
+ struct nfsmount *nmp;
+ struct file_handle from_handle;
+ struct file_handle to_handle;
+ char from_name[NAME_MAX+1];
+ char to_name[NAME_MAX+1];
+ struct nfs_fattr fattr;
+ struct RENAME3args request;
struct rpc_reply_rename resok;
- int error = 0;
+ FAR uint32_t *ptr;
+ int namelen;
+ int reqlen;
+ int error;
/* Sanity checks */
@@ -2252,7 +2259,6 @@ static int nfs_rename(struct inode *mountpt, const char *oldrelpath,
/* Get the mountpoint private data from the inode structure */
nmp = (struct nfsmount *)mountpt->i_private;
- np = nmp->nm_head;
/* Check if the mount is still healthy */
@@ -2260,30 +2266,77 @@ static int nfs_rename(struct inode *mountpt, const char *oldrelpath,
error = nfs_checkmount(nmp);
if (error != OK)
{
+ fdbg("ERROR: nfs_checkmount returned: %d\n", error);
goto errout_with_semaphore;
}
- if (np->n_type != NFREG && np->n_type != NFDIR)
+ /* Find the NFS node of the directory containing the 'from' object */
+
+ error = nfs_finddir(nmp, oldrelpath, &from_handle, &fattr, from_name);
+ if (error != OK)
{
- fdbg("open eacces typ=%d\n", np->n_type);
- error = EACCES;
- goto errout_with_semaphore;
+ fdbg("ERROR: nfs_finddir returned: %d\n", error);
+ return error;
}
- nfsstats.rpccnt[NFSPROC_RENAME]++;
- memset(&rename, 0, sizeof(struct RENAME3args));
- memset(&resok, 0, sizeof(struct rpc_reply_rename));
- rename.from.fhandle.length = txdr_unsigned(np->n_fhsize);
- memcpy(&rename.from.fhandle.handle, &np->n_fhandle, sizeof(nfsfh_t));
- rename.from.length = txdr_unsigned(64);
- strncpy((FAR char *)rename.from.name, oldrelpath, 64);
- rename.to.fhandle.length = txdr_unsigned(np->n_fhsize);
- memcpy(&rename.to.fhandle.handle, &np->n_fhandle, sizeof(nfsfh_t));
- rename.to.length = txdr_unsigned(64);
- strncpy((FAR char *)rename.to.name, newrelpath, 64);
+ /* Find the NFS node of the directory containing the 'from' object */
+
+ error = nfs_finddir(nmp, newrelpath, &to_handle, &fattr, to_name);
+ if (error != OK)
+ {
+ fdbg("ERROR: nfs_finddir returned: %d\n", error);
+ return error;
+ }
+
+ /* Format the RENAME RPC arguements */
+
+ ptr = (FAR uint32_t *)&request;
+ reqlen = 0;
+
+ /* Copy the variable length, 'from' directory file handle */
+
+ *ptr++ = txdr_unsigned(from_handle.length);
+ reqlen += sizeof(uint32_t);
+
+ memcpy(ptr, &from_handle.handle, from_handle.length);
+ reqlen += (int)from_handle.length;
+ ptr += uint32_increment(from_handle.length);
+ /* Copy the variable-length 'from' object name */
+
+ namelen = strlen(from_name);
+
+ *ptr++ = txdr_unsigned(namelen);
+ reqlen += sizeof(uint32_t);
+
+ memcpy(ptr, from_name, namelen);
+ reqlen += uint32_alignup(namelen);
+ ptr += uint32_increment(namelen);
+
+ /* Copy the variable length, 'to' directory file handle */
+
+ *ptr++ = txdr_unsigned(to_handle.length);
+ reqlen += sizeof(uint32_t);
+
+ memcpy(ptr, &to_handle.handle, to_handle.length);
+ ptr += uint32_increment(to_handle.length);
+ reqlen += (int)to_handle.length;
+
+ /* Copy the variable-length 'to' object name */
+
+ namelen = strlen(to_name);
+
+ *ptr++ = txdr_unsigned(namelen);
+ reqlen += sizeof(uint32_t);
+
+ memcpy(ptr, to_name, namelen);
+ reqlen += uint32_alignup(namelen);
+
+ /* Perform the RENAME RPC */
+
+ nfsstats.rpccnt[NFSPROC_RENAME]++;
error = nfs_request(nmp, NFSPROC_RENAME,
- (FAR const void *)&rename, sizeof(struct RENAME3args),
+ (FAR const void *)&request, reqlen,
(FAR void *)&resok, sizeof(struct rpc_reply_rename));
/* Check if the rename was successful */
@@ -2300,14 +2353,6 @@ static int nfs_rename(struct inode *mountpt, const char *oldrelpath,
}
#endif
- if (error)
- {
- goto errout_with_semaphore;
- }
-
- memcpy(&np->n_fattr, &resok.rename.todir_wcc.after, sizeof(struct nfs_fattr));
- np->n_flags |= NFSNODE_MODIFIED;
-
errout_with_semaphore:
nfs_semgive(nmp);
return -error;
diff --git a/nuttx/fs/nfs/rpc_clnt.c b/nuttx/fs/nfs/rpc_clnt.c
index ff7fcfdfc3..34d5ccc133 100644
--- a/nuttx/fs/nfs/rpc_clnt.c
+++ b/nuttx/fs/nfs/rpc_clnt.c
@@ -1291,15 +1291,18 @@ static int rpcclnt_buildheader(struct rpcclnt *rpc, int procid, int prog, int ve
case NFSPROC_RENAME:
{
- /* Copy the variable, caller-provided data into the call message structure */
+ /* Copy the variable length, caller-provided data into the call
+ * message structure.
+ */
struct rpc_call_rename *callmsg = (struct rpc_call_rename *)msgbuf;
memcpy(&callmsg->rename, request, *reqlen);
- /* Return the full size of the message (including messages headers) */
+ /* Return the full size of the message (the size of variable data
+ * plus the size of the messages header).
+ */
- DEBUGASSERT(*reqlen == sizeof(struct RENAME3args));
- *reqlen = sizeof(struct rpc_call_rename);
+ *reqlen += sizeof(struct rpc_call_header);
/* Format the message header */