Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fsdev: break out 9p-marshal.{c,h} from virtio-9p-marshal.{c,h}
Break out some generic functions for marshaling 9p state. Pure code motion plus minor fixes for build system. Signed-off-by: Wei Liu <wei.liu2@citrix.com> Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
- Loading branch information
Showing
6 changed files
with
143 additions
and
111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
* 9p backend | ||
* | ||
* Copyright IBM, Corp. 2010 | ||
* | ||
* Authors: | ||
* Anthony Liguori <aliguori@us.ibm.com> | ||
* | ||
* This work is licensed under the terms of the GNU GPL, version 2. See | ||
* the COPYING file in the top-level directory. | ||
* | ||
*/ | ||
|
||
#include <glib.h> | ||
#include <glib/gprintf.h> | ||
#include <sys/types.h> | ||
#include <dirent.h> | ||
#include <sys/time.h> | ||
#include <utime.h> | ||
#include <sys/uio.h> | ||
#include <string.h> | ||
#include <stdint.h> | ||
#include <errno.h> | ||
|
||
#include "qemu/compiler.h" | ||
#include "9p-marshal.h" | ||
|
||
void v9fs_string_free(V9fsString *str) | ||
{ | ||
g_free(str->data); | ||
str->data = NULL; | ||
str->size = 0; | ||
} | ||
|
||
void v9fs_string_null(V9fsString *str) | ||
{ | ||
v9fs_string_free(str); | ||
} | ||
|
||
void GCC_FMT_ATTR(2, 3) | ||
v9fs_string_sprintf(V9fsString *str, const char *fmt, ...) | ||
{ | ||
va_list ap; | ||
|
||
v9fs_string_free(str); | ||
|
||
va_start(ap, fmt); | ||
str->size = g_vasprintf(&str->data, fmt, ap); | ||
va_end(ap); | ||
} | ||
|
||
void v9fs_string_copy(V9fsString *lhs, V9fsString *rhs) | ||
{ | ||
v9fs_string_free(lhs); | ||
v9fs_string_sprintf(lhs, "%s", rhs->data); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
#ifndef _QEMU_9P_MARSHAL_H | ||
#define _QEMU_9P_MARSHAL_H | ||
|
||
typedef struct V9fsString | ||
{ | ||
uint16_t size; | ||
char *data; | ||
} V9fsString; | ||
|
||
typedef struct V9fsQID | ||
{ | ||
int8_t type; | ||
int32_t version; | ||
int64_t path; | ||
} V9fsQID; | ||
|
||
typedef struct V9fsStat | ||
{ | ||
int16_t size; | ||
int16_t type; | ||
int32_t dev; | ||
V9fsQID qid; | ||
int32_t mode; | ||
int32_t atime; | ||
int32_t mtime; | ||
int64_t length; | ||
V9fsString name; | ||
V9fsString uid; | ||
V9fsString gid; | ||
V9fsString muid; | ||
/* 9p2000.u */ | ||
V9fsString extension; | ||
int32_t n_uid; | ||
int32_t n_gid; | ||
int32_t n_muid; | ||
} V9fsStat; | ||
|
||
typedef struct V9fsIattr | ||
{ | ||
int32_t valid; | ||
int32_t mode; | ||
int32_t uid; | ||
int32_t gid; | ||
int64_t size; | ||
int64_t atime_sec; | ||
int64_t atime_nsec; | ||
int64_t mtime_sec; | ||
int64_t mtime_nsec; | ||
} V9fsIattr; | ||
|
||
typedef struct V9fsStatDotl { | ||
uint64_t st_result_mask; | ||
V9fsQID qid; | ||
uint32_t st_mode; | ||
uint32_t st_uid; | ||
uint32_t st_gid; | ||
uint64_t st_nlink; | ||
uint64_t st_rdev; | ||
uint64_t st_size; | ||
uint64_t st_blksize; | ||
uint64_t st_blocks; | ||
uint64_t st_atime_sec; | ||
uint64_t st_atime_nsec; | ||
uint64_t st_mtime_sec; | ||
uint64_t st_mtime_nsec; | ||
uint64_t st_ctime_sec; | ||
uint64_t st_ctime_nsec; | ||
uint64_t st_btime_sec; | ||
uint64_t st_btime_nsec; | ||
uint64_t st_gen; | ||
uint64_t st_data_version; | ||
} V9fsStatDotl; | ||
|
||
static inline void v9fs_string_init(V9fsString *str) | ||
{ | ||
str->data = NULL; | ||
str->size = 0; | ||
} | ||
extern void v9fs_string_free(V9fsString *str); | ||
extern void v9fs_string_null(V9fsString *str); | ||
extern void v9fs_string_sprintf(V9fsString *str, const char *fmt, ...); | ||
extern void v9fs_string_copy(V9fsString *lhs, V9fsString *rhs); | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters