Patchwork virtio-9p: Rearrange fileop structures

login
register
mail settings
Submitter jvrao
Date June 1, 2010, 8:30 p.m.
Message ID <1275424251-13951-1-git-send-email-jvrao@linux.vnet.ibm.com>
Download mbox | patch
Permalink /patch/54304/
State New
Headers show

Comments

jvrao - June 1, 2010, 8:30 p.m.
This patch rearranges the fileop structures by moving the structure definitions
from virtio-9p.c to virtio-9p.h file. No functional changes.

Signed-off-by: Venkateswararao Jujjuri <jvrao@linux.vnet.ibm.com>
---
 hw/virtio-9p.c |  185 ++++++++++++++------------------------------------------
 hw/virtio-9p.h |   92 ++++++++++++++++++++++++++++
 2 files changed, 138 insertions(+), 139 deletions(-)
Anthony Liguori - June 23, 2010, 1:46 a.m.
On 06/01/2010 03:30 PM, Venkateswararao Jujjuri (JV) wrote:
> This patch rearranges the fileop structures by moving the structure definitions
> from virtio-9p.c to virtio-9p.h file. No functional changes.
>
> Signed-off-by: Venkateswararao Jujjuri<jvrao@linux.vnet.ibm.com>
> ---
>    

Applied.  Thanks.

Regards,

Anthony Liguori

>   hw/virtio-9p.c |  185 ++++++++++++++------------------------------------------
>   hw/virtio-9p.h |   92 ++++++++++++++++++++++++++++
>   2 files changed, 138 insertions(+), 139 deletions(-)
>
> diff --git a/hw/virtio-9p.c b/hw/virtio-9p.c
> index e5d0112..038bb39 100644
> --- a/hw/virtio-9p.c
> +++ b/hw/virtio-9p.c
> @@ -21,6 +21,52 @@
>   int dotu = 1;
>   int debug_9p_pdu;
>
> +enum {
> +    Oread   = 0x00,
> +    Owrite  = 0x01,
> +    Ordwr   = 0x02,
> +    Oexec   = 0x03,
> +    Oexcl   = 0x04,
> +    Otrunc  = 0x10,
> +    Orexec  = 0x20,
> +    Orclose = 0x40,
> +    Oappend = 0x80,
> +};
> +
> +static int omode_to_uflags(int8_t mode)
> +{
> +    int ret = 0;
> +
> +    switch (mode&  3) {
> +    case Oread:
> +        ret = O_RDONLY;
> +        break;
> +    case Ordwr:
> +        ret = O_RDWR;
> +        break;
> +    case Owrite:
> +        ret = O_WRONLY;
> +        break;
> +    case Oexec:
> +        ret = O_RDONLY;
> +        break;
> +    }
> +
> +    if (mode&  Otrunc) {
> +        ret |= O_TRUNC;
> +    }
> +
> +    if (mode&  Oappend) {
> +        ret |= O_APPEND;
> +    }
> +
> +    if (mode&  Oexcl) {
> +        ret |= O_EXCL;
> +    }
> +
> +    return ret;
> +}
> +
>   static int v9fs_do_lstat(V9fsState *s, V9fsString *path, struct stat *stbuf)
>   {
>       return s->ops->lstat(&s->ctx, path->data, stbuf);
> @@ -995,14 +1041,6 @@ out:
>       v9fs_string_free(&aname);
>   }
>
> -typedef struct V9fsStatState {
> -    V9fsPDU *pdu;
> -    size_t offset;
> -    V9fsStat v9stat;
> -    V9fsFidState *fidp;
> -    struct stat stbuf;
> -} V9fsStatState;
> -
>   static void v9fs_stat_post_lstat(V9fsState *s, V9fsStatState *vs, int err)
>   {
>       if (err == -1) {
> @@ -1053,19 +1091,6 @@ out:
>       qemu_free(vs);
>   }
>
> -typedef struct V9fsWalkState {
> -    V9fsPDU *pdu;
> -    size_t offset;
> -    int16_t nwnames;
> -    int name_idx;
> -    V9fsQID *qids;
> -    V9fsFidState *fidp;
> -    V9fsFidState *newfidp;
> -    V9fsString path;
> -    V9fsString *wnames;
> -    struct stat stbuf;
> -} V9fsWalkState;
> -
>   static void v9fs_walk_complete(V9fsState *s, V9fsWalkState *vs, int err)
>   {
>       complete_pdu(s, vs->pdu, err);
> @@ -1229,62 +1254,6 @@ out:
>       v9fs_walk_complete(s, vs, err);
>   }
>
> -typedef struct V9fsOpenState {
> -    V9fsPDU *pdu;
> -    size_t offset;
> -    int8_t mode;
> -    V9fsFidState *fidp;
> -    V9fsQID qid;
> -    struct stat stbuf;
> -
> -} V9fsOpenState;
> -
> -enum {
> -    Oread   = 0x00,
> -    Owrite  = 0x01,
> -    Ordwr   = 0x02,
> -    Oexec   = 0x03,
> -    Oexcl   = 0x04,
> -    Otrunc  = 0x10,
> -    Orexec  = 0x20,
> -    Orclose = 0x40,
> -    Oappend = 0x80,
> -};
> -
> -static int omode_to_uflags(int8_t mode)
> -{
> -    int ret = 0;
> -
> -    switch (mode&  3) {
> -    case Oread:
> -        ret = O_RDONLY;
> -        break;
> -    case Ordwr:
> -        ret = O_RDWR;
> -        break;
> -    case Owrite:
> -        ret = O_WRONLY;
> -        break;
> -    case Oexec:
> -        ret = O_RDONLY;
> -        break;
> -    }
> -
> -    if (mode&  Otrunc) {
> -        ret |= O_TRUNC;
> -    }
> -
> -    if (mode&  Oappend) {
> -        ret |= O_APPEND;
> -    }
> -
> -    if (mode&  Oexcl) {
> -        ret |= O_EXCL;
> -    }
> -
> -    return ret;
> -}
> -
>   static void v9fs_open_post_opendir(V9fsState *s, V9fsOpenState *vs, int err)
>   {
>       if (vs->fidp->dir == NULL) {
> @@ -1387,25 +1356,6 @@ out:
>       complete_pdu(s, pdu, err);
>   }
>
> -typedef struct V9fsReadState {
> -    V9fsPDU *pdu;
> -    size_t offset;
> -    int32_t count;
> -    int32_t total;
> -    int64_t off;
> -    V9fsFidState *fidp;
> -    struct iovec iov[128]; /* FIXME: bad, bad, bad */
> -    struct iovec *sg;
> -    off_t dir_pos;
> -    struct dirent *dent;
> -    struct stat stbuf;
> -    V9fsString name;
> -    V9fsStat v9stat;
> -    int32_t len;
> -    int32_t cnt;
> -    int32_t max_count;
> -} V9fsReadState;
> -
>   static void v9fs_read_post_readdir(V9fsState *, V9fsReadState *, ssize_t);
>
>   static void v9fs_read_post_seekdir(V9fsState *s, V9fsReadState *vs, ssize_t err)
> @@ -1593,19 +1543,6 @@ out:
>       qemu_free(vs);
>   }
>
> -typedef struct V9fsWriteState {
> -    V9fsPDU *pdu;
> -    size_t offset;
> -    int32_t len;
> -    int32_t count;
> -    int32_t total;
> -    int64_t off;
> -    V9fsFidState *fidp;
> -    struct iovec iov[128]; /* FIXME: bad, bad, bad */
> -    struct iovec *sg;
> -    int cnt;
> -} V9fsWriteState;
> -
>   static void v9fs_write_post_writev(V9fsState *s, V9fsWriteState *vs,
>                                      ssize_t err)
>   {
> @@ -1702,19 +1639,6 @@ out:
>       qemu_free(vs);
>   }
>
> -typedef struct V9fsCreateState {
> -    V9fsPDU *pdu;
> -    size_t offset;
> -    V9fsFidState *fidp;
> -    V9fsQID qid;
> -    int32_t perm;
> -    int8_t mode;
> -    struct stat stbuf;
> -    V9fsString name;
> -    V9fsString extension;
> -    V9fsString fullname;
> -} V9fsCreateState;
> -
>   static void v9fs_post_create(V9fsState *s, V9fsCreateState *vs, int err)
>   {
>       if (err == 0) {
> @@ -1934,12 +1858,6 @@ static void v9fs_flush(V9fsState *s, V9fsPDU *pdu)
>       complete_pdu(s, pdu, 7);
>   }
>
> -typedef struct V9fsRemoveState {
> -    V9fsPDU *pdu;
> -    size_t offset;
> -    V9fsFidState *fidp;
> -} V9fsRemoveState;
> -
>   static void v9fs_remove_post_remove(V9fsState *s, V9fsRemoveState *vs,
>                                                                   int err)
>   {
> @@ -1982,17 +1900,6 @@ out:
>       qemu_free(vs);
>   }
>
> -typedef struct V9fsWstatState
> -{
> -    V9fsPDU *pdu;
> -    size_t offset;
> -    int16_t unused;
> -    V9fsStat v9stat;
> -    V9fsFidState *fidp;
> -    struct stat stbuf;
> -    V9fsString nname;
> -} V9fsWstatState;
> -
>   static void v9fs_wstat_post_truncate(V9fsState *s, V9fsWstatState *vs, int err)
>   {
>       if (err<  0) {
> diff --git a/hw/virtio-9p.h b/hw/virtio-9p.h
> index b95dbe4..67f8087 100644
> --- a/hw/virtio-9p.h
> +++ b/hw/virtio-9p.h
> @@ -146,6 +146,98 @@ typedef struct V9fsState
>       size_t config_size;
>   } V9fsState;
>
> +typedef struct V9fsCreateState {
> +    V9fsPDU *pdu;
> +    size_t offset;
> +    V9fsFidState *fidp;
> +    V9fsQID qid;
> +    int32_t perm;
> +    int8_t mode;
> +    struct stat stbuf;
> +    V9fsString name;
> +    V9fsString extension;
> +    V9fsString fullname;
> +} V9fsCreateState;
> +
> +typedef struct V9fsStatState {
> +    V9fsPDU *pdu;
> +    size_t offset;
> +    V9fsStat v9stat;
> +    V9fsFidState *fidp;
> +    struct stat stbuf;
> +} V9fsStatState;
> +
> +typedef struct V9fsWalkState {
> +    V9fsPDU *pdu;
> +    size_t offset;
> +    int16_t nwnames;
> +    int name_idx;
> +    V9fsQID *qids;
> +    V9fsFidState *fidp;
> +    V9fsFidState *newfidp;
> +    V9fsString path;
> +    V9fsString *wnames;
> +    struct stat stbuf;
> +} V9fsWalkState;
> +
> +typedef struct V9fsOpenState {
> +    V9fsPDU *pdu;
> +    size_t offset;
> +    int8_t mode;
> +    V9fsFidState *fidp;
> +    V9fsQID qid;
> +    struct stat stbuf;
> +} V9fsOpenState;
> +
> +typedef struct V9fsReadState {
> +    V9fsPDU *pdu;
> +    size_t offset;
> +    int32_t count;
> +    int32_t total;
> +    int64_t off;
> +    V9fsFidState *fidp;
> +    struct iovec iov[128]; /* FIXME: bad, bad, bad */
> +    struct iovec *sg;
> +    off_t dir_pos;
> +    struct dirent *dent;
> +    struct stat stbuf;
> +    V9fsString name;
> +    V9fsStat v9stat;
> +    int32_t len;
> +    int32_t cnt;
> +    int32_t max_count;
> +} V9fsReadState;
> +
> +typedef struct V9fsWriteState {
> +    V9fsPDU *pdu;
> +    size_t offset;
> +    int32_t len;
> +    int32_t count;
> +    int32_t total;
> +    int64_t off;
> +    V9fsFidState *fidp;
> +    struct iovec iov[128]; /* FIXME: bad, bad, bad */
> +    struct iovec *sg;
> +    int cnt;
> +} V9fsWriteState;
> +
> +typedef struct V9fsRemoveState {
> +    V9fsPDU *pdu;
> +    size_t offset;
> +    V9fsFidState *fidp;
> +} V9fsRemoveState;
> +
> +typedef struct V9fsWstatState
> +{
> +    V9fsPDU *pdu;
> +    size_t offset;
> +    int16_t unused;
> +    V9fsStat v9stat;
> +    V9fsFidState *fidp;
> +    struct stat stbuf;
> +    V9fsString nname;
> +} V9fsWstatState;
> +
>   struct virtio_9p_config
>   {
>       /* number of characters in tag */
>

Patch

diff --git a/hw/virtio-9p.c b/hw/virtio-9p.c
index e5d0112..038bb39 100644
--- a/hw/virtio-9p.c
+++ b/hw/virtio-9p.c
@@ -21,6 +21,52 @@ 
 int dotu = 1;
 int debug_9p_pdu;
 
+enum {
+    Oread   = 0x00,
+    Owrite  = 0x01,
+    Ordwr   = 0x02,
+    Oexec   = 0x03,
+    Oexcl   = 0x04,
+    Otrunc  = 0x10,
+    Orexec  = 0x20,
+    Orclose = 0x40,
+    Oappend = 0x80,
+};
+
+static int omode_to_uflags(int8_t mode)
+{
+    int ret = 0;
+
+    switch (mode & 3) {
+    case Oread:
+        ret = O_RDONLY;
+        break;
+    case Ordwr:
+        ret = O_RDWR;
+        break;
+    case Owrite:
+        ret = O_WRONLY;
+        break;
+    case Oexec:
+        ret = O_RDONLY;
+        break;
+    }
+
+    if (mode & Otrunc) {
+        ret |= O_TRUNC;
+    }
+
+    if (mode & Oappend) {
+        ret |= O_APPEND;
+    }
+
+    if (mode & Oexcl) {
+        ret |= O_EXCL;
+    }
+
+    return ret;
+}
+
 static int v9fs_do_lstat(V9fsState *s, V9fsString *path, struct stat *stbuf)
 {
     return s->ops->lstat(&s->ctx, path->data, stbuf);
@@ -995,14 +1041,6 @@  out:
     v9fs_string_free(&aname);
 }
 
-typedef struct V9fsStatState {
-    V9fsPDU *pdu;
-    size_t offset;
-    V9fsStat v9stat;
-    V9fsFidState *fidp;
-    struct stat stbuf;
-} V9fsStatState;
-
 static void v9fs_stat_post_lstat(V9fsState *s, V9fsStatState *vs, int err)
 {
     if (err == -1) {
@@ -1053,19 +1091,6 @@  out:
     qemu_free(vs);
 }
 
-typedef struct V9fsWalkState {
-    V9fsPDU *pdu;
-    size_t offset;
-    int16_t nwnames;
-    int name_idx;
-    V9fsQID *qids;
-    V9fsFidState *fidp;
-    V9fsFidState *newfidp;
-    V9fsString path;
-    V9fsString *wnames;
-    struct stat stbuf;
-} V9fsWalkState;
-
 static void v9fs_walk_complete(V9fsState *s, V9fsWalkState *vs, int err)
 {
     complete_pdu(s, vs->pdu, err);
@@ -1229,62 +1254,6 @@  out:
     v9fs_walk_complete(s, vs, err);
 }
 
-typedef struct V9fsOpenState {
-    V9fsPDU *pdu;
-    size_t offset;
-    int8_t mode;
-    V9fsFidState *fidp;
-    V9fsQID qid;
-    struct stat stbuf;
-
-} V9fsOpenState;
-
-enum {
-    Oread   = 0x00,
-    Owrite  = 0x01,
-    Ordwr   = 0x02,
-    Oexec   = 0x03,
-    Oexcl   = 0x04,
-    Otrunc  = 0x10,
-    Orexec  = 0x20,
-    Orclose = 0x40,
-    Oappend = 0x80,
-};
-
-static int omode_to_uflags(int8_t mode)
-{
-    int ret = 0;
-
-    switch (mode & 3) {
-    case Oread:
-        ret = O_RDONLY;
-        break;
-    case Ordwr:
-        ret = O_RDWR;
-        break;
-    case Owrite:
-        ret = O_WRONLY;
-        break;
-    case Oexec:
-        ret = O_RDONLY;
-        break;
-    }
-
-    if (mode & Otrunc) {
-        ret |= O_TRUNC;
-    }
-
-    if (mode & Oappend) {
-        ret |= O_APPEND;
-    }
-
-    if (mode & Oexcl) {
-        ret |= O_EXCL;
-    }
-
-    return ret;
-}
-
 static void v9fs_open_post_opendir(V9fsState *s, V9fsOpenState *vs, int err)
 {
     if (vs->fidp->dir == NULL) {
@@ -1387,25 +1356,6 @@  out:
     complete_pdu(s, pdu, err);
 }
 
-typedef struct V9fsReadState {
-    V9fsPDU *pdu;
-    size_t offset;
-    int32_t count;
-    int32_t total;
-    int64_t off;
-    V9fsFidState *fidp;
-    struct iovec iov[128]; /* FIXME: bad, bad, bad */
-    struct iovec *sg;
-    off_t dir_pos;
-    struct dirent *dent;
-    struct stat stbuf;
-    V9fsString name;
-    V9fsStat v9stat;
-    int32_t len;
-    int32_t cnt;
-    int32_t max_count;
-} V9fsReadState;
-
 static void v9fs_read_post_readdir(V9fsState *, V9fsReadState *, ssize_t);
 
 static void v9fs_read_post_seekdir(V9fsState *s, V9fsReadState *vs, ssize_t err)
@@ -1593,19 +1543,6 @@  out:
     qemu_free(vs);
 }
 
-typedef struct V9fsWriteState {
-    V9fsPDU *pdu;
-    size_t offset;
-    int32_t len;
-    int32_t count;
-    int32_t total;
-    int64_t off;
-    V9fsFidState *fidp;
-    struct iovec iov[128]; /* FIXME: bad, bad, bad */
-    struct iovec *sg;
-    int cnt;
-} V9fsWriteState;
-
 static void v9fs_write_post_writev(V9fsState *s, V9fsWriteState *vs,
                                    ssize_t err)
 {
@@ -1702,19 +1639,6 @@  out:
     qemu_free(vs);
 }
 
-typedef struct V9fsCreateState {
-    V9fsPDU *pdu;
-    size_t offset;
-    V9fsFidState *fidp;
-    V9fsQID qid;
-    int32_t perm;
-    int8_t mode;
-    struct stat stbuf;
-    V9fsString name;
-    V9fsString extension;
-    V9fsString fullname;
-} V9fsCreateState;
-
 static void v9fs_post_create(V9fsState *s, V9fsCreateState *vs, int err)
 {
     if (err == 0) {
@@ -1934,12 +1858,6 @@  static void v9fs_flush(V9fsState *s, V9fsPDU *pdu)
     complete_pdu(s, pdu, 7);
 }
 
-typedef struct V9fsRemoveState {
-    V9fsPDU *pdu;
-    size_t offset;
-    V9fsFidState *fidp;
-} V9fsRemoveState;
-
 static void v9fs_remove_post_remove(V9fsState *s, V9fsRemoveState *vs,
                                                                 int err)
 {
@@ -1982,17 +1900,6 @@  out:
     qemu_free(vs);
 }
 
-typedef struct V9fsWstatState
-{
-    V9fsPDU *pdu;
-    size_t offset;
-    int16_t unused;
-    V9fsStat v9stat;
-    V9fsFidState *fidp;
-    struct stat stbuf;
-    V9fsString nname;
-} V9fsWstatState;
-
 static void v9fs_wstat_post_truncate(V9fsState *s, V9fsWstatState *vs, int err)
 {
     if (err < 0) {
diff --git a/hw/virtio-9p.h b/hw/virtio-9p.h
index b95dbe4..67f8087 100644
--- a/hw/virtio-9p.h
+++ b/hw/virtio-9p.h
@@ -146,6 +146,98 @@  typedef struct V9fsState
     size_t config_size;
 } V9fsState;
 
+typedef struct V9fsCreateState {
+    V9fsPDU *pdu;
+    size_t offset;
+    V9fsFidState *fidp;
+    V9fsQID qid;
+    int32_t perm;
+    int8_t mode;
+    struct stat stbuf;
+    V9fsString name;
+    V9fsString extension;
+    V9fsString fullname;
+} V9fsCreateState;
+
+typedef struct V9fsStatState {
+    V9fsPDU *pdu;
+    size_t offset;
+    V9fsStat v9stat;
+    V9fsFidState *fidp;
+    struct stat stbuf;
+} V9fsStatState;
+
+typedef struct V9fsWalkState {
+    V9fsPDU *pdu;
+    size_t offset;
+    int16_t nwnames;
+    int name_idx;
+    V9fsQID *qids;
+    V9fsFidState *fidp;
+    V9fsFidState *newfidp;
+    V9fsString path;
+    V9fsString *wnames;
+    struct stat stbuf;
+} V9fsWalkState;
+
+typedef struct V9fsOpenState {
+    V9fsPDU *pdu;
+    size_t offset;
+    int8_t mode;
+    V9fsFidState *fidp;
+    V9fsQID qid;
+    struct stat stbuf;
+} V9fsOpenState;
+
+typedef struct V9fsReadState {
+    V9fsPDU *pdu;
+    size_t offset;
+    int32_t count;
+    int32_t total;
+    int64_t off;
+    V9fsFidState *fidp;
+    struct iovec iov[128]; /* FIXME: bad, bad, bad */
+    struct iovec *sg;
+    off_t dir_pos;
+    struct dirent *dent;
+    struct stat stbuf;
+    V9fsString name;
+    V9fsStat v9stat;
+    int32_t len;
+    int32_t cnt;
+    int32_t max_count;
+} V9fsReadState;
+
+typedef struct V9fsWriteState {
+    V9fsPDU *pdu;
+    size_t offset;
+    int32_t len;
+    int32_t count;
+    int32_t total;
+    int64_t off;
+    V9fsFidState *fidp;
+    struct iovec iov[128]; /* FIXME: bad, bad, bad */
+    struct iovec *sg;
+    int cnt;
+} V9fsWriteState;
+
+typedef struct V9fsRemoveState {
+    V9fsPDU *pdu;
+    size_t offset;
+    V9fsFidState *fidp;
+} V9fsRemoveState;
+
+typedef struct V9fsWstatState
+{
+    V9fsPDU *pdu;
+    size_t offset;
+    int16_t unused;
+    V9fsStat v9stat;
+    V9fsFidState *fidp;
+    struct stat stbuf;
+    V9fsString nname;
+} V9fsWstatState;
+
 struct virtio_9p_config
 {
     /* number of characters in tag */