blob: c35fb548e7cfb9bde07c7e998bd57a3dfce72ff7 [file] [log] [blame]
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -05001/*
2 * include/net/9p/client.h
3 *
4 * 9P Client Definitions
5 *
Eric Van Hensbergen8a0dc952008-02-06 19:25:03 -06006 * Copyright (C) 2008 by Eric Van Hensbergen <ericvh@gmail.com>
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -05007 * 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 Hensbergenee443992008-03-05 07:08:09 -060029/**
Eric Van Hensbergen8b81ef52008-10-13 18:45:25 -050030 * 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
39enum p9_trans_status {
40 Connected,
41 Disconnected,
42 Hung,
43};
44
45/**
Eric Van Hensbergenee443992008-03-05 07:08:09 -060046 * 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 Ionkovbd238fb2007-07-10 17:57:28 -050062struct p9_client {
63 spinlock_t lock; /* protect client structure */
64 int msize;
65 unsigned char dotu;
Eric Van Hensbergen8a0dc952008-02-06 19:25:03 -060066 struct p9_trans_module *trans_mod;
Eric Van Hensbergen8b81ef52008-10-13 18:45:25 -050067 enum p9_trans_status status;
68 void *trans;
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -050069 struct p9_conn *conn;
70
71 struct p9_idpool *fidpool;
72 struct list_head fidlist;
73};
74
Eric Van Hensbergenee443992008-03-05 07:08:09 -060075/**
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 Ionkovbd238fb2007-07-10 17:57:28 -050093struct 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 Hensbergen8a0dc952008-02-06 19:25:03 -0600109struct p9_client *p9_client_create(const char *dev_name, char *options);
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -0500110void p9_client_destroy(struct p9_client *clnt);
111void p9_client_disconnect(struct p9_client *clnt);
112struct p9_fid *p9_client_attach(struct p9_client *clnt, struct p9_fid *afid,
Latchesar Ionkovba176742007-10-17 14:31:07 -0500113 char *uname, u32 n_uname, char *aname);
114struct p9_fid *p9_client_auth(struct p9_client *clnt, char *uname,
115 u32 n_uname, char *aname);
Latchesar Ionkovbd238fb2007-07-10 17:57:28 -0500116struct p9_fid *p9_client_walk(struct p9_fid *oldfid, int nwname, char **wnames,
117 int clone);
118int p9_client_open(struct p9_fid *fid, int mode);
119int p9_client_fcreate(struct p9_fid *fid, char *name, u32 perm, int mode,
120 char *extension);
121int p9_client_clunk(struct p9_fid *fid);
122int p9_client_remove(struct p9_fid *fid);
123int p9_client_read(struct p9_fid *fid, char *data, u64 offset, u32 count);
124int p9_client_readn(struct p9_fid *fid, char *data, u64 offset, u32 count);
125int p9_client_write(struct p9_fid *fid, char *data, u64 offset, u32 count);
126int p9_client_uread(struct p9_fid *fid, char __user *data, u64 offset,
127 u32 count);
128int p9_client_uwrite(struct p9_fid *fid, const char __user *data, u64 offset,
129 u32 count);
130struct p9_stat *p9_client_stat(struct p9_fid *fid);
131int p9_client_wstat(struct p9_fid *fid, struct p9_wstat *wst);
132struct p9_stat *p9_client_dirread(struct p9_fid *fid, u64 offset);
133
134#endif /* NET_9P_CLIENT_H */