2008-10-14 01:40:27 +00:00
|
|
|
/*
|
|
|
|
* net/9p/protocol.c
|
|
|
|
*
|
|
|
|
* 9P Protocol Support Code
|
|
|
|
*
|
|
|
|
* Copyright (C) 2008 by Eric Van Hensbergen <ericvh@gmail.com>
|
|
|
|
*
|
|
|
|
* Base on code from Anthony Liguori <aliguori@us.ibm.com>
|
|
|
|
* Copyright (C) 2008 by IBM, Corp.
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/errno.h>
|
2010-12-04 15:22:46 +00:00
|
|
|
#include <linux/kernel.h>
|
2008-10-16 13:30:07 +00:00
|
|
|
#include <linux/uaccess.h>
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 08:04:11 +00:00
|
|
|
#include <linux/slab.h>
|
2008-10-17 21:20:07 +00:00
|
|
|
#include <linux/sched.h>
|
2010-12-04 15:22:46 +00:00
|
|
|
#include <linux/stddef.h>
|
2009-02-07 06:07:41 +00:00
|
|
|
#include <linux/types.h>
|
2008-10-14 01:40:27 +00:00
|
|
|
#include <net/9p/9p.h>
|
|
|
|
#include <net/9p/client.h>
|
|
|
|
#include "protocol.h"
|
|
|
|
|
|
|
|
static int
|
2010-03-05 18:50:14 +00:00
|
|
|
p9pdu_writef(struct p9_fcall *pdu, int proto_version, const char *fmt, ...);
|
2008-10-14 01:40:27 +00:00
|
|
|
|
2008-10-22 23:47:40 +00:00
|
|
|
#ifdef CONFIG_NET_9P_DEBUG
|
2008-10-16 13:30:07 +00:00
|
|
|
void
|
|
|
|
p9pdu_dump(int way, struct p9_fcall *pdu)
|
|
|
|
{
|
|
|
|
int i, n;
|
|
|
|
u8 *data = pdu->sdata;
|
|
|
|
int datalen = pdu->size;
|
|
|
|
char buf[255];
|
|
|
|
int buflen = 255;
|
|
|
|
|
|
|
|
i = n = 0;
|
|
|
|
if (datalen > (buflen-16))
|
|
|
|
datalen = buflen-16;
|
|
|
|
while (i < datalen) {
|
|
|
|
n += scnprintf(buf + n, buflen - n, "%02x ", data[i]);
|
|
|
|
if (i%4 == 3)
|
|
|
|
n += scnprintf(buf + n, buflen - n, " ");
|
|
|
|
if (i%32 == 31)
|
|
|
|
n += scnprintf(buf + n, buflen - n, "\n");
|
|
|
|
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
n += scnprintf(buf + n, buflen - n, "\n");
|
|
|
|
|
|
|
|
if (way)
|
2008-10-17 21:20:07 +00:00
|
|
|
P9_DPRINTK(P9_DEBUG_PKT, "[[[(%d) %s\n", datalen, buf);
|
2008-10-16 13:30:07 +00:00
|
|
|
else
|
2008-10-17 21:20:07 +00:00
|
|
|
P9_DPRINTK(P9_DEBUG_PKT, "]]](%d) %s\n", datalen, buf);
|
2008-10-16 13:30:07 +00:00
|
|
|
}
|
2008-10-22 23:47:40 +00:00
|
|
|
#else
|
|
|
|
void
|
|
|
|
p9pdu_dump(int way, struct p9_fcall *pdu)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
#endif
|
2008-10-16 13:30:07 +00:00
|
|
|
EXPORT_SYMBOL(p9pdu_dump);
|
|
|
|
|
2008-10-14 01:40:27 +00:00
|
|
|
void p9stat_free(struct p9_wstat *stbuf)
|
|
|
|
{
|
|
|
|
kfree(stbuf->name);
|
|
|
|
kfree(stbuf->uid);
|
|
|
|
kfree(stbuf->gid);
|
|
|
|
kfree(stbuf->muid);
|
|
|
|
kfree(stbuf->extension);
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(p9stat_free);
|
|
|
|
|
|
|
|
static size_t pdu_read(struct p9_fcall *pdu, void *data, size_t size)
|
|
|
|
{
|
2010-12-04 15:22:46 +00:00
|
|
|
size_t len = min(pdu->size - pdu->offset, size);
|
2008-10-14 01:40:27 +00:00
|
|
|
memcpy(data, &pdu->sdata[pdu->offset], len);
|
|
|
|
pdu->offset += len;
|
|
|
|
return size - len;
|
|
|
|
}
|
|
|
|
|
|
|
|
static size_t pdu_write(struct p9_fcall *pdu, const void *data, size_t size)
|
|
|
|
{
|
2010-12-04 15:22:46 +00:00
|
|
|
size_t len = min(pdu->capacity - pdu->size, size);
|
2008-10-14 01:40:27 +00:00
|
|
|
memcpy(&pdu->sdata[pdu->size], data, len);
|
|
|
|
pdu->size += len;
|
|
|
|
return size - len;
|
|
|
|
}
|
|
|
|
|
2008-10-16 13:30:07 +00:00
|
|
|
static size_t
|
|
|
|
pdu_write_u(struct p9_fcall *pdu, const char __user *udata, size_t size)
|
|
|
|
{
|
2010-12-04 15:22:46 +00:00
|
|
|
size_t len = min(pdu->capacity - pdu->size, size);
|
2010-10-19 03:47:02 +00:00
|
|
|
if (copy_from_user(&pdu->sdata[pdu->size], udata, len))
|
|
|
|
len = 0;
|
2008-10-16 13:30:07 +00:00
|
|
|
|
|
|
|
pdu->size += len;
|
|
|
|
return size - len;
|
|
|
|
}
|
|
|
|
|
2011-01-29 01:05:59 +00:00
|
|
|
static size_t
|
|
|
|
pdu_write_urw(struct p9_fcall *pdu, const char *kdata, const char __user *udata,
|
|
|
|
size_t size)
|
|
|
|
{
|
|
|
|
BUG_ON(pdu->size > P9_IOHDRSZ);
|
|
|
|
pdu->pubuf = (char __user *)udata;
|
|
|
|
pdu->pkbuf = (char *)kdata;
|
|
|
|
pdu->pbuf_size = size;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-02-17 02:43:20 +00:00
|
|
|
static size_t
|
|
|
|
pdu_write_readdir(struct p9_fcall *pdu, const char *kdata, size_t size)
|
|
|
|
{
|
|
|
|
BUG_ON(pdu->size > P9_READDIRHDRSZ);
|
|
|
|
pdu->pkbuf = (char *)kdata;
|
|
|
|
pdu->pbuf_size = size;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-10-14 01:40:27 +00:00
|
|
|
/*
|
|
|
|
b - int8_t
|
|
|
|
w - int16_t
|
|
|
|
d - int32_t
|
|
|
|
q - int64_t
|
|
|
|
s - string
|
|
|
|
S - stat
|
|
|
|
Q - qid
|
|
|
|
D - data blob (int32_t size followed by void *, results are not freed)
|
|
|
|
T - array of strings (int16_t count, followed by strings)
|
|
|
|
R - array of qids (int16_t count, followed by qids)
|
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
|
|
|
A - stat for 9p2000.L (p9_stat_dotl)
|
2008-10-14 01:40:27 +00:00
|
|
|
? - if optional = 1, continue parsing
|
|
|
|
*/
|
|
|
|
|
|
|
|
static int
|
2010-03-05 18:50:14 +00:00
|
|
|
p9pdu_vreadf(struct p9_fcall *pdu, int proto_version, const char *fmt,
|
|
|
|
va_list ap)
|
2008-10-14 01:40:27 +00:00
|
|
|
{
|
|
|
|
const char *ptr;
|
|
|
|
int errcode = 0;
|
|
|
|
|
|
|
|
for (ptr = fmt; *ptr; ptr++) {
|
|
|
|
switch (*ptr) {
|
|
|
|
case 'b':{
|
|
|
|
int8_t *val = va_arg(ap, int8_t *);
|
|
|
|
if (pdu_read(pdu, val, sizeof(*val))) {
|
|
|
|
errcode = -EFAULT;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'w':{
|
|
|
|
int16_t *val = va_arg(ap, int16_t *);
|
2009-02-07 06:07:41 +00:00
|
|
|
__le16 le_val;
|
|
|
|
if (pdu_read(pdu, &le_val, sizeof(le_val))) {
|
2008-10-14 01:40:27 +00:00
|
|
|
errcode = -EFAULT;
|
|
|
|
break;
|
|
|
|
}
|
2009-02-07 06:07:41 +00:00
|
|
|
*val = le16_to_cpu(le_val);
|
2008-10-14 01:40:27 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'd':{
|
|
|
|
int32_t *val = va_arg(ap, int32_t *);
|
2009-02-07 06:07:41 +00:00
|
|
|
__le32 le_val;
|
|
|
|
if (pdu_read(pdu, &le_val, sizeof(le_val))) {
|
2008-10-14 01:40:27 +00:00
|
|
|
errcode = -EFAULT;
|
|
|
|
break;
|
|
|
|
}
|
2009-02-07 06:07:41 +00:00
|
|
|
*val = le32_to_cpu(le_val);
|
2008-10-14 01:40:27 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'q':{
|
|
|
|
int64_t *val = va_arg(ap, int64_t *);
|
2009-02-07 06:07:41 +00:00
|
|
|
__le64 le_val;
|
|
|
|
if (pdu_read(pdu, &le_val, sizeof(le_val))) {
|
2008-10-14 01:40:27 +00:00
|
|
|
errcode = -EFAULT;
|
|
|
|
break;
|
|
|
|
}
|
2009-02-07 06:07:41 +00:00
|
|
|
*val = le64_to_cpu(le_val);
|
2008-10-14 01:40:27 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 's':{
|
2008-10-22 23:54:47 +00:00
|
|
|
char **sptr = va_arg(ap, char **);
|
2011-01-10 20:23:53 +00:00
|
|
|
uint16_t len;
|
2008-10-14 01:40:27 +00:00
|
|
|
|
2010-03-05 18:50:14 +00:00
|
|
|
errcode = p9pdu_readf(pdu, proto_version,
|
|
|
|
"w", &len);
|
2008-10-14 01:40:27 +00:00
|
|
|
if (errcode)
|
|
|
|
break;
|
|
|
|
|
2011-03-08 11:09:47 +00:00
|
|
|
*sptr = kmalloc(len + 1, GFP_NOFS);
|
2008-10-22 23:54:47 +00:00
|
|
|
if (*sptr == NULL) {
|
2008-10-14 01:40:27 +00:00
|
|
|
errcode = -EFAULT;
|
|
|
|
break;
|
|
|
|
}
|
2011-01-10 20:23:53 +00:00
|
|
|
if (pdu_read(pdu, *sptr, len)) {
|
2008-10-14 01:40:27 +00:00
|
|
|
errcode = -EFAULT;
|
2008-10-22 23:54:47 +00:00
|
|
|
kfree(*sptr);
|
|
|
|
*sptr = NULL;
|
2008-10-14 01:40:27 +00:00
|
|
|
} else
|
2011-01-10 20:23:53 +00:00
|
|
|
(*sptr)[len] = 0;
|
2008-10-14 01:40:27 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'Q':{
|
|
|
|
struct p9_qid *qid =
|
|
|
|
va_arg(ap, struct p9_qid *);
|
|
|
|
|
2010-03-05 18:50:14 +00:00
|
|
|
errcode = p9pdu_readf(pdu, proto_version, "bdq",
|
2008-10-14 01:40:27 +00:00
|
|
|
&qid->type, &qid->version,
|
|
|
|
&qid->path);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'S':{
|
|
|
|
struct p9_wstat *stbuf =
|
|
|
|
va_arg(ap, struct p9_wstat *);
|
|
|
|
|
2008-10-17 17:45:23 +00:00
|
|
|
memset(stbuf, 0, sizeof(struct p9_wstat));
|
2008-10-14 01:40:27 +00:00
|
|
|
stbuf->n_uid = stbuf->n_gid = stbuf->n_muid =
|
2008-10-17 17:45:23 +00:00
|
|
|
-1;
|
2008-10-14 01:40:27 +00:00
|
|
|
errcode =
|
2010-03-05 18:50:14 +00:00
|
|
|
p9pdu_readf(pdu, proto_version,
|
2008-10-14 01:40:27 +00:00
|
|
|
"wwdQdddqssss?sddd",
|
|
|
|
&stbuf->size, &stbuf->type,
|
|
|
|
&stbuf->dev, &stbuf->qid,
|
|
|
|
&stbuf->mode, &stbuf->atime,
|
|
|
|
&stbuf->mtime, &stbuf->length,
|
|
|
|
&stbuf->name, &stbuf->uid,
|
|
|
|
&stbuf->gid, &stbuf->muid,
|
|
|
|
&stbuf->extension,
|
|
|
|
&stbuf->n_uid, &stbuf->n_gid,
|
|
|
|
&stbuf->n_muid);
|
|
|
|
if (errcode)
|
|
|
|
p9stat_free(stbuf);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'D':{
|
2011-01-10 20:23:53 +00:00
|
|
|
uint32_t *count = va_arg(ap, uint32_t *);
|
2008-10-14 01:40:27 +00:00
|
|
|
void **data = va_arg(ap, void **);
|
|
|
|
|
|
|
|
errcode =
|
2010-03-05 18:50:14 +00:00
|
|
|
p9pdu_readf(pdu, proto_version, "d", count);
|
2008-10-14 01:40:27 +00:00
|
|
|
if (!errcode) {
|
|
|
|
*count =
|
2011-01-10 20:23:53 +00:00
|
|
|
min_t(uint32_t, *count,
|
2010-12-04 15:22:46 +00:00
|
|
|
pdu->size - pdu->offset);
|
2008-10-14 01:40:27 +00:00
|
|
|
*data = &pdu->sdata[pdu->offset];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'T':{
|
|
|
|
int16_t *nwname = va_arg(ap, int16_t *);
|
|
|
|
char ***wnames = va_arg(ap, char ***);
|
|
|
|
|
2010-03-05 18:50:14 +00:00
|
|
|
errcode = p9pdu_readf(pdu, proto_version,
|
|
|
|
"w", nwname);
|
2008-10-14 01:40:27 +00:00
|
|
|
if (!errcode) {
|
|
|
|
*wnames =
|
|
|
|
kmalloc(sizeof(char *) * *nwname,
|
2011-03-08 11:09:47 +00:00
|
|
|
GFP_NOFS);
|
2008-10-14 01:40:27 +00:00
|
|
|
if (!*wnames)
|
|
|
|
errcode = -ENOMEM;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!errcode) {
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < *nwname; i++) {
|
|
|
|
errcode =
|
2010-03-05 18:50:14 +00:00
|
|
|
p9pdu_readf(pdu,
|
|
|
|
proto_version,
|
2008-10-14 01:40:27 +00:00
|
|
|
"s",
|
|
|
|
&(*wnames)[i]);
|
|
|
|
if (errcode)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (errcode) {
|
|
|
|
if (*wnames) {
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < *nwname; i++)
|
|
|
|
kfree((*wnames)[i]);
|
|
|
|
}
|
|
|
|
kfree(*wnames);
|
|
|
|
*wnames = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'R':{
|
|
|
|
int16_t *nwqid = va_arg(ap, int16_t *);
|
|
|
|
struct p9_qid **wqids =
|
|
|
|
va_arg(ap, struct p9_qid **);
|
|
|
|
|
|
|
|
*wqids = NULL;
|
|
|
|
|
|
|
|
errcode =
|
2010-03-05 18:50:14 +00:00
|
|
|
p9pdu_readf(pdu, proto_version, "w", nwqid);
|
2008-10-14 01:40:27 +00:00
|
|
|
if (!errcode) {
|
|
|
|
*wqids =
|
|
|
|
kmalloc(*nwqid *
|
|
|
|
sizeof(struct p9_qid),
|
2011-03-08 11:09:47 +00:00
|
|
|
GFP_NOFS);
|
2008-10-14 01:40:27 +00:00
|
|
|
if (*wqids == NULL)
|
|
|
|
errcode = -ENOMEM;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!errcode) {
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < *nwqid; i++) {
|
|
|
|
errcode =
|
2010-03-05 18:50:14 +00:00
|
|
|
p9pdu_readf(pdu,
|
|
|
|
proto_version,
|
2008-10-14 01:40:27 +00:00
|
|
|
"Q",
|
|
|
|
&(*wqids)[i]);
|
|
|
|
if (errcode)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (errcode) {
|
|
|
|
kfree(*wqids);
|
|
|
|
*wqids = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
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
|
|
|
case 'A': {
|
|
|
|
struct p9_stat_dotl *stbuf =
|
|
|
|
va_arg(ap, struct p9_stat_dotl *);
|
|
|
|
|
|
|
|
memset(stbuf, 0, sizeof(struct p9_stat_dotl));
|
|
|
|
errcode =
|
|
|
|
p9pdu_readf(pdu, proto_version,
|
|
|
|
"qQdddqqqqqqqqqqqqqqq",
|
|
|
|
&stbuf->st_result_mask,
|
|
|
|
&stbuf->qid,
|
|
|
|
&stbuf->st_mode,
|
|
|
|
&stbuf->st_uid, &stbuf->st_gid,
|
|
|
|
&stbuf->st_nlink,
|
|
|
|
&stbuf->st_rdev, &stbuf->st_size,
|
|
|
|
&stbuf->st_blksize, &stbuf->st_blocks,
|
|
|
|
&stbuf->st_atime_sec,
|
|
|
|
&stbuf->st_atime_nsec,
|
|
|
|
&stbuf->st_mtime_sec,
|
|
|
|
&stbuf->st_mtime_nsec,
|
|
|
|
&stbuf->st_ctime_sec,
|
|
|
|
&stbuf->st_ctime_nsec,
|
|
|
|
&stbuf->st_btime_sec,
|
|
|
|
&stbuf->st_btime_nsec,
|
|
|
|
&stbuf->st_gen,
|
|
|
|
&stbuf->st_data_version);
|
|
|
|
}
|
|
|
|
break;
|
2008-10-14 01:40:27 +00:00
|
|
|
case '?':
|
2010-03-25 12:40:35 +00:00
|
|
|
if ((proto_version != p9_proto_2000u) &&
|
|
|
|
(proto_version != p9_proto_2000L))
|
2008-10-14 01:40:27 +00:00
|
|
|
return 0;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
BUG();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (errcode)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return errcode;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2010-03-05 18:50:14 +00:00
|
|
|
p9pdu_vwritef(struct p9_fcall *pdu, int proto_version, const char *fmt,
|
|
|
|
va_list ap)
|
2008-10-14 01:40:27 +00:00
|
|
|
{
|
|
|
|
const char *ptr;
|
|
|
|
int errcode = 0;
|
|
|
|
|
|
|
|
for (ptr = fmt; *ptr; ptr++) {
|
|
|
|
switch (*ptr) {
|
|
|
|
case 'b':{
|
|
|
|
int8_t val = va_arg(ap, int);
|
|
|
|
if (pdu_write(pdu, &val, sizeof(val)))
|
|
|
|
errcode = -EFAULT;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'w':{
|
2009-02-07 06:07:41 +00:00
|
|
|
__le16 val = cpu_to_le16(va_arg(ap, int));
|
2008-10-14 01:40:27 +00:00
|
|
|
if (pdu_write(pdu, &val, sizeof(val)))
|
|
|
|
errcode = -EFAULT;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'd':{
|
2009-02-07 06:07:41 +00:00
|
|
|
__le32 val = cpu_to_le32(va_arg(ap, int32_t));
|
2008-10-14 01:40:27 +00:00
|
|
|
if (pdu_write(pdu, &val, sizeof(val)))
|
|
|
|
errcode = -EFAULT;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'q':{
|
2009-02-07 06:07:41 +00:00
|
|
|
__le64 val = cpu_to_le64(va_arg(ap, int64_t));
|
2008-10-14 01:40:27 +00:00
|
|
|
if (pdu_write(pdu, &val, sizeof(val)))
|
|
|
|
errcode = -EFAULT;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 's':{
|
2008-10-22 23:54:47 +00:00
|
|
|
const char *sptr = va_arg(ap, const char *);
|
2011-01-10 20:23:53 +00:00
|
|
|
uint16_t len = 0;
|
2008-10-22 23:54:47 +00:00
|
|
|
if (sptr)
|
2011-01-10 20:23:53 +00:00
|
|
|
len = min_t(uint16_t, strlen(sptr),
|
|
|
|
USHRT_MAX);
|
2008-10-14 01:40:27 +00:00
|
|
|
|
2010-03-05 18:50:14 +00:00
|
|
|
errcode = p9pdu_writef(pdu, proto_version,
|
|
|
|
"w", len);
|
2008-10-22 23:54:47 +00:00
|
|
|
if (!errcode && pdu_write(pdu, sptr, len))
|
2008-10-14 01:40:27 +00:00
|
|
|
errcode = -EFAULT;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'Q':{
|
|
|
|
const struct p9_qid *qid =
|
|
|
|
va_arg(ap, const struct p9_qid *);
|
|
|
|
errcode =
|
2010-03-05 18:50:14 +00:00
|
|
|
p9pdu_writef(pdu, proto_version, "bdq",
|
2008-10-14 01:40:27 +00:00
|
|
|
qid->type, qid->version,
|
|
|
|
qid->path);
|
|
|
|
} break;
|
|
|
|
case 'S':{
|
|
|
|
const struct p9_wstat *stbuf =
|
|
|
|
va_arg(ap, const struct p9_wstat *);
|
|
|
|
errcode =
|
2010-03-05 18:50:14 +00:00
|
|
|
p9pdu_writef(pdu, proto_version,
|
2008-10-14 01:40:27 +00:00
|
|
|
"wwdQdddqssss?sddd",
|
|
|
|
stbuf->size, stbuf->type,
|
2008-10-16 13:30:07 +00:00
|
|
|
stbuf->dev, &stbuf->qid,
|
2008-10-14 01:40:27 +00:00
|
|
|
stbuf->mode, stbuf->atime,
|
|
|
|
stbuf->mtime, stbuf->length,
|
|
|
|
stbuf->name, stbuf->uid,
|
|
|
|
stbuf->gid, stbuf->muid,
|
|
|
|
stbuf->extension, stbuf->n_uid,
|
|
|
|
stbuf->n_gid, stbuf->n_muid);
|
|
|
|
} break;
|
|
|
|
case 'D':{
|
2011-01-10 20:23:53 +00:00
|
|
|
uint32_t count = va_arg(ap, uint32_t);
|
2008-10-14 01:40:27 +00:00
|
|
|
const void *data = va_arg(ap, const void *);
|
|
|
|
|
2010-03-05 18:50:14 +00:00
|
|
|
errcode = p9pdu_writef(pdu, proto_version, "d",
|
|
|
|
count);
|
2008-10-14 01:40:27 +00:00
|
|
|
if (!errcode && pdu_write(pdu, data, count))
|
|
|
|
errcode = -EFAULT;
|
|
|
|
}
|
|
|
|
break;
|
2011-01-29 01:05:59 +00:00
|
|
|
case 'E':{
|
|
|
|
int32_t cnt = va_arg(ap, int32_t);
|
|
|
|
const char *k = va_arg(ap, const void *);
|
2011-03-24 17:44:46 +00:00
|
|
|
const char __user *u = va_arg(ap,
|
|
|
|
const void __user *);
|
2011-01-29 01:05:59 +00:00
|
|
|
errcode = p9pdu_writef(pdu, proto_version, "d",
|
|
|
|
cnt);
|
|
|
|
if (!errcode && pdu_write_urw(pdu, k, u, cnt))
|
|
|
|
errcode = -EFAULT;
|
|
|
|
}
|
|
|
|
break;
|
2011-02-17 02:43:20 +00:00
|
|
|
case 'F':{
|
|
|
|
int32_t cnt = va_arg(ap, int32_t);
|
|
|
|
const char *k = va_arg(ap, const void *);
|
|
|
|
errcode = p9pdu_writef(pdu, proto_version, "d",
|
|
|
|
cnt);
|
|
|
|
if (!errcode && pdu_write_readdir(pdu, k, cnt))
|
|
|
|
errcode = -EFAULT;
|
|
|
|
}
|
|
|
|
break;
|
2008-10-16 13:30:07 +00:00
|
|
|
case 'U':{
|
|
|
|
int32_t count = va_arg(ap, int32_t);
|
|
|
|
const char __user *udata =
|
2008-10-22 23:54:47 +00:00
|
|
|
va_arg(ap, const void __user *);
|
2010-03-05 18:50:14 +00:00
|
|
|
errcode = p9pdu_writef(pdu, proto_version, "d",
|
|
|
|
count);
|
2008-10-16 13:30:07 +00:00
|
|
|
if (!errcode && pdu_write_u(pdu, udata, count))
|
|
|
|
errcode = -EFAULT;
|
|
|
|
}
|
|
|
|
break;
|
2008-10-14 01:40:27 +00:00
|
|
|
case 'T':{
|
|
|
|
int16_t nwname = va_arg(ap, int);
|
|
|
|
const char **wnames = va_arg(ap, const char **);
|
|
|
|
|
2010-03-05 18:50:14 +00:00
|
|
|
errcode = p9pdu_writef(pdu, proto_version, "w",
|
|
|
|
nwname);
|
2008-10-14 01:40:27 +00:00
|
|
|
if (!errcode) {
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < nwname; i++) {
|
|
|
|
errcode =
|
2010-03-05 18:50:14 +00:00
|
|
|
p9pdu_writef(pdu,
|
|
|
|
proto_version,
|
2008-10-14 01:40:27 +00:00
|
|
|
"s",
|
|
|
|
wnames[i]);
|
|
|
|
if (errcode)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'R':{
|
|
|
|
int16_t nwqid = va_arg(ap, int);
|
|
|
|
struct p9_qid *wqids =
|
|
|
|
va_arg(ap, struct p9_qid *);
|
|
|
|
|
2010-03-05 18:50:14 +00:00
|
|
|
errcode = p9pdu_writef(pdu, proto_version, "w",
|
|
|
|
nwqid);
|
2008-10-14 01:40:27 +00:00
|
|
|
if (!errcode) {
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < nwqid; i++) {
|
|
|
|
errcode =
|
2010-03-05 18:50:14 +00:00
|
|
|
p9pdu_writef(pdu,
|
|
|
|
proto_version,
|
2008-10-14 01:40:27 +00:00
|
|
|
"Q",
|
|
|
|
&wqids[i]);
|
|
|
|
if (errcode)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
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
|
|
|
case 'I':{
|
|
|
|
struct p9_iattr_dotl *p9attr = va_arg(ap,
|
|
|
|
struct p9_iattr_dotl *);
|
|
|
|
|
|
|
|
errcode = p9pdu_writef(pdu, proto_version,
|
|
|
|
"ddddqqqqq",
|
|
|
|
p9attr->valid,
|
|
|
|
p9attr->mode,
|
|
|
|
p9attr->uid,
|
|
|
|
p9attr->gid,
|
|
|
|
p9attr->size,
|
|
|
|
p9attr->atime_sec,
|
|
|
|
p9attr->atime_nsec,
|
|
|
|
p9attr->mtime_sec,
|
|
|
|
p9attr->mtime_nsec);
|
|
|
|
}
|
|
|
|
break;
|
2008-10-14 01:40:27 +00:00
|
|
|
case '?':
|
2010-03-25 12:40:35 +00:00
|
|
|
if ((proto_version != p9_proto_2000u) &&
|
|
|
|
(proto_version != p9_proto_2000L))
|
2008-10-14 01:40:27 +00:00
|
|
|
return 0;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
BUG();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (errcode)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return errcode;
|
|
|
|
}
|
|
|
|
|
2010-03-05 18:50:14 +00:00
|
|
|
int p9pdu_readf(struct p9_fcall *pdu, int proto_version, const char *fmt, ...)
|
2008-10-14 01:40:27 +00:00
|
|
|
{
|
|
|
|
va_list ap;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
va_start(ap, fmt);
|
2010-03-05 18:50:14 +00:00
|
|
|
ret = p9pdu_vreadf(pdu, proto_version, fmt, ap);
|
2008-10-14 01:40:27 +00:00
|
|
|
va_end(ap);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2010-03-05 18:50:14 +00:00
|
|
|
p9pdu_writef(struct p9_fcall *pdu, int proto_version, const char *fmt, ...)
|
2008-10-14 01:40:27 +00:00
|
|
|
{
|
|
|
|
va_list ap;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
va_start(ap, fmt);
|
2010-03-05 18:50:14 +00:00
|
|
|
ret = p9pdu_vwritef(pdu, proto_version, fmt, ap);
|
2008-10-14 01:40:27 +00:00
|
|
|
va_end(ap);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
2008-10-16 13:30:07 +00:00
|
|
|
|
2010-03-05 18:50:14 +00:00
|
|
|
int p9stat_read(char *buf, int len, struct p9_wstat *st, int proto_version)
|
2008-10-16 13:29:30 +00:00
|
|
|
{
|
|
|
|
struct p9_fcall fake_pdu;
|
2008-10-17 21:20:07 +00:00
|
|
|
int ret;
|
2008-10-16 13:29:30 +00:00
|
|
|
|
|
|
|
fake_pdu.size = len;
|
|
|
|
fake_pdu.capacity = len;
|
|
|
|
fake_pdu.sdata = buf;
|
|
|
|
fake_pdu.offset = 0;
|
|
|
|
|
2010-03-05 18:50:14 +00:00
|
|
|
ret = p9pdu_readf(&fake_pdu, proto_version, "S", st);
|
2008-10-17 21:20:07 +00:00
|
|
|
if (ret) {
|
|
|
|
P9_DPRINTK(P9_DEBUG_9P, "<<< p9stat_read failed: %d\n", ret);
|
|
|
|
p9pdu_dump(1, &fake_pdu);
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
2008-10-16 13:29:30 +00:00
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(p9stat_read);
|
|
|
|
|
2008-10-16 13:30:07 +00:00
|
|
|
int p9pdu_prepare(struct p9_fcall *pdu, int16_t tag, int8_t type)
|
|
|
|
{
|
2011-02-03 01:52:46 +00:00
|
|
|
pdu->id = type;
|
2008-10-16 13:30:07 +00:00
|
|
|
return p9pdu_writef(pdu, 0, "dbw", 0, type, tag);
|
|
|
|
}
|
|
|
|
|
|
|
|
int p9pdu_finalize(struct p9_fcall *pdu)
|
|
|
|
{
|
|
|
|
int size = pdu->size;
|
|
|
|
int err;
|
|
|
|
|
|
|
|
pdu->size = 0;
|
|
|
|
err = p9pdu_writef(pdu, 0, "d", size);
|
|
|
|
pdu->size = size;
|
|
|
|
|
2008-10-22 23:47:40 +00:00
|
|
|
#ifdef CONFIG_NET_9P_DEBUG
|
2008-10-17 21:20:07 +00:00
|
|
|
if ((p9_debug_level & P9_DEBUG_PKT) == P9_DEBUG_PKT)
|
2008-10-16 13:30:07 +00:00
|
|
|
p9pdu_dump(0, pdu);
|
2008-10-22 23:47:40 +00:00
|
|
|
#endif
|
2008-10-16 13:30:07 +00:00
|
|
|
|
2008-10-17 21:20:07 +00:00
|
|
|
P9_DPRINTK(P9_DEBUG_9P, ">>> size=%d type: %d tag: %d\n", pdu->size,
|
|
|
|
pdu->id, pdu->tag);
|
|
|
|
|
2008-10-16 13:30:07 +00:00
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
void p9pdu_reset(struct p9_fcall *pdu)
|
|
|
|
{
|
|
|
|
pdu->offset = 0;
|
|
|
|
pdu->size = 0;
|
2011-01-28 22:11:13 +00:00
|
|
|
pdu->private = NULL;
|
|
|
|
pdu->pubuf = NULL;
|
|
|
|
pdu->pkbuf = NULL;
|
|
|
|
pdu->pbuf_size = 0;
|
2008-10-16 13:30:07 +00:00
|
|
|
}
|
2010-06-04 13:41:26 +00:00
|
|
|
|
|
|
|
int p9dirent_read(char *buf, int len, struct p9_dirent *dirent,
|
|
|
|
int proto_version)
|
|
|
|
{
|
|
|
|
struct p9_fcall fake_pdu;
|
|
|
|
int ret;
|
|
|
|
char *nameptr;
|
|
|
|
|
|
|
|
fake_pdu.size = len;
|
|
|
|
fake_pdu.capacity = len;
|
|
|
|
fake_pdu.sdata = buf;
|
|
|
|
fake_pdu.offset = 0;
|
|
|
|
|
|
|
|
ret = p9pdu_readf(&fake_pdu, proto_version, "Qqbs", &dirent->qid,
|
|
|
|
&dirent->d_off, &dirent->d_type, &nameptr);
|
|
|
|
if (ret) {
|
|
|
|
P9_DPRINTK(P9_DEBUG_9P, "<<< p9dirent_read failed: %d\n", ret);
|
|
|
|
p9pdu_dump(1, &fake_pdu);
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
strcpy(dirent->d_name, nameptr);
|
|
|
|
|
|
|
|
out:
|
|
|
|
return fake_pdu.offset;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(p9dirent_read);
|