4 * 9P protocol conversion functions
6 * Copyright (C) 2004, 2005 by Latchesar Ionkov <lucho@ionkov.net>
7 * Copyright (C) 2004 by Eric Van Hensbergen <ericvh@gmail.com>
8 * Copyright (C) 2002 by Ron Minnich <rminnich@lanl.gov>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2
12 * as published by the Free Software Foundation.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to:
21 * Free Software Foundation
22 * 51 Franklin Street, Fifth Floor
23 * Boston, MA 02111-1301 USA
27 #include <linux/module.h>
28 #include <linux/errno.h>
30 #include <linux/sched.h>
31 #include <linux/idr.h>
32 #include <linux/uaccess.h>
33 #include <net/9p/9p.h>
36 * Buffer to help with string parsing
44 static inline void buf_init(struct cbuf *buf, void *data, int datalen)
46 buf->sp = buf->p = data;
47 buf->ep = data + datalen;
50 static inline int buf_check_overflow(struct cbuf *buf)
52 return buf->p > buf->ep;
55 static int buf_check_size(struct cbuf *buf, int len)
57 if (buf->p + len > buf->ep) {
58 if (buf->p < buf->ep) {
60 "buffer overflow: want %d has %d\n", len,
61 (int)(buf->ep - buf->p));
72 static void *buf_alloc(struct cbuf *buf, int len)
76 if (buf_check_size(buf, len)) {
84 static void buf_put_int8(struct cbuf *buf, u8 val)
86 if (buf_check_size(buf, 1)) {
92 static void buf_put_int16(struct cbuf *buf, u16 val)
94 if (buf_check_size(buf, 2)) {
95 *(__le16 *) buf->p = cpu_to_le16(val);
100 static void buf_put_int32(struct cbuf *buf, u32 val)
102 if (buf_check_size(buf, 4)) {
103 *(__le32 *)buf->p = cpu_to_le32(val);
108 static void buf_put_int64(struct cbuf *buf, u64 val)
110 if (buf_check_size(buf, 8)) {
111 *(__le64 *)buf->p = cpu_to_le64(val);
116 static char *buf_put_stringn(struct cbuf *buf, const char *s, u16 slen)
121 if (buf_check_size(buf, slen + 2)) {
122 buf_put_int16(buf, slen);
124 memcpy(buf->p, s, slen);
131 static u8 buf_get_int8(struct cbuf *buf)
135 if (buf_check_size(buf, 1)) {
143 static u16 buf_get_int16(struct cbuf *buf)
147 if (buf_check_size(buf, 2)) {
148 ret = le16_to_cpu(*(__le16 *)buf->p);
155 static u32 buf_get_int32(struct cbuf *buf)
159 if (buf_check_size(buf, 4)) {
160 ret = le32_to_cpu(*(__le32 *)buf->p);
167 static u64 buf_get_int64(struct cbuf *buf)
171 if (buf_check_size(buf, 8)) {
172 ret = le64_to_cpu(*(__le64 *)buf->p);
179 static void buf_get_str(struct cbuf *buf, struct p9_str *vstr)
181 vstr->len = buf_get_int16(buf);
182 if (!buf_check_overflow(buf) && buf_check_size(buf, vstr->len)) {
191 static void buf_get_qid(struct cbuf *bufp, struct p9_qid *qid)
193 qid->type = buf_get_int8(bufp);
194 qid->version = buf_get_int32(bufp);
195 qid->path = buf_get_int64(bufp);
199 * p9_size_wstat - calculate the size of a variable length stat struct
200 * @wstat: metadata (stat) structure
201 * @dotu: non-zero if 9P2000.u
205 static int p9_size_wstat(struct p9_wstat *wstat, int dotu)
210 P9_EPRINTK(KERN_ERR, "p9_size_stat: got a NULL stat pointer\n");
214 size = /* 2 + *//* size[2] */
217 1 + /* qid.type[1] */
218 4 + /* qid.vers[4] */
219 8 + /* qid.path[8] */
224 8; /* minimum sum of string lengths */
227 size += strlen(wstat->name);
229 size += strlen(wstat->uid);
231 size += strlen(wstat->gid);
233 size += strlen(wstat->muid);
236 size += 4 + /* n_uid[4] */
239 2; /* string length of extension[4] */
240 if (wstat->extension)
241 size += strlen(wstat->extension);
248 * buf_get_stat - safely decode a recieved metadata (stat) structure
249 * @bufp: buffer to deserialize
250 * @stat: metadata (stat) structure
251 * @dotu: non-zero if 9P2000.u
256 buf_get_stat(struct cbuf *bufp, struct p9_stat *stat, int dotu)
258 stat->size = buf_get_int16(bufp);
259 stat->type = buf_get_int16(bufp);
260 stat->dev = buf_get_int32(bufp);
261 stat->qid.type = buf_get_int8(bufp);
262 stat->qid.version = buf_get_int32(bufp);
263 stat->qid.path = buf_get_int64(bufp);
264 stat->mode = buf_get_int32(bufp);
265 stat->atime = buf_get_int32(bufp);
266 stat->mtime = buf_get_int32(bufp);
267 stat->length = buf_get_int64(bufp);
268 buf_get_str(bufp, &stat->name);
269 buf_get_str(bufp, &stat->uid);
270 buf_get_str(bufp, &stat->gid);
271 buf_get_str(bufp, &stat->muid);
274 buf_get_str(bufp, &stat->extension);
275 stat->n_uid = buf_get_int32(bufp);
276 stat->n_gid = buf_get_int32(bufp);
277 stat->n_muid = buf_get_int32(bufp);
282 * p9_deserialize_stat - decode a received metadata structure
283 * @buf: buffer to deserialize
284 * @buflen: length of received buffer
285 * @stat: metadata structure to decode into
286 * @dotu: non-zero if 9P2000.u
288 * Note: stat will point to the buf region.
292 p9_deserialize_stat(void *buf, u32 buflen, struct p9_stat *stat,
296 struct cbuf *bufp = &buffer;
299 buf_init(bufp, buf, buflen);
301 buf_get_stat(bufp, stat, dotu);
303 if (buf_check_overflow(bufp))
308 EXPORT_SYMBOL(p9_deserialize_stat);
311 * deserialize_fcall - unmarshal a response
312 * @buf: recieved buffer
313 * @buflen: length of received buffer
314 * @rcall: fcall structure to populate
315 * @rcalllen: length of fcall structure to populate
316 * @dotu: non-zero if 9P2000.u
321 p9_deserialize_fcall(void *buf, u32 buflen, struct p9_fcall *rcall,
326 struct cbuf *bufp = &buffer;
329 buf_init(bufp, buf, buflen);
331 rcall->size = buf_get_int32(bufp);
332 rcall->id = buf_get_int8(bufp);
333 rcall->tag = buf_get_int16(bufp);
335 P9_DPRINTK(P9_DEBUG_CONV, "size %d id %d tag %d\n", rcall->size,
336 rcall->id, rcall->tag);
340 P9_EPRINTK(KERN_ERR, "unknown message type: %d\n", rcall->id);
343 rcall->params.rversion.msize = buf_get_int32(bufp);
344 buf_get_str(bufp, &rcall->params.rversion.version);
349 rcall->params.rattach.qid.type = buf_get_int8(bufp);
350 rcall->params.rattach.qid.version = buf_get_int32(bufp);
351 rcall->params.rattach.qid.path = buf_get_int64(bufp);
354 rcall->params.rwalk.nwqid = buf_get_int16(bufp);
355 if (rcall->params.rwalk.nwqid > P9_MAXWELEM) {
357 "Rwalk with more than %d qids: %d\n",
358 P9_MAXWELEM, rcall->params.rwalk.nwqid);
362 for (i = 0; i < rcall->params.rwalk.nwqid; i++)
363 buf_get_qid(bufp, &rcall->params.rwalk.wqids[i]);
366 buf_get_qid(bufp, &rcall->params.ropen.qid);
367 rcall->params.ropen.iounit = buf_get_int32(bufp);
370 buf_get_qid(bufp, &rcall->params.rcreate.qid);
371 rcall->params.rcreate.iounit = buf_get_int32(bufp);
374 rcall->params.rread.count = buf_get_int32(bufp);
375 rcall->params.rread.data = bufp->p;
376 buf_check_size(bufp, rcall->params.rread.count);
379 rcall->params.rwrite.count = buf_get_int32(bufp);
387 buf_get_stat(bufp, &rcall->params.rstat.stat, dotu);
392 buf_get_str(bufp, &rcall->params.rerror.error);
394 rcall->params.rerror.errno = buf_get_int16(bufp);
398 if (buf_check_overflow(bufp)) {
399 P9_DPRINTK(P9_DEBUG_ERROR, "buffer overflow\n");
403 return bufp->p - bufp->sp;
405 EXPORT_SYMBOL(p9_deserialize_fcall);
407 static inline void p9_put_int8(struct cbuf *bufp, u8 val, u8 * p)
410 buf_put_int8(bufp, val);
413 static inline void p9_put_int16(struct cbuf *bufp, u16 val, u16 * p)
416 buf_put_int16(bufp, val);
419 static inline void p9_put_int32(struct cbuf *bufp, u32 val, u32 * p)
422 buf_put_int32(bufp, val);
425 static inline void p9_put_int64(struct cbuf *bufp, u64 val, u64 * p)
428 buf_put_int64(bufp, val);
432 p9_put_str(struct cbuf *bufp, char *data, struct p9_str *str)
442 s = buf_put_stringn(bufp, data, len);
450 p9_put_data(struct cbuf *bufp, const char *data, int count,
451 unsigned char **pdata)
453 *pdata = buf_alloc(bufp, count);
454 memmove(*pdata, data, count);
459 p9_put_user_data(struct cbuf *bufp, const char __user *data, int count,
460 unsigned char **pdata)
462 *pdata = buf_alloc(bufp, count);
463 return copy_from_user(*pdata, data, count);
467 p9_put_wstat(struct cbuf *bufp, struct p9_wstat *wstat,
468 struct p9_stat *stat, int statsz, int dotu)
470 p9_put_int16(bufp, statsz, &stat->size);
471 p9_put_int16(bufp, wstat->type, &stat->type);
472 p9_put_int32(bufp, wstat->dev, &stat->dev);
473 p9_put_int8(bufp, wstat->qid.type, &stat->qid.type);
474 p9_put_int32(bufp, wstat->qid.version, &stat->qid.version);
475 p9_put_int64(bufp, wstat->qid.path, &stat->qid.path);
476 p9_put_int32(bufp, wstat->mode, &stat->mode);
477 p9_put_int32(bufp, wstat->atime, &stat->atime);
478 p9_put_int32(bufp, wstat->mtime, &stat->mtime);
479 p9_put_int64(bufp, wstat->length, &stat->length);
481 p9_put_str(bufp, wstat->name, &stat->name);
482 p9_put_str(bufp, wstat->uid, &stat->uid);
483 p9_put_str(bufp, wstat->gid, &stat->gid);
484 p9_put_str(bufp, wstat->muid, &stat->muid);
487 p9_put_str(bufp, wstat->extension, &stat->extension);
488 p9_put_int32(bufp, wstat->n_uid, &stat->n_uid);
489 p9_put_int32(bufp, wstat->n_gid, &stat->n_gid);
490 p9_put_int32(bufp, wstat->n_muid, &stat->n_muid);
494 static struct p9_fcall *
495 p9_create_common(struct cbuf *bufp, u32 size, u8 id)
499 size += 4 + 1 + 2; /* size[4] id[1] tag[2] */
500 fc = kmalloc(sizeof(struct p9_fcall) + size, GFP_KERNEL);
502 return ERR_PTR(-ENOMEM);
504 fc->sdata = (char *)fc + sizeof(*fc);
506 buf_init(bufp, (char *)fc->sdata, size);
507 p9_put_int32(bufp, size, &fc->size);
508 p9_put_int8(bufp, id, &fc->id);
509 p9_put_int16(bufp, P9_NOTAG, &fc->tag);
515 * p9_set_tag - set the tag field of an &p9_fcall structure
516 * @fc: fcall structure to set tag within
517 * @tag: tag id to set
520 void p9_set_tag(struct p9_fcall *fc, u16 tag)
523 *(__le16 *) (fc->sdata + 5) = cpu_to_le16(tag);
525 EXPORT_SYMBOL(p9_set_tag);
528 * p9_create_tversion - allocates and creates a T_VERSION request
529 * @msize: requested maximum data size
530 * @version: version string to negotiate
533 struct p9_fcall *p9_create_tversion(u32 msize, char *version)
538 struct cbuf *bufp = &buffer;
540 size = 4 + 2 + strlen(version); /* msize[4] version[s] */
541 fc = p9_create_common(bufp, size, P9_TVERSION);
545 p9_put_int32(bufp, msize, &fc->params.tversion.msize);
546 p9_put_str(bufp, version, &fc->params.tversion.version);
548 if (buf_check_overflow(bufp)) {
550 fc = ERR_PTR(-ENOMEM);
555 EXPORT_SYMBOL(p9_create_tversion);
558 * p9_create_tauth - allocates and creates a T_AUTH request
559 * @afid: handle to use for authentication protocol
560 * @uname: user name attempting to authenticate
561 * @aname: mount specifier for remote server
562 * @n_uname: numeric id for user attempting to authneticate
563 * @dotu: 9P2000.u extension flag
567 struct p9_fcall *p9_create_tauth(u32 afid, char *uname, char *aname,
568 u32 n_uname, int dotu)
573 struct cbuf *bufp = &buffer;
575 /* afid[4] uname[s] aname[s] */
578 size += strlen(uname);
581 size += strlen(aname);
584 size += 4; /* n_uname */
586 fc = p9_create_common(bufp, size, P9_TAUTH);
590 p9_put_int32(bufp, afid, &fc->params.tauth.afid);
591 p9_put_str(bufp, uname, &fc->params.tauth.uname);
592 p9_put_str(bufp, aname, &fc->params.tauth.aname);
594 p9_put_int32(bufp, n_uname, &fc->params.tauth.n_uname);
596 if (buf_check_overflow(bufp)) {
598 fc = ERR_PTR(-ENOMEM);
603 EXPORT_SYMBOL(p9_create_tauth);
606 * p9_create_tattach - allocates and creates a T_ATTACH request
607 * @fid: handle to use for the new mount point
608 * @afid: handle to use for authentication protocol
609 * @uname: user name attempting to attach
610 * @aname: mount specifier for remote server
611 * @n_uname: numeric id for user attempting to attach
612 * @n_uname: numeric id for user attempting to attach
613 * @dotu: 9P2000.u extension flag
618 p9_create_tattach(u32 fid, u32 afid, char *uname, char *aname,
619 u32 n_uname, int dotu)
624 struct cbuf *bufp = &buffer;
626 /* fid[4] afid[4] uname[s] aname[s] */
627 size = 4 + 4 + 2 + 2;
629 size += strlen(uname);
632 size += strlen(aname);
635 size += 4; /* n_uname */
637 fc = p9_create_common(bufp, size, P9_TATTACH);
641 p9_put_int32(bufp, fid, &fc->params.tattach.fid);
642 p9_put_int32(bufp, afid, &fc->params.tattach.afid);
643 p9_put_str(bufp, uname, &fc->params.tattach.uname);
644 p9_put_str(bufp, aname, &fc->params.tattach.aname);
646 p9_put_int32(bufp, n_uname, &fc->params.tattach.n_uname);
651 EXPORT_SYMBOL(p9_create_tattach);
654 * p9_create_tflush - allocates and creates a T_FLUSH request
655 * @oldtag: tag id for the transaction we are attempting to cancel
659 struct p9_fcall *p9_create_tflush(u16 oldtag)
664 struct cbuf *bufp = &buffer;
666 size = 2; /* oldtag[2] */
667 fc = p9_create_common(bufp, size, P9_TFLUSH);
671 p9_put_int16(bufp, oldtag, &fc->params.tflush.oldtag);
673 if (buf_check_overflow(bufp)) {
675 fc = ERR_PTR(-ENOMEM);
680 EXPORT_SYMBOL(p9_create_tflush);
683 * p9_create_twalk - allocates and creates a T_FLUSH request
684 * @fid: handle we are traversing from
685 * @newfid: a new handle for this transaction
686 * @nwname: number of path elements to traverse
687 * @wnames: array of path elements
691 struct p9_fcall *p9_create_twalk(u32 fid, u32 newfid, u16 nwname,
697 struct cbuf *bufp = &buffer;
699 if (nwname > P9_MAXWELEM) {
700 P9_DPRINTK(P9_DEBUG_ERROR, "nwname > %d\n", P9_MAXWELEM);
704 size = 4 + 4 + 2; /* fid[4] newfid[4] nwname[2] ... */
705 for (i = 0; i < nwname; i++) {
706 size += 2 + strlen(wnames[i]); /* wname[s] */
709 fc = p9_create_common(bufp, size, P9_TWALK);
713 p9_put_int32(bufp, fid, &fc->params.twalk.fid);
714 p9_put_int32(bufp, newfid, &fc->params.twalk.newfid);
715 p9_put_int16(bufp, nwname, &fc->params.twalk.nwname);
716 for (i = 0; i < nwname; i++) {
717 p9_put_str(bufp, wnames[i], &fc->params.twalk.wnames[i]);
720 if (buf_check_overflow(bufp)) {
722 fc = ERR_PTR(-ENOMEM);
727 EXPORT_SYMBOL(p9_create_twalk);
730 * p9_create_topen - allocates and creates a T_OPEN request
731 * @fid: handle we are trying to open
732 * @mode: what mode we are trying to open the file in
736 struct p9_fcall *p9_create_topen(u32 fid, u8 mode)
741 struct cbuf *bufp = &buffer;
743 size = 4 + 1; /* fid[4] mode[1] */
744 fc = p9_create_common(bufp, size, P9_TOPEN);
748 p9_put_int32(bufp, fid, &fc->params.topen.fid);
749 p9_put_int8(bufp, mode, &fc->params.topen.mode);
751 if (buf_check_overflow(bufp)) {
753 fc = ERR_PTR(-ENOMEM);
758 EXPORT_SYMBOL(p9_create_topen);
761 * p9_create_tcreate - allocates and creates a T_CREATE request
762 * @fid: handle of directory we are trying to create in
763 * @name: name of the file we are trying to create
764 * @perm: permissions for the file we are trying to create
765 * @mode: what mode we are trying to open the file in
766 * @extension: 9p2000.u extension string (for special files)
767 * @dotu: 9p2000.u enabled flag
769 * Note: Plan 9 create semantics include opening the resulting file
770 * which is why mode is included.
773 struct p9_fcall *p9_create_tcreate(u32 fid, char *name, u32 perm, u8 mode,
774 char *extension, int dotu)
779 struct cbuf *bufp = &buffer;
781 /* fid[4] name[s] perm[4] mode[1] */
782 size = 4 + 2 + strlen(name) + 4 + 1;
784 size += 2 + /* extension[s] */
785 (extension == NULL ? 0 : strlen(extension));
788 fc = p9_create_common(bufp, size, P9_TCREATE);
792 p9_put_int32(bufp, fid, &fc->params.tcreate.fid);
793 p9_put_str(bufp, name, &fc->params.tcreate.name);
794 p9_put_int32(bufp, perm, &fc->params.tcreate.perm);
795 p9_put_int8(bufp, mode, &fc->params.tcreate.mode);
797 p9_put_str(bufp, extension, &fc->params.tcreate.extension);
799 if (buf_check_overflow(bufp)) {
801 fc = ERR_PTR(-ENOMEM);
806 EXPORT_SYMBOL(p9_create_tcreate);
809 * p9_create_tread - allocates and creates a T_READ request
810 * @fid: handle of the file we are trying to read
811 * @offset: offset to start reading from
812 * @count: how many bytes to read
815 struct p9_fcall *p9_create_tread(u32 fid, u64 offset, u32 count)
820 struct cbuf *bufp = &buffer;
822 size = 4 + 8 + 4; /* fid[4] offset[8] count[4] */
823 fc = p9_create_common(bufp, size, P9_TREAD);
827 p9_put_int32(bufp, fid, &fc->params.tread.fid);
828 p9_put_int64(bufp, offset, &fc->params.tread.offset);
829 p9_put_int32(bufp, count, &fc->params.tread.count);
831 if (buf_check_overflow(bufp)) {
833 fc = ERR_PTR(-ENOMEM);
838 EXPORT_SYMBOL(p9_create_tread);
841 * p9_create_twrite - allocates and creates a T_WRITE request from the kernel
842 * @fid: handle of the file we are trying to write
843 * @offset: offset to start writing at
844 * @count: how many bytes to write
845 * @data: data to write
847 * This function will create a requst with data buffers from the kernel
848 * such as the page cache.
851 struct p9_fcall *p9_create_twrite(u32 fid, u64 offset, u32 count,
857 struct cbuf *bufp = &buffer;
859 /* fid[4] offset[8] count[4] data[count] */
860 size = 4 + 8 + 4 + count;
861 fc = p9_create_common(bufp, size, P9_TWRITE);
865 p9_put_int32(bufp, fid, &fc->params.twrite.fid);
866 p9_put_int64(bufp, offset, &fc->params.twrite.offset);
867 p9_put_int32(bufp, count, &fc->params.twrite.count);
868 err = p9_put_data(bufp, data, count, &fc->params.twrite.data);
875 if (buf_check_overflow(bufp)) {
877 fc = ERR_PTR(-ENOMEM);
882 EXPORT_SYMBOL(p9_create_twrite);
885 * p9_create_twrite_u - allocates and creates a T_WRITE request from userspace
886 * @fid: handle of the file we are trying to write
887 * @offset: offset to start writing at
888 * @count: how many bytes to write
889 * @data: data to write
891 * This function will create a request with data buffers from userspace
894 struct p9_fcall *p9_create_twrite_u(u32 fid, u64 offset, u32 count,
895 const char __user *data)
900 struct cbuf *bufp = &buffer;
902 /* fid[4] offset[8] count[4] data[count] */
903 size = 4 + 8 + 4 + count;
904 fc = p9_create_common(bufp, size, P9_TWRITE);
908 p9_put_int32(bufp, fid, &fc->params.twrite.fid);
909 p9_put_int64(bufp, offset, &fc->params.twrite.offset);
910 p9_put_int32(bufp, count, &fc->params.twrite.count);
911 err = p9_put_user_data(bufp, data, count, &fc->params.twrite.data);
918 if (buf_check_overflow(bufp)) {
920 fc = ERR_PTR(-ENOMEM);
925 EXPORT_SYMBOL(p9_create_twrite_u);
928 * p9_create_tclunk - allocate a request to forget about a file handle
929 * @fid: handle of the file we closing or forgetting about
931 * clunk is used both to close open files and to discard transient handles
932 * which may be created during meta-data operations and hierarchy traversal.
935 struct p9_fcall *p9_create_tclunk(u32 fid)
940 struct cbuf *bufp = &buffer;
942 size = 4; /* fid[4] */
943 fc = p9_create_common(bufp, size, P9_TCLUNK);
947 p9_put_int32(bufp, fid, &fc->params.tclunk.fid);
949 if (buf_check_overflow(bufp)) {
951 fc = ERR_PTR(-ENOMEM);
956 EXPORT_SYMBOL(p9_create_tclunk);
959 * p9_create_tremove - allocate and create a request to remove a file
960 * @fid: handle of the file or directory we are removing
964 struct p9_fcall *p9_create_tremove(u32 fid)
969 struct cbuf *bufp = &buffer;
971 size = 4; /* fid[4] */
972 fc = p9_create_common(bufp, size, P9_TREMOVE);
976 p9_put_int32(bufp, fid, &fc->params.tremove.fid);
978 if (buf_check_overflow(bufp)) {
980 fc = ERR_PTR(-ENOMEM);
985 EXPORT_SYMBOL(p9_create_tremove);
988 * p9_create_tstat - allocate and populate a request for attributes
989 * @fid: handle of the file or directory we are trying to get the attributes of
993 struct p9_fcall *p9_create_tstat(u32 fid)
998 struct cbuf *bufp = &buffer;
1000 size = 4; /* fid[4] */
1001 fc = p9_create_common(bufp, size, P9_TSTAT);
1005 p9_put_int32(bufp, fid, &fc->params.tstat.fid);
1007 if (buf_check_overflow(bufp)) {
1009 fc = ERR_PTR(-ENOMEM);
1014 EXPORT_SYMBOL(p9_create_tstat);
1017 * p9_create_tstat - allocate and populate a request to change attributes
1018 * @fid: handle of the file or directory we are trying to change
1019 * @wstat: &p9_stat structure with attributes we wish to set
1020 * @dotu: 9p2000.u enabled flag
1024 struct p9_fcall *p9_create_twstat(u32 fid, struct p9_wstat *wstat,
1028 struct p9_fcall *fc;
1030 struct cbuf *bufp = &buffer;
1032 statsz = p9_size_wstat(wstat, dotu);
1033 size = 4 + 2 + 2 + statsz; /* fid[4] stat[n] */
1034 fc = p9_create_common(bufp, size, P9_TWSTAT);
1038 p9_put_int32(bufp, fid, &fc->params.twstat.fid);
1039 buf_put_int16(bufp, statsz + 2);
1040 p9_put_wstat(bufp, wstat, &fc->params.twstat.stat, statsz, dotu);
1042 if (buf_check_overflow(bufp)) {
1044 fc = ERR_PTR(-ENOMEM);
1049 EXPORT_SYMBOL(p9_create_twstat);