4 * Copyright IBM, Corp. 2011
7 * Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
9 * This work is licensed under the terms of the GNU GPL, version 2. See
10 * the COPYING file in the top-level directory.
14 #ifndef QEMU_9P_SYNTH_H
15 #define QEMU_9P_SYNTH_H
17 typedef struct V9fsSynthNode V9fsSynthNode
;
18 typedef ssize_t (*v9fs_synth_read
)(void *buf
, int len
, off_t offset
,
20 typedef ssize_t (*v9fs_synth_write
)(void *buf
, int len
, off_t offset
,
22 typedef struct V9fsSynthNodeAttr
{
27 v9fs_synth_write write
;
30 struct V9fsSynthNode
{
31 QLIST_HEAD(, V9fsSynthNode
) child
;
32 QLIST_ENTRY(V9fsSynthNode
) sibling
;
34 V9fsSynthNodeAttr
*attr
;
35 V9fsSynthNodeAttr actual_attr
;
40 typedef struct V9fsSynthOpenState
{
45 * Ensure there is enough space for 'dent' above, some systems have a
46 * d_name size of just 1, which would cause a buffer overrun.
48 char dent_trailing_space
[NAME_MAX
];
51 int qemu_v9fs_synth_mkdir(V9fsSynthNode
*parent
, int mode
,
52 const char *name
, V9fsSynthNode
**result
);
53 int qemu_v9fs_synth_add_file(V9fsSynthNode
*parent
, int mode
,
54 const char *name
, v9fs_synth_read read
,
55 v9fs_synth_write write
, void *arg
);
59 #define QTEST_V9FS_SYNTH_WALK_FILE "WALK%d"
60 #define QTEST_V9FS_SYNTH_LOPEN_FILE "LOPEN"
61 #define QTEST_V9FS_SYNTH_WRITE_FILE "WRITE"
63 /* for READDIR test */
64 #define QTEST_V9FS_SYNTH_READDIR_DIR "ReadDirDir"
65 #define QTEST_V9FS_SYNTH_READDIR_FILE "ReadDirFile%d"
66 #define QTEST_V9FS_SYNTH_READDIR_NFILES 100
68 /* Any write to the "FLUSH" file is handled one byte at a time by the
69 * backend. If the byte is zero, the backend returns success (ie, 1),
70 * otherwise it forces the server to try again forever. Thus allowing
71 * the client to cancel the request.
73 #define QTEST_V9FS_SYNTH_FLUSH_FILE "FLUSH"