9p-synth.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*
  2. * 9p
  3. *
  4. * Copyright IBM, Corp. 2011
  5. *
  6. * Authors:
  7. * Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
  8. *
  9. * This work is licensed under the terms of the GNU GPL, version 2. See
  10. * the COPYING file in the top-level directory.
  11. *
  12. */
  13. #ifndef QEMU_9P_SYNTH_H
  14. #define QEMU_9P_SYNTH_H
  15. typedef struct V9fsSynthNode V9fsSynthNode;
  16. typedef ssize_t (*v9fs_synth_read)(void *buf, int len, off_t offset,
  17. void *arg);
  18. typedef ssize_t (*v9fs_synth_write)(void *buf, int len, off_t offset,
  19. void *arg);
  20. typedef struct V9fsSynthNodeAttr {
  21. int mode;
  22. int inode;
  23. int nlink;
  24. v9fs_synth_read read;
  25. v9fs_synth_write write;
  26. } V9fsSynthNodeAttr;
  27. struct V9fsSynthNode {
  28. QLIST_HEAD(, V9fsSynthNode) child;
  29. QLIST_ENTRY(V9fsSynthNode) sibling;
  30. char name[NAME_MAX];
  31. V9fsSynthNodeAttr *attr;
  32. V9fsSynthNodeAttr actual_attr;
  33. void *private;
  34. int open_count;
  35. };
  36. typedef struct V9fsSynthOpenState {
  37. off_t offset;
  38. V9fsSynthNode *node;
  39. struct dirent dent;
  40. } V9fsSynthOpenState;
  41. int qemu_v9fs_synth_mkdir(V9fsSynthNode *parent, int mode,
  42. const char *name, V9fsSynthNode **result);
  43. int qemu_v9fs_synth_add_file(V9fsSynthNode *parent, int mode,
  44. const char *name, v9fs_synth_read read,
  45. v9fs_synth_write write, void *arg);
  46. /* qtest stuff */
  47. #define QTEST_V9FS_SYNTH_WALK_FILE "WALK%d"
  48. #define QTEST_V9FS_SYNTH_LOPEN_FILE "LOPEN"
  49. #define QTEST_V9FS_SYNTH_WRITE_FILE "WRITE"
  50. /* Any write to the "FLUSH" file is handled one byte at a time by the
  51. * backend. If the byte is zero, the backend returns success (ie, 1),
  52. * otherwise it forces the server to try again forever. Thus allowing
  53. * the client to cancel the request.
  54. */
  55. #define QTEST_V9FS_SYNTH_FLUSH_FILE "FLUSH"
  56. #endif