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 14121d0712SMarkus Armbruster #ifndef QEMU_9P_SYNTH_H 15121d0712SMarkus Armbruster #define QEMU_9P_SYNTH_H 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; 43635324e8SGreg Kurz struct dirent dent; 44364031f1SWei Liu } V9fsSynthOpenState; 45364031f1SWei Liu 46bc70a592SGreg Kurz int qemu_v9fs_synth_mkdir(V9fsSynthNode *parent, int mode, 47364031f1SWei Liu const char *name, V9fsSynthNode **result); 48bc70a592SGreg Kurz 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 522893ddd5SGreg Kurz /* qtest stuff */ 532893ddd5SGreg Kurz 542893ddd5SGreg Kurz #define QTEST_V9FS_SYNTH_WALK_FILE "WALK%d" 5582469aaeSGreg Kurz #define QTEST_V9FS_SYNTH_LOPEN_FILE "LOPEN" 56354b86f8SGreg Kurz #define QTEST_V9FS_SYNTH_WRITE_FILE "WRITE" 572893ddd5SGreg Kurz 58*af46a3b2SChristian Schoenebeck /* for READDIR test */ 59*af46a3b2SChristian Schoenebeck #define QTEST_V9FS_SYNTH_READDIR_DIR "ReadDirDir" 60*af46a3b2SChristian Schoenebeck #define QTEST_V9FS_SYNTH_READDIR_FILE "ReadDirFile%d" 61*af46a3b2SChristian Schoenebeck #define QTEST_V9FS_SYNTH_READDIR_NFILES 100 62*af46a3b2SChristian Schoenebeck 63357e2f7fSGreg Kurz /* Any write to the "FLUSH" file is handled one byte at a time by the 64357e2f7fSGreg Kurz * backend. If the byte is zero, the backend returns success (ie, 1), 65357e2f7fSGreg Kurz * otherwise it forces the server to try again forever. Thus allowing 66357e2f7fSGreg Kurz * the client to cancel the request. 67357e2f7fSGreg Kurz */ 68357e2f7fSGreg Kurz #define QTEST_V9FS_SYNTH_FLUSH_FILE "FLUSH" 69357e2f7fSGreg Kurz 70364031f1SWei Liu #endif 71