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 26 #ifndef NET_9P_CLIENT_H 27 #define NET_9P_CLIENT_H 28 29 /** 30 * struct p9_client - per client instance state 31 * @lock: protect @fidlist 32 * @msize: maximum data size negotiated by protocol 33 * @dotu: extension flags negotiated by protocol 34 * @trans_mod: module API instantiated with this client 35 * @trans: tranport instance state and API 36 * @conn: connection state information used by trans_fd 37 * @fidpool: fid handle accounting for session 38 * @fidlist: List of active fid handles 39 * 40 * The client structure is used to keep track of various per-client 41 * state that has been instantiated. 42 * 43 * Bugs: duplicated data and potentially unnecessary elements. 44 */ 45 46 struct p9_client { 47 spinlock_t lock; /* protect client structure */ 48 int msize; 49 unsigned char dotu; 50 struct p9_trans_module *trans_mod; 51 struct p9_trans *trans; 52 struct p9_conn *conn; 53 54 struct p9_idpool *fidpool; 55 struct list_head fidlist; 56 }; 57 58 /** 59 * struct p9_fid - file system entity handle 60 * @clnt: back pointer to instantiating &p9_client 61 * @fid: numeric identifier for this handle 62 * @mode: current mode of this fid (enum?) 63 * @qid: the &p9_qid server identifier this handle points to 64 * @iounit: the server reported maximum transaction size for this file 65 * @uid: the numeric uid of the local user who owns this handle 66 * @aux: transport specific information (unused?) 67 * @rdir_fpos: tracks offset of file position when reading directory contents 68 * @rdir_pos: (unused?) 69 * @rdir_fcall: holds response of last directory read request 70 * @flist: per-client-instance fid tracking 71 * @dlist: per-dentry fid tracking 72 * 73 * TODO: This needs lots of explanation. 74 */ 75 76 struct p9_fid { 77 struct p9_client *clnt; 78 u32 fid; 79 int mode; 80 struct p9_qid qid; 81 u32 iounit; 82 uid_t uid; 83 void *aux; 84 85 int rdir_fpos; 86 int rdir_pos; 87 struct p9_fcall *rdir_fcall; 88 struct list_head flist; 89 struct list_head dlist; /* list of all fids attached to a dentry */ 90 }; 91 92 struct p9_client *p9_client_create(const char *dev_name, char *options); 93 void p9_client_destroy(struct p9_client *clnt); 94 void p9_client_disconnect(struct p9_client *clnt); 95 struct p9_fid *p9_client_attach(struct p9_client *clnt, struct p9_fid *afid, 96 char *uname, u32 n_uname, char *aname); 97 struct p9_fid *p9_client_auth(struct p9_client *clnt, char *uname, 98 u32 n_uname, char *aname); 99 struct p9_fid *p9_client_walk(struct p9_fid *oldfid, int nwname, char **wnames, 100 int clone); 101 int p9_client_open(struct p9_fid *fid, int mode); 102 int p9_client_fcreate(struct p9_fid *fid, char *name, u32 perm, int mode, 103 char *extension); 104 int p9_client_clunk(struct p9_fid *fid); 105 int p9_client_remove(struct p9_fid *fid); 106 int p9_client_read(struct p9_fid *fid, char *data, u64 offset, u32 count); 107 int p9_client_readn(struct p9_fid *fid, char *data, u64 offset, u32 count); 108 int p9_client_write(struct p9_fid *fid, char *data, u64 offset, u32 count); 109 int p9_client_uread(struct p9_fid *fid, char __user *data, u64 offset, 110 u32 count); 111 int p9_client_uwrite(struct p9_fid *fid, const char __user *data, u64 offset, 112 u32 count); 113 struct p9_stat *p9_client_stat(struct p9_fid *fid); 114 int p9_client_wstat(struct p9_fid *fid, struct p9_wstat *wst); 115 struct p9_stat *p9_client_dirread(struct p9_fid *fid, u64 offset); 116 117 #endif /* NET_9P_CLIENT_H */ 118