2007-07-10 22:57:28 +00:00
|
|
|
/*
|
|
|
|
* include/net/9p/client.h
|
|
|
|
*
|
|
|
|
* 9P Client Definitions
|
|
|
|
*
|
2008-02-07 01:25:03 +00:00
|
|
|
* Copyright (C) 2008 by Eric Van Hensbergen <ericvh@gmail.com>
|
2007-07-10 22:57:28 +00:00
|
|
|
* Copyright (C) 2007 by Latchesar Ionkov <lucho@ionkov.net>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License version 2
|
|
|
|
* as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to:
|
|
|
|
* Free Software Foundation
|
|
|
|
* 51 Franklin Street, Fifth Floor
|
|
|
|
* Boston, MA 02111-1301 USA
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef NET_9P_CLIENT_H
|
|
|
|
#define NET_9P_CLIENT_H
|
|
|
|
|
2008-10-13 23:45:23 +00:00
|
|
|
/* Number of requests per row */
|
|
|
|
#define P9_ROW_MAXTAG 255
|
|
|
|
|
2010-03-05 18:49:11 +00:00
|
|
|
/** enum p9_proto_versions - 9P protocol versions
|
|
|
|
* @p9_proto_legacy: 9P Legacy mode, pre-9P2000.u
|
|
|
|
* @p9_proto_2000u: 9P2000.u extension
|
2010-03-08 17:33:04 +00:00
|
|
|
* @p9_proto_2000L: 9P2000.L extension
|
2010-03-05 18:49:11 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
enum p9_proto_versions{
|
|
|
|
p9_proto_legacy = 0,
|
|
|
|
p9_proto_2000u = 1,
|
2010-03-08 17:33:04 +00:00
|
|
|
p9_proto_2000L = 2,
|
2010-03-05 18:49:11 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-10-13 23:45:25 +00:00
|
|
|
/**
|
|
|
|
* enum p9_trans_status - different states of underlying transports
|
|
|
|
* @Connected: transport is connected and healthy
|
|
|
|
* @Disconnected: transport has been disconnected
|
|
|
|
* @Hung: transport is connected by wedged
|
|
|
|
*
|
|
|
|
* This enumeration details the various states a transport
|
|
|
|
* instatiation can be in.
|
|
|
|
*/
|
|
|
|
|
|
|
|
enum p9_trans_status {
|
|
|
|
Connected,
|
2010-03-29 23:13:59 +00:00
|
|
|
BeginDisconnect,
|
2008-10-13 23:45:25 +00:00
|
|
|
Disconnected,
|
|
|
|
Hung,
|
|
|
|
};
|
|
|
|
|
2008-10-13 23:45:23 +00:00
|
|
|
/**
|
|
|
|
* enum p9_req_status_t - virtio request status
|
|
|
|
* @REQ_STATUS_IDLE: request slot unused
|
|
|
|
* @REQ_STATUS_ALLOC: request has been allocated but not sent
|
2008-10-13 23:45:22 +00:00
|
|
|
* @REQ_STATUS_UNSENT: request waiting to be sent
|
2008-10-13 23:45:23 +00:00
|
|
|
* @REQ_STATUS_SENT: request sent to server
|
|
|
|
* @REQ_STATUS_FLSH: a flush has been sent for this request
|
|
|
|
* @REQ_STATUS_RCVD: response received from server
|
|
|
|
* @REQ_STATUS_FLSHD: request has been flushed
|
2008-10-13 23:45:22 +00:00
|
|
|
* @REQ_STATUS_ERROR: request encountered an error on the client side
|
2008-10-13 23:45:23 +00:00
|
|
|
*
|
|
|
|
* The @REQ_STATUS_IDLE state is used to mark a request slot as unused
|
|
|
|
* but use is actually tracked by the idpool structure which handles tag
|
|
|
|
* id allocation.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
enum p9_req_status_t {
|
|
|
|
REQ_STATUS_IDLE,
|
|
|
|
REQ_STATUS_ALLOC,
|
2008-10-13 23:45:22 +00:00
|
|
|
REQ_STATUS_UNSENT,
|
2008-10-13 23:45:23 +00:00
|
|
|
REQ_STATUS_SENT,
|
|
|
|
REQ_STATUS_FLSH,
|
|
|
|
REQ_STATUS_RCVD,
|
|
|
|
REQ_STATUS_FLSHD,
|
|
|
|
REQ_STATUS_ERROR,
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* struct p9_req_t - request slots
|
|
|
|
* @status: status of this request slot
|
|
|
|
* @t_err: transport error
|
2008-10-16 13:30:07 +00:00
|
|
|
* @flush_tag: tag of request being flushed (for flush requests)
|
2008-10-13 23:45:23 +00:00
|
|
|
* @wq: wait_queue for the client to block on for this request
|
|
|
|
* @tc: the request fcall structure
|
|
|
|
* @rc: the response fcall structure
|
|
|
|
* @aux: transport specific data (provided for trans_fd migration)
|
2008-10-13 23:45:22 +00:00
|
|
|
* @req_list: link for higher level objects to chain requests
|
2008-10-13 23:45:23 +00:00
|
|
|
*
|
|
|
|
* Transport use an array to track outstanding requests
|
|
|
|
* instead of a list. While this may incurr overhead during initial
|
|
|
|
* allocation or expansion, it makes request lookup much easier as the
|
|
|
|
* tag id is a index into an array. (We use tag+1 so that we can accomodate
|
|
|
|
* the -1 tag for the T_VERSION request).
|
|
|
|
* This also has the nice effect of only having to allocate wait_queues
|
|
|
|
* once, instead of constantly allocating and freeing them. Its possible
|
|
|
|
* other resources could benefit from this scheme as well.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
struct p9_req_t {
|
|
|
|
int status;
|
|
|
|
int t_err;
|
|
|
|
wait_queue_head_t *wq;
|
|
|
|
struct p9_fcall *tc;
|
|
|
|
struct p9_fcall *rc;
|
|
|
|
void *aux;
|
2008-10-13 23:45:22 +00:00
|
|
|
|
|
|
|
struct list_head req_list;
|
2008-10-13 23:45:23 +00:00
|
|
|
};
|
|
|
|
|
2008-03-05 13:08:09 +00:00
|
|
|
/**
|
|
|
|
* struct p9_client - per client instance state
|
|
|
|
* @lock: protect @fidlist
|
|
|
|
* @msize: maximum data size negotiated by protocol
|
|
|
|
* @dotu: extension flags negotiated by protocol
|
2010-03-05 18:49:11 +00:00
|
|
|
* @proto_version: 9P protocol version to use
|
2008-03-05 13:08:09 +00:00
|
|
|
* @trans_mod: module API instantiated with this client
|
|
|
|
* @trans: tranport instance state and API
|
|
|
|
* @conn: connection state information used by trans_fd
|
|
|
|
* @fidpool: fid handle accounting for session
|
|
|
|
* @fidlist: List of active fid handles
|
2008-10-13 23:45:23 +00:00
|
|
|
* @tagpool - transaction id accounting for session
|
|
|
|
* @reqs - 2D array of requests
|
|
|
|
* @max_tag - current maximum tag id allocated
|
2008-03-05 13:08:09 +00:00
|
|
|
*
|
|
|
|
* The client structure is used to keep track of various per-client
|
|
|
|
* state that has been instantiated.
|
2008-10-13 23:45:23 +00:00
|
|
|
* In order to minimize per-transaction overhead we use a
|
|
|
|
* simple array to lookup requests instead of a hash table
|
|
|
|
* or linked list. In order to support larger number of
|
|
|
|
* transactions, we make this a 2D array, allocating new rows
|
|
|
|
* when we need to grow the total number of the transactions.
|
|
|
|
*
|
|
|
|
* Each row is 256 requests and we'll support up to 256 rows for
|
|
|
|
* a total of 64k concurrent requests per session.
|
2008-03-05 13:08:09 +00:00
|
|
|
*
|
|
|
|
* Bugs: duplicated data and potentially unnecessary elements.
|
|
|
|
*/
|
|
|
|
|
2007-07-10 22:57:28 +00:00
|
|
|
struct p9_client {
|
|
|
|
spinlock_t lock; /* protect client structure */
|
|
|
|
int msize;
|
2010-03-05 18:49:11 +00:00
|
|
|
unsigned char proto_version;
|
2008-02-07 01:25:03 +00:00
|
|
|
struct p9_trans_module *trans_mod;
|
2008-10-13 23:45:25 +00:00
|
|
|
enum p9_trans_status status;
|
|
|
|
void *trans;
|
2007-07-10 22:57:28 +00:00
|
|
|
struct p9_conn *conn;
|
|
|
|
|
|
|
|
struct p9_idpool *fidpool;
|
|
|
|
struct list_head fidlist;
|
2008-10-13 23:45:23 +00:00
|
|
|
|
|
|
|
struct p9_idpool *tagpool;
|
|
|
|
struct p9_req_t *reqs[P9_ROW_MAXTAG];
|
|
|
|
int max_tag;
|
2007-07-10 22:57:28 +00:00
|
|
|
};
|
|
|
|
|
2008-03-05 13:08:09 +00:00
|
|
|
/**
|
|
|
|
* struct p9_fid - file system entity handle
|
|
|
|
* @clnt: back pointer to instantiating &p9_client
|
|
|
|
* @fid: numeric identifier for this handle
|
|
|
|
* @mode: current mode of this fid (enum?)
|
|
|
|
* @qid: the &p9_qid server identifier this handle points to
|
|
|
|
* @iounit: the server reported maximum transaction size for this file
|
|
|
|
* @uid: the numeric uid of the local user who owns this handle
|
2009-11-02 14:39:28 +00:00
|
|
|
* @rdir: readdir accounting structure (allocated on demand)
|
2008-03-05 13:08:09 +00:00
|
|
|
* @flist: per-client-instance fid tracking
|
|
|
|
* @dlist: per-dentry fid tracking
|
|
|
|
*
|
|
|
|
* TODO: This needs lots of explanation.
|
|
|
|
*/
|
|
|
|
|
2007-07-10 22:57:28 +00:00
|
|
|
struct p9_fid {
|
|
|
|
struct p9_client *clnt;
|
|
|
|
u32 fid;
|
|
|
|
int mode;
|
|
|
|
struct p9_qid qid;
|
|
|
|
u32 iounit;
|
|
|
|
uid_t uid;
|
|
|
|
|
2009-11-02 14:39:28 +00:00
|
|
|
void *rdir;
|
|
|
|
|
2007-07-10 22:57:28 +00:00
|
|
|
struct list_head flist;
|
|
|
|
struct list_head dlist; /* list of all fids attached to a dentry */
|
|
|
|
};
|
|
|
|
|
2010-06-04 13:41:26 +00:00
|
|
|
/**
|
|
|
|
* struct p9_dirent - directory entry structure
|
|
|
|
* @qid: The p9 server qid for this dirent
|
|
|
|
* @d_off: offset to the next dirent
|
|
|
|
* @d_type: type of file
|
|
|
|
* @d_name: file name
|
|
|
|
*/
|
|
|
|
|
|
|
|
struct p9_dirent {
|
|
|
|
struct p9_qid qid;
|
|
|
|
u64 d_off;
|
|
|
|
unsigned char d_type;
|
|
|
|
char d_name[256];
|
|
|
|
};
|
|
|
|
|
2010-03-25 12:45:30 +00:00
|
|
|
int p9_client_statfs(struct p9_fid *fid, struct p9_rstatfs *sb);
|
2010-03-25 12:47:26 +00:00
|
|
|
int p9_client_rename(struct p9_fid *fid, struct p9_fid *newdirfid, char *name);
|
2008-10-22 23:54:47 +00:00
|
|
|
int p9_client_version(struct p9_client *);
|
2008-02-07 01:25:03 +00:00
|
|
|
struct p9_client *p9_client_create(const char *dev_name, char *options);
|
2007-07-10 22:57:28 +00:00
|
|
|
void p9_client_destroy(struct p9_client *clnt);
|
|
|
|
void p9_client_disconnect(struct p9_client *clnt);
|
2010-03-29 23:13:59 +00:00
|
|
|
void p9_client_begin_disconnect(struct p9_client *clnt);
|
2007-07-10 22:57:28 +00:00
|
|
|
struct p9_fid *p9_client_attach(struct p9_client *clnt, struct p9_fid *afid,
|
2007-10-17 19:31:07 +00:00
|
|
|
char *uname, u32 n_uname, char *aname);
|
|
|
|
struct p9_fid *p9_client_auth(struct p9_client *clnt, char *uname,
|
|
|
|
u32 n_uname, char *aname);
|
2007-07-10 22:57:28 +00:00
|
|
|
struct p9_fid *p9_client_walk(struct p9_fid *oldfid, int nwname, char **wnames,
|
|
|
|
int clone);
|
|
|
|
int p9_client_open(struct p9_fid *fid, int mode);
|
|
|
|
int p9_client_fcreate(struct p9_fid *fid, char *name, u32 perm, int mode,
|
|
|
|
char *extension);
|
2010-06-03 22:16:59 +00:00
|
|
|
int p9_client_link(struct p9_fid *fid, struct p9_fid *oldfid, char *newname);
|
2010-06-09 22:59:31 +00:00
|
|
|
int p9_client_symlink(struct p9_fid *fid, char *name, char *symname, gid_t gid,
|
|
|
|
struct p9_qid *qid);
|
2007-07-10 22:57:28 +00:00
|
|
|
int p9_client_clunk(struct p9_fid *fid);
|
|
|
|
int p9_client_remove(struct p9_fid *fid);
|
2008-10-14 01:36:17 +00:00
|
|
|
int p9_client_read(struct p9_fid *fid, char *data, char __user *udata,
|
|
|
|
u64 offset, u32 count);
|
|
|
|
int p9_client_write(struct p9_fid *fid, char *data, const char __user *udata,
|
|
|
|
u64 offset, u32 count);
|
2010-06-04 13:41:26 +00:00
|
|
|
int p9_client_readdir(struct p9_fid *fid, char *data, u32 count, u64 offset);
|
|
|
|
int p9dirent_read(char *buf, int len, struct p9_dirent *dirent,
|
|
|
|
int proto_version);
|
2008-10-16 13:30:07 +00:00
|
|
|
struct p9_wstat *p9_client_stat(struct p9_fid *fid);
|
2007-07-10 22:57:28 +00:00
|
|
|
int p9_client_wstat(struct p9_fid *fid, struct p9_wstat *wst);
|
9p: Implement client side of setattr for 9P2000.L protocol.
SYNOPSIS
size[4] Tsetattr tag[2] attr[n]
size[4] Rsetattr tag[2]
DESCRIPTION
The setattr command changes some of the file status information.
attr resembles the iattr structure used in Linux kernel. It
specifies which status parameter is to be changed and to what
value. It is laid out as follows:
valid[4]
specifies which status information is to be changed. Possible
values are:
ATTR_MODE (1 << 0)
ATTR_UID (1 << 1)
ATTR_GID (1 << 2)
ATTR_SIZE (1 << 3)
ATTR_ATIME (1 << 4)
ATTR_MTIME (1 << 5)
ATTR_ATIME_SET (1 << 7)
ATTR_MTIME_SET (1 << 8)
The last two bits represent whether the time information
is being sent by the client's user space. In the absense
of these bits the server always uses server's time.
mode[4]
File permission bits
uid[4]
Owner id of file
gid[4]
Group id of the file
size[8]
File size
atime_sec[8]
Time of last file access, seconds
atime_nsec[8]
Time of last file access, nanoseconds
mtime_sec[8]
Time of last file modification, seconds
mtime_nsec[8]
Time of last file modification, nanoseconds
Explanation of the patches:
--------------------------
*) The kernel just copies relevent contents of iattr structure to
p9_iattr_dotl structure and passes it down to the client. The
only check it has is calling inode_change_ok()
*) The p9_iattr_dotl structure does not have ctime and ia_file
parameters because I don't think these are needed in our case.
The client user space can request updating just ctime by calling
chown(fd, -1, -1). This is handled on server side without a need
for putting ctime on the wire.
*) The server currently supports changing mode, time, ownership and
size of the file.
*) 9P RFC says "Either all the changes in wstat request happen, or
none of them does: if the request succeeds, all changes were made;
if it fails, none were."
I have not done anything to implement this specifically because I
don't see a reason.
Signed-off-by: Sripathi Kodi <sripathik@in.ibm.com>
Signed-off-by: Venkateswararao Jujjuri <jvrao@linux.vnet.ibm.com>
Signed-off-by: Eric Van Hensbergen <ericvh@gmail.com>
2010-06-18 06:20:10 +00:00
|
|
|
int p9_client_setattr(struct p9_fid *fid, struct p9_iattr_dotl *attr);
|
2007-07-10 22:57:28 +00:00
|
|
|
|
9p: getattr client implementation for 9P2000.L protocol.
SYNOPSIS
size[4] Tgetattr tag[2] fid[4] request_mask[8]
size[4] Rgetattr tag[2] lstat[n]
DESCRIPTION
The getattr transaction inquires about the file identified by fid.
request_mask is a bit mask that specifies which fields of the
stat structure is the client interested in.
The reply will contain a machine-independent directory entry,
laid out as follows:
st_result_mask[8]
Bit mask that indicates which fields in the stat structure
have been populated by the server
qid.type[1]
the type of the file (directory, etc.), represented as a bit
vector corresponding to the high 8 bits of the file's mode
word.
qid.vers[4]
version number for given path
qid.path[8]
the file server's unique identification for the file
st_mode[4]
Permission and flags
st_uid[4]
User id of owner
st_gid[4]
Group ID of owner
st_nlink[8]
Number of hard links
st_rdev[8]
Device ID (if special file)
st_size[8]
Size, in bytes
st_blksize[8]
Block size for file system IO
st_blocks[8]
Number of file system blocks allocated
st_atime_sec[8]
Time of last access, seconds
st_atime_nsec[8]
Time of last access, nanoseconds
st_mtime_sec[8]
Time of last modification, seconds
st_mtime_nsec[8]
Time of last modification, nanoseconds
st_ctime_sec[8]
Time of last status change, seconds
st_ctime_nsec[8]
Time of last status change, nanoseconds
st_btime_sec[8]
Time of creation (birth) of file, seconds
st_btime_nsec[8]
Time of creation (birth) of file, nanoseconds
st_gen[8]
Inode generation
st_data_version[8]
Data version number
request_mask and result_mask bit masks contain the following bits
#define P9_STATS_MODE 0x00000001ULL
#define P9_STATS_NLINK 0x00000002ULL
#define P9_STATS_UID 0x00000004ULL
#define P9_STATS_GID 0x00000008ULL
#define P9_STATS_RDEV 0x00000010ULL
#define P9_STATS_ATIME 0x00000020ULL
#define P9_STATS_MTIME 0x00000040ULL
#define P9_STATS_CTIME 0x00000080ULL
#define P9_STATS_INO 0x00000100ULL
#define P9_STATS_SIZE 0x00000200ULL
#define P9_STATS_BLOCKS 0x00000400ULL
#define P9_STATS_BTIME 0x00000800ULL
#define P9_STATS_GEN 0x00001000ULL
#define P9_STATS_DATA_VERSION 0x00002000ULL
#define P9_STATS_BASIC 0x000007ffULL
#define P9_STATS_ALL 0x00003fffULL
This patch implements the client side of getattr implementation for
9P2000.L. It introduces a new structure p9_stat_dotl for getting
Linux stat information along with QID. The data layout is similar to
stat structure in Linux user space with the following major
differences:
inode (st_ino) is not part of data. Instead qid is.
device (st_dev) is not part of data because this doesn't make sense
on the client.
All time variables are 64 bit wide on the wire. The kernel seems to use
32 bit variables for these variables. However, some of the architectures
have used 64 bit variables and glibc exposes 64 bit variables to user
space on some architectures. Hence to be on the safer side we have made
these 64 bit in the protocol. Refer to the comments in
include/asm-generic/stat.h
There are some additional fields: st_btime_sec, st_btime_nsec, st_gen,
st_data_version apart from the bitmask, st_result_mask. The bit mask
is filled by the server to indicate which stat fields have been
populated by the server. Currently there is no clean way for the
server to obtain these additional fields, so it sends back just the
basic fields.
Signed-off-by: Sripathi Kodi <sripathik@in.ibm.com>
Signed-off-by: Eric Van Hensbegren <ericvh@gmail.com>
2010-07-12 14:37:23 +00:00
|
|
|
struct p9_stat_dotl *p9_client_getattr_dotl(struct p9_fid *fid,
|
|
|
|
u64 request_mask);
|
|
|
|
|
2010-06-16 08:57:01 +00:00
|
|
|
int p9_client_mknod_dotl(struct p9_fid *oldfid, char *name, int mode,
|
|
|
|
dev_t rdev, gid_t gid, struct p9_qid *);
|
2008-10-13 23:45:23 +00:00
|
|
|
struct p9_req_t *p9_tag_lookup(struct p9_client *, u16);
|
2008-10-13 23:45:21 +00:00
|
|
|
void p9_client_cb(struct p9_client *c, struct p9_req_t *req);
|
2008-10-13 23:45:23 +00:00
|
|
|
|
2008-10-22 23:47:39 +00:00
|
|
|
int p9_parse_header(struct p9_fcall *, int32_t *, int8_t *, int16_t *, int);
|
2008-10-16 13:29:30 +00:00
|
|
|
int p9stat_read(char *, int, struct p9_wstat *, int);
|
2008-10-16 13:30:07 +00:00
|
|
|
void p9stat_free(struct p9_wstat *);
|
|
|
|
|
2010-03-05 18:50:14 +00:00
|
|
|
int p9_is_proto_dotu(struct p9_client *clnt);
|
|
|
|
int p9_is_proto_dotl(struct p9_client *clnt);
|
2008-10-16 13:29:30 +00:00
|
|
|
|
2007-07-10 22:57:28 +00:00
|
|
|
#endif /* NET_9P_CLIENT_H */
|