client.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. /*
  2. * include/net/9p/client.h
  3. *
  4. * 9P Client Definitions
  5. *
  6. * Copyright (C) 2008 by Eric Van Hensbergen <ericvh@gmail.com>
  7. * Copyright (C) 2007 by Latchesar Ionkov <lucho@ionkov.net>
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License version 2
  11. * as published by the Free Software Foundation.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to:
  20. * Free Software Foundation
  21. * 51 Franklin Street, Fifth Floor
  22. * Boston, MA 02111-1301 USA
  23. *
  24. */
  25. #ifndef NET_9P_CLIENT_H
  26. #define NET_9P_CLIENT_H
  27. /**
  28. * struct p9_client - per client instance state
  29. * @lock: protect @fidlist
  30. * @msize: maximum data size negotiated by protocol
  31. * @dotu: extension flags negotiated by protocol
  32. * @trans_mod: module API instantiated with this client
  33. * @trans: tranport instance state and API
  34. * @conn: connection state information used by trans_fd
  35. * @fidpool: fid handle accounting for session
  36. * @fidlist: List of active fid handles
  37. *
  38. * The client structure is used to keep track of various per-client
  39. * state that has been instantiated.
  40. *
  41. * Bugs: duplicated data and potentially unnecessary elements.
  42. */
  43. struct p9_client {
  44. spinlock_t lock; /* protect client structure */
  45. int msize;
  46. unsigned char dotu;
  47. struct p9_trans_module *trans_mod;
  48. struct p9_trans *trans;
  49. struct p9_conn *conn;
  50. struct p9_idpool *fidpool;
  51. struct list_head fidlist;
  52. };
  53. /**
  54. * struct p9_fid - file system entity handle
  55. * @clnt: back pointer to instantiating &p9_client
  56. * @fid: numeric identifier for this handle
  57. * @mode: current mode of this fid (enum?)
  58. * @qid: the &p9_qid server identifier this handle points to
  59. * @iounit: the server reported maximum transaction size for this file
  60. * @uid: the numeric uid of the local user who owns this handle
  61. * @aux: transport specific information (unused?)
  62. * @rdir_fpos: tracks offset of file position when reading directory contents
  63. * @rdir_pos: (unused?)
  64. * @rdir_fcall: holds response of last directory read request
  65. * @flist: per-client-instance fid tracking
  66. * @dlist: per-dentry fid tracking
  67. *
  68. * TODO: This needs lots of explanation.
  69. */
  70. struct p9_fid {
  71. struct p9_client *clnt;
  72. u32 fid;
  73. int mode;
  74. struct p9_qid qid;
  75. u32 iounit;
  76. uid_t uid;
  77. void *aux;
  78. int rdir_fpos;
  79. int rdir_pos;
  80. struct p9_fcall *rdir_fcall;
  81. struct list_head flist;
  82. struct list_head dlist; /* list of all fids attached to a dentry */
  83. };
  84. struct p9_client *p9_client_create(const char *dev_name, char *options);
  85. void p9_client_destroy(struct p9_client *clnt);
  86. void p9_client_disconnect(struct p9_client *clnt);
  87. struct p9_fid *p9_client_attach(struct p9_client *clnt, struct p9_fid *afid,
  88. char *uname, u32 n_uname, char *aname);
  89. struct p9_fid *p9_client_auth(struct p9_client *clnt, char *uname,
  90. u32 n_uname, char *aname);
  91. struct p9_fid *p9_client_walk(struct p9_fid *oldfid, int nwname, char **wnames,
  92. int clone);
  93. int p9_client_open(struct p9_fid *fid, int mode);
  94. int p9_client_fcreate(struct p9_fid *fid, char *name, u32 perm, int mode,
  95. char *extension);
  96. int p9_client_clunk(struct p9_fid *fid);
  97. int p9_client_remove(struct p9_fid *fid);
  98. int p9_client_read(struct p9_fid *fid, char *data, u64 offset, u32 count);
  99. int p9_client_readn(struct p9_fid *fid, char *data, u64 offset, u32 count);
  100. int p9_client_write(struct p9_fid *fid, char *data, u64 offset, u32 count);
  101. int p9_client_uread(struct p9_fid *fid, char __user *data, u64 offset,
  102. u32 count);
  103. int p9_client_uwrite(struct p9_fid *fid, const char __user *data, u64 offset,
  104. u32 count);
  105. struct p9_stat *p9_client_stat(struct p9_fid *fid);
  106. int p9_client_wstat(struct p9_fid *fid, struct p9_wstat *wst);
  107. struct p9_stat *p9_client_dirread(struct p9_fid *fid, u64 offset);
  108. #endif /* NET_9P_CLIENT_H */