Latchesar Ionkov | bd238fb | 2007-07-10 17:57:28 -0500 | [diff] [blame] | 1 | /* |
| 2 | * include/net/9p/client.h |
| 3 | * |
| 4 | * 9P Client Definitions |
| 5 | * |
Eric Van Hensbergen | 8a0dc95 | 2008-02-06 19:25:03 -0600 | [diff] [blame] | 6 | * Copyright (C) 2008 by Eric Van Hensbergen <ericvh@gmail.com> |
Latchesar Ionkov | bd238fb | 2007-07-10 17:57:28 -0500 | [diff] [blame] | 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 | |
| 26 | #ifndef NET_9P_CLIENT_H |
| 27 | #define NET_9P_CLIENT_H |
| 28 | |
Eric Van Hensbergen | ee44399 | 2008-03-05 07:08:09 -0600 | [diff] [blame] | 29 | /** |
Eric Van Hensbergen | 8b81ef5 | 2008-10-13 18:45:25 -0500 | [diff] [blame^] | 30 | * enum p9_trans_status - different states of underlying transports |
| 31 | * @Connected: transport is connected and healthy |
| 32 | * @Disconnected: transport has been disconnected |
| 33 | * @Hung: transport is connected by wedged |
| 34 | * |
| 35 | * This enumeration details the various states a transport |
| 36 | * instatiation can be in. |
| 37 | */ |
| 38 | |
| 39 | enum p9_trans_status { |
| 40 | Connected, |
| 41 | Disconnected, |
| 42 | Hung, |
| 43 | }; |
| 44 | |
| 45 | /** |
Eric Van Hensbergen | ee44399 | 2008-03-05 07:08:09 -0600 | [diff] [blame] | 46 | * struct p9_client - per client instance state |
| 47 | * @lock: protect @fidlist |
| 48 | * @msize: maximum data size negotiated by protocol |
| 49 | * @dotu: extension flags negotiated by protocol |
| 50 | * @trans_mod: module API instantiated with this client |
| 51 | * @trans: tranport instance state and API |
| 52 | * @conn: connection state information used by trans_fd |
| 53 | * @fidpool: fid handle accounting for session |
| 54 | * @fidlist: List of active fid handles |
| 55 | * |
| 56 | * The client structure is used to keep track of various per-client |
| 57 | * state that has been instantiated. |
| 58 | * |
| 59 | * Bugs: duplicated data and potentially unnecessary elements. |
| 60 | */ |
| 61 | |
Latchesar Ionkov | bd238fb | 2007-07-10 17:57:28 -0500 | [diff] [blame] | 62 | struct p9_client { |
| 63 | spinlock_t lock; /* protect client structure */ |
| 64 | int msize; |
| 65 | unsigned char dotu; |
Eric Van Hensbergen | 8a0dc95 | 2008-02-06 19:25:03 -0600 | [diff] [blame] | 66 | struct p9_trans_module *trans_mod; |
Eric Van Hensbergen | 8b81ef5 | 2008-10-13 18:45:25 -0500 | [diff] [blame^] | 67 | enum p9_trans_status status; |
| 68 | void *trans; |
Latchesar Ionkov | bd238fb | 2007-07-10 17:57:28 -0500 | [diff] [blame] | 69 | struct p9_conn *conn; |
| 70 | |
| 71 | struct p9_idpool *fidpool; |
| 72 | struct list_head fidlist; |
| 73 | }; |
| 74 | |
Eric Van Hensbergen | ee44399 | 2008-03-05 07:08:09 -0600 | [diff] [blame] | 75 | /** |
| 76 | * struct p9_fid - file system entity handle |
| 77 | * @clnt: back pointer to instantiating &p9_client |
| 78 | * @fid: numeric identifier for this handle |
| 79 | * @mode: current mode of this fid (enum?) |
| 80 | * @qid: the &p9_qid server identifier this handle points to |
| 81 | * @iounit: the server reported maximum transaction size for this file |
| 82 | * @uid: the numeric uid of the local user who owns this handle |
| 83 | * @aux: transport specific information (unused?) |
| 84 | * @rdir_fpos: tracks offset of file position when reading directory contents |
| 85 | * @rdir_pos: (unused?) |
| 86 | * @rdir_fcall: holds response of last directory read request |
| 87 | * @flist: per-client-instance fid tracking |
| 88 | * @dlist: per-dentry fid tracking |
| 89 | * |
| 90 | * TODO: This needs lots of explanation. |
| 91 | */ |
| 92 | |
Latchesar Ionkov | bd238fb | 2007-07-10 17:57:28 -0500 | [diff] [blame] | 93 | struct p9_fid { |
| 94 | struct p9_client *clnt; |
| 95 | u32 fid; |
| 96 | int mode; |
| 97 | struct p9_qid qid; |
| 98 | u32 iounit; |
| 99 | uid_t uid; |
| 100 | void *aux; |
| 101 | |
| 102 | int rdir_fpos; |
| 103 | int rdir_pos; |
| 104 | struct p9_fcall *rdir_fcall; |
| 105 | struct list_head flist; |
| 106 | struct list_head dlist; /* list of all fids attached to a dentry */ |
| 107 | }; |
| 108 | |
Eric Van Hensbergen | 8a0dc95 | 2008-02-06 19:25:03 -0600 | [diff] [blame] | 109 | struct p9_client *p9_client_create(const char *dev_name, char *options); |
Latchesar Ionkov | bd238fb | 2007-07-10 17:57:28 -0500 | [diff] [blame] | 110 | void p9_client_destroy(struct p9_client *clnt); |
| 111 | void p9_client_disconnect(struct p9_client *clnt); |
| 112 | struct p9_fid *p9_client_attach(struct p9_client *clnt, struct p9_fid *afid, |
Latchesar Ionkov | ba17674 | 2007-10-17 14:31:07 -0500 | [diff] [blame] | 113 | char *uname, u32 n_uname, char *aname); |
| 114 | struct p9_fid *p9_client_auth(struct p9_client *clnt, char *uname, |
| 115 | u32 n_uname, char *aname); |
Latchesar Ionkov | bd238fb | 2007-07-10 17:57:28 -0500 | [diff] [blame] | 116 | struct p9_fid *p9_client_walk(struct p9_fid *oldfid, int nwname, char **wnames, |
| 117 | int clone); |
| 118 | int p9_client_open(struct p9_fid *fid, int mode); |
| 119 | int p9_client_fcreate(struct p9_fid *fid, char *name, u32 perm, int mode, |
| 120 | char *extension); |
| 121 | int p9_client_clunk(struct p9_fid *fid); |
| 122 | int p9_client_remove(struct p9_fid *fid); |
| 123 | int p9_client_read(struct p9_fid *fid, char *data, u64 offset, u32 count); |
| 124 | int p9_client_readn(struct p9_fid *fid, char *data, u64 offset, u32 count); |
| 125 | int p9_client_write(struct p9_fid *fid, char *data, u64 offset, u32 count); |
| 126 | int p9_client_uread(struct p9_fid *fid, char __user *data, u64 offset, |
| 127 | u32 count); |
| 128 | int p9_client_uwrite(struct p9_fid *fid, const char __user *data, u64 offset, |
| 129 | u32 count); |
| 130 | struct p9_stat *p9_client_stat(struct p9_fid *fid); |
| 131 | int p9_client_wstat(struct p9_fid *fid, struct p9_wstat *wst); |
| 132 | struct p9_stat *p9_client_dirread(struct p9_fid *fid, u64 offset); |
| 133 | |
| 134 | #endif /* NET_9P_CLIENT_H */ |