xref: /openbmc/qemu/hw/9pfs/9p-synth.h (revision 635324e83e238598e86628dba5ab62ce910e6f72)
1364031f1SWei Liu /*
2364031f1SWei Liu  * 9p
3364031f1SWei Liu  *
4364031f1SWei Liu  * Copyright IBM, Corp. 2011
5364031f1SWei Liu  *
6364031f1SWei Liu  * Authors:
7364031f1SWei Liu  *  Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
8364031f1SWei Liu  *
9364031f1SWei Liu  * This work is licensed under the terms of the GNU GPL, version 2.  See
10364031f1SWei Liu  * the COPYING file in the top-level directory.
11364031f1SWei Liu  *
12364031f1SWei Liu  */
13364031f1SWei Liu #ifndef HW_9PFS_SYNTH_H
14364031f1SWei Liu #define HW_9PFS_SYNTH_H 1
15364031f1SWei Liu 
16364031f1SWei Liu 
17364031f1SWei Liu typedef struct V9fsSynthNode V9fsSynthNode;
18364031f1SWei Liu typedef ssize_t (*v9fs_synth_read)(void *buf, int len, off_t offset,
19364031f1SWei Liu                                    void *arg);
20364031f1SWei Liu typedef ssize_t (*v9fs_synth_write)(void *buf, int len, off_t offset,
21364031f1SWei Liu                                     void *arg);
22364031f1SWei Liu typedef struct V9fsSynthNodeAttr {
23364031f1SWei Liu     int mode;
24364031f1SWei Liu     int inode;
25364031f1SWei Liu     int nlink;
26364031f1SWei Liu     v9fs_synth_read read;
27364031f1SWei Liu     v9fs_synth_write write;
28364031f1SWei Liu } V9fsSynthNodeAttr;
29364031f1SWei Liu 
30364031f1SWei Liu struct V9fsSynthNode {
31364031f1SWei Liu     QLIST_HEAD(, V9fsSynthNode) child;
32364031f1SWei Liu     QLIST_ENTRY(V9fsSynthNode) sibling;
33364031f1SWei Liu     char name[NAME_MAX];
34364031f1SWei Liu     V9fsSynthNodeAttr *attr;
35364031f1SWei Liu     V9fsSynthNodeAttr actual_attr;
36364031f1SWei Liu     void *private;
37364031f1SWei Liu     int open_count;
38364031f1SWei Liu };
39364031f1SWei Liu 
40364031f1SWei Liu typedef struct V9fsSynthOpenState {
41364031f1SWei Liu     off_t offset;
42364031f1SWei Liu     V9fsSynthNode *node;
43*635324e8SGreg Kurz     struct dirent dent;
44364031f1SWei Liu } V9fsSynthOpenState;
45364031f1SWei Liu 
46364031f1SWei Liu extern int qemu_v9fs_synth_mkdir(V9fsSynthNode *parent, int mode,
47364031f1SWei Liu                                  const char *name, V9fsSynthNode **result);
48364031f1SWei Liu extern int qemu_v9fs_synth_add_file(V9fsSynthNode *parent, int mode,
49364031f1SWei Liu                                     const char *name, v9fs_synth_read read,
50364031f1SWei Liu                                     v9fs_synth_write write, void *arg);
51364031f1SWei Liu 
52364031f1SWei Liu #endif
53