rename - change name of file or directory

size[4] Trename tag[2] fid[4] newdirfid[4] name[s]
size[4] Rrename tag[2]

Implement the 2000.L rename operation. A new function
v9fs_complete_rename is introduced that acts as a common entry point
for 2000.L rename operation and 2000.U rename opearation (via wstat).
As part of this change the field 'nname' (used only for rename) is
removed from the structure V9fsWstatState. Instead a new structure
V9fsRenameState is used for rename operations both by 2000.U and 2000.L
code paths. Both 2000.U and 2000.L rename code paths construct the
V9fsRenameState structure and passes that to v9fs_complete_rename
function.

Changes from previous version:
 Use qemu_mallocz to initialize
 Use strcpy,strcat functions instead of memcpy
 Changed the variable name to newdirfid
 Introduced post rename function
 Error checking
 Removed nname field from V9fsWstatState

Signed-off-by: M. Mohan Kumar <mohan@in.ibm.com>
Signed-off-by: Venkateswararao Jujjuri <jvrao@linux.vnet.ibm.com>
diff --git a/hw/virtio-9p.h b/hw/virtio-9p.h
index 91cc0ae..4d179b7 100644
--- a/hw/virtio-9p.h
+++ b/hw/virtio-9p.h
@@ -21,6 +21,8 @@
     P9_RSYMLINK,
     P9_TMKNOD = 18,
     P9_RMKNOD,
+    P9_TRENAME = 20,
+    P9_RRENAME,
     P9_TGETATTR = 24,
     P9_RGETATTR,
     P9_TSETATTR = 26,
@@ -310,7 +312,6 @@
     V9fsStat v9stat;
     V9fsFidState *fidp;
     struct stat stbuf;
-    V9fsString nname;
 } V9fsWstatState;
 
 typedef struct V9fsSymlinkState
@@ -385,6 +386,14 @@
     V9fsString fullname;
 } V9fsMkState;
 
+typedef struct V9fsRenameState {
+    V9fsPDU *pdu;
+    V9fsFidState *fidp;
+    size_t offset;
+    int32_t newdirfid;
+    V9fsString name;
+} V9fsRenameState;
+
 extern size_t pdu_packunpack(void *addr, struct iovec *sg, int sg_count,
                             size_t offset, size_t size, int pack);