1*0a6a1f1dSLionel Sambuc /* $NetBSD: puffs_compat.c,v 1.4 2015/04/22 17:07:24 pooka Exp $ */
284d9c625SLionel Sambuc
384d9c625SLionel Sambuc /*
484d9c625SLionel Sambuc * Copyright (c) 2010 Antti Kantee. All Rights Reserved.
584d9c625SLionel Sambuc *
684d9c625SLionel Sambuc * Redistribution and use in source and binary forms, with or without
784d9c625SLionel Sambuc * modification, are permitted provided that the following conditions
884d9c625SLionel Sambuc * are met:
984d9c625SLionel Sambuc * 1. Redistributions of source code must retain the above copyright
1084d9c625SLionel Sambuc * notice, this list of conditions and the following disclaimer.
1184d9c625SLionel Sambuc * 2. Redistributions in binary form must reproduce the above copyright
1284d9c625SLionel Sambuc * notice, this list of conditions and the following disclaimer in the
1384d9c625SLionel Sambuc * documentation and/or other materials provided with the distribution.
1484d9c625SLionel Sambuc *
1584d9c625SLionel Sambuc * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
1684d9c625SLionel Sambuc * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
1784d9c625SLionel Sambuc * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
1884d9c625SLionel Sambuc * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
1984d9c625SLionel Sambuc * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2084d9c625SLionel Sambuc * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
2184d9c625SLionel Sambuc * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2284d9c625SLionel Sambuc * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2384d9c625SLionel Sambuc * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2484d9c625SLionel Sambuc * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2584d9c625SLionel Sambuc * SUCH DAMAGE.
2684d9c625SLionel Sambuc */
2784d9c625SLionel Sambuc
2884d9c625SLionel Sambuc /*
2984d9c625SLionel Sambuc * This file handles puffs PDUs so that they are compatible between
3084d9c625SLionel Sambuc * 32bit<->64bit time_t/dev_t. It enables running a -current kernel
3184d9c625SLionel Sambuc * against a 5.0 userland (assuming the protocol otherwise matches!).
3284d9c625SLionel Sambuc */
3384d9c625SLionel Sambuc
3484d9c625SLionel Sambuc #include <sys/cdefs.h>
35*0a6a1f1dSLionel Sambuc __KERNEL_RCSID(0, "$NetBSD: puffs_compat.c,v 1.4 2015/04/22 17:07:24 pooka Exp $");
3684d9c625SLionel Sambuc
3784d9c625SLionel Sambuc #include <sys/param.h>
3884d9c625SLionel Sambuc #include <sys/atomic.h>
3984d9c625SLionel Sambuc #include <sys/kmem.h>
4084d9c625SLionel Sambuc #include <sys/kthread.h>
4184d9c625SLionel Sambuc #include <sys/lock.h>
4284d9c625SLionel Sambuc #include <sys/mount.h>
4384d9c625SLionel Sambuc #include <sys/namei.h>
4484d9c625SLionel Sambuc #include <sys/proc.h>
4584d9c625SLionel Sambuc #include <sys/vnode.h>
4684d9c625SLionel Sambuc #include <sys/atomic.h>
4784d9c625SLionel Sambuc
4884d9c625SLionel Sambuc #include <dev/putter/putter_sys.h>
4984d9c625SLionel Sambuc
5084d9c625SLionel Sambuc #include <fs/puffs/puffs_msgif.h>
5184d9c625SLionel Sambuc #include <fs/puffs/puffs_sys.h>
5284d9c625SLionel Sambuc
5384d9c625SLionel Sambuc #include <compat/sys/time.h>
5484d9c625SLionel Sambuc
5584d9c625SLionel Sambuc /*
5684d9c625SLionel Sambuc * compat types
5784d9c625SLionel Sambuc */
5884d9c625SLionel Sambuc struct vattr50 {
5984d9c625SLionel Sambuc enum vtype va_type;
6084d9c625SLionel Sambuc mode_t va_mode;
6184d9c625SLionel Sambuc nlink_t va_nlink;
6284d9c625SLionel Sambuc uid_t va_uid;
6384d9c625SLionel Sambuc gid_t va_gid;
6484d9c625SLionel Sambuc uint32_t va_fsid;
6584d9c625SLionel Sambuc ino_t va_fileid;
6684d9c625SLionel Sambuc u_quad_t va_size;
6784d9c625SLionel Sambuc long va_blocksize;
6884d9c625SLionel Sambuc struct timespec50 va_atime;
6984d9c625SLionel Sambuc struct timespec50 va_mtime;
7084d9c625SLionel Sambuc struct timespec50 va_ctime;
7184d9c625SLionel Sambuc struct timespec50 va_birthtime;
7284d9c625SLionel Sambuc u_long va_gen;
7384d9c625SLionel Sambuc u_long va_flags;
7484d9c625SLionel Sambuc uint32_t va_rdev;
7584d9c625SLionel Sambuc u_quad_t va_bytes;
7684d9c625SLionel Sambuc u_quad_t va_filerev;
7784d9c625SLionel Sambuc u_int va_vaflags;
7884d9c625SLionel Sambuc long va_spare;
7984d9c625SLionel Sambuc };
8084d9c625SLionel Sambuc
8184d9c625SLionel Sambuc struct puffs50_vfsmsg_fhtonode {
8284d9c625SLionel Sambuc struct puffs_req pvfsr_pr;
8384d9c625SLionel Sambuc
8484d9c625SLionel Sambuc void *pvfsr_fhcookie; /* IN */
8584d9c625SLionel Sambuc enum vtype pvfsr_vtype; /* IN */
8684d9c625SLionel Sambuc voff_t pvfsr_size; /* IN */
8784d9c625SLionel Sambuc uint32_t pvfsr_rdev; /* IN */
8884d9c625SLionel Sambuc
8984d9c625SLionel Sambuc size_t pvfsr_dsize; /* OUT */
9084d9c625SLionel Sambuc uint8_t pvfsr_data[0] /* OUT, XXX */
9184d9c625SLionel Sambuc __aligned(ALIGNBYTES+1);
9284d9c625SLionel Sambuc };
9384d9c625SLionel Sambuc
9484d9c625SLionel Sambuc struct puffs50_vnmsg_lookup {
9584d9c625SLionel Sambuc struct puffs_req pvn_pr;
9684d9c625SLionel Sambuc
9784d9c625SLionel Sambuc struct puffs_kcn pvnr_cn; /* OUT */
9884d9c625SLionel Sambuc struct puffs_kcred pvnr_cn_cred; /* OUT */
9984d9c625SLionel Sambuc
10084d9c625SLionel Sambuc puffs_cookie_t pvnr_newnode; /* IN */
10184d9c625SLionel Sambuc enum vtype pvnr_vtype; /* IN */
10284d9c625SLionel Sambuc voff_t pvnr_size; /* IN */
10384d9c625SLionel Sambuc uint32_t pvnr_rdev; /* IN */
10484d9c625SLionel Sambuc };
10584d9c625SLionel Sambuc
10684d9c625SLionel Sambuc struct puffs50_vnmsg_create {
10784d9c625SLionel Sambuc struct puffs_req pvn_pr;
10884d9c625SLionel Sambuc
10984d9c625SLionel Sambuc struct puffs_kcn pvnr_cn; /* OUT */
11084d9c625SLionel Sambuc struct puffs_kcred pvnr_cn_cred; /* OUT */
11184d9c625SLionel Sambuc
11284d9c625SLionel Sambuc struct vattr50 pvnr_va; /* OUT */
11384d9c625SLionel Sambuc puffs_cookie_t pvnr_newnode; /* IN */
11484d9c625SLionel Sambuc };
11584d9c625SLionel Sambuc
11684d9c625SLionel Sambuc struct puffs50_vnmsg_mknod {
11784d9c625SLionel Sambuc struct puffs_req pvn_pr;
11884d9c625SLionel Sambuc
11984d9c625SLionel Sambuc struct puffs_kcn pvnr_cn; /* OUT */
12084d9c625SLionel Sambuc struct puffs_kcred pvnr_cn_cred; /* OUT */
12184d9c625SLionel Sambuc
12284d9c625SLionel Sambuc struct vattr50 pvnr_va; /* OUT */
12384d9c625SLionel Sambuc puffs_cookie_t pvnr_newnode; /* IN */
12484d9c625SLionel Sambuc };
12584d9c625SLionel Sambuc
12684d9c625SLionel Sambuc #define puffs50_vnmsg_setattr puffs50_vnmsg_setgetattr
12784d9c625SLionel Sambuc #define puffs50_vnmsg_getattr puffs50_vnmsg_setgetattr
12884d9c625SLionel Sambuc struct puffs50_vnmsg_setgetattr {
12984d9c625SLionel Sambuc struct puffs_req pvn_pr;
13084d9c625SLionel Sambuc
13184d9c625SLionel Sambuc struct puffs_kcred pvnr_cred; /* OUT */
13284d9c625SLionel Sambuc struct vattr50 pvnr_va; /* IN/OUT (op depend) */
13384d9c625SLionel Sambuc };
13484d9c625SLionel Sambuc
13584d9c625SLionel Sambuc struct puffs50_vnmsg_mkdir {
13684d9c625SLionel Sambuc struct puffs_req pvn_pr;
13784d9c625SLionel Sambuc
13884d9c625SLionel Sambuc struct puffs_kcn pvnr_cn; /* OUT */
13984d9c625SLionel Sambuc struct puffs_kcred pvnr_cn_cred; /* OUT */
14084d9c625SLionel Sambuc
14184d9c625SLionel Sambuc struct vattr50 pvnr_va; /* OUT */
14284d9c625SLionel Sambuc puffs_cookie_t pvnr_newnode; /* IN */
14384d9c625SLionel Sambuc };
14484d9c625SLionel Sambuc
14584d9c625SLionel Sambuc struct puffs50_vnmsg_symlink {
14684d9c625SLionel Sambuc struct puffs_req pvn_pr;
14784d9c625SLionel Sambuc
14884d9c625SLionel Sambuc struct puffs_kcn pvnr_cn; /* OUT */
14984d9c625SLionel Sambuc struct puffs_kcred pvnr_cn_cred; /* OUT */
15084d9c625SLionel Sambuc
15184d9c625SLionel Sambuc struct vattr50 pvnr_va; /* OUT */
15284d9c625SLionel Sambuc puffs_cookie_t pvnr_newnode; /* IN */
15384d9c625SLionel Sambuc char pvnr_link[MAXPATHLEN]; /* OUT */
15484d9c625SLionel Sambuc };
15584d9c625SLionel Sambuc
15684d9c625SLionel Sambuc /*
15784d9c625SLionel Sambuc * vattr translation routines
15884d9c625SLionel Sambuc */
15984d9c625SLionel Sambuc
160*0a6a1f1dSLionel Sambuc #ifdef COMPAT_50
16184d9c625SLionel Sambuc static void
vattr_to_50(const struct vattr * va,struct vattr50 * va50)16284d9c625SLionel Sambuc vattr_to_50(const struct vattr *va, struct vattr50 *va50)
16384d9c625SLionel Sambuc {
16484d9c625SLionel Sambuc
16584d9c625SLionel Sambuc va50->va_type = va->va_type;
16684d9c625SLionel Sambuc va50->va_mode = va->va_mode;
16784d9c625SLionel Sambuc va50->va_nlink = va->va_nlink;
16884d9c625SLionel Sambuc va50->va_uid = va->va_uid;
16984d9c625SLionel Sambuc va50->va_gid = va->va_gid;
17084d9c625SLionel Sambuc va50->va_fsid = (uint64_t)va->va_fsid;
17184d9c625SLionel Sambuc va50->va_fileid = va->va_fileid;
17284d9c625SLionel Sambuc va50->va_size = va->va_size;
17384d9c625SLionel Sambuc va50->va_blocksize = va->va_blocksize;
17484d9c625SLionel Sambuc timespec_to_timespec50(&va->va_atime, &va50->va_atime);
17584d9c625SLionel Sambuc timespec_to_timespec50(&va->va_ctime, &va50->va_ctime);
17684d9c625SLionel Sambuc timespec_to_timespec50(&va->va_mtime, &va50->va_mtime);
17784d9c625SLionel Sambuc timespec_to_timespec50(&va->va_birthtime, &va50->va_birthtime);
17884d9c625SLionel Sambuc va50->va_gen = va->va_gen;
17984d9c625SLionel Sambuc va50->va_flags = va->va_flags;
18084d9c625SLionel Sambuc va50->va_rdev = (int32_t)va->va_rdev;
18184d9c625SLionel Sambuc va50->va_bytes = va->va_bytes;
18284d9c625SLionel Sambuc va50->va_filerev = va->va_filerev;
18384d9c625SLionel Sambuc va50->va_vaflags = va->va_flags;
18484d9c625SLionel Sambuc }
18584d9c625SLionel Sambuc
18684d9c625SLionel Sambuc static void
vattr_from_50(const struct vattr50 * va50,struct vattr * va)18784d9c625SLionel Sambuc vattr_from_50(const struct vattr50 *va50, struct vattr *va)
18884d9c625SLionel Sambuc {
18984d9c625SLionel Sambuc
19084d9c625SLionel Sambuc va->va_type = va50->va_type;
19184d9c625SLionel Sambuc va->va_mode = va50->va_mode;
19284d9c625SLionel Sambuc va->va_nlink = va50->va_nlink;
19384d9c625SLionel Sambuc va->va_uid = va50->va_uid;
19484d9c625SLionel Sambuc va->va_gid = va50->va_gid;
19584d9c625SLionel Sambuc va->va_fsid = (uint32_t)va50->va_fsid;
19684d9c625SLionel Sambuc va->va_fileid = va50->va_fileid;
19784d9c625SLionel Sambuc va->va_size = va50->va_size;
19884d9c625SLionel Sambuc va->va_blocksize = va50->va_blocksize;
19984d9c625SLionel Sambuc timespec50_to_timespec(&va50->va_atime, &va->va_atime);
20084d9c625SLionel Sambuc timespec50_to_timespec(&va50->va_ctime, &va->va_ctime);
20184d9c625SLionel Sambuc timespec50_to_timespec(&va50->va_mtime, &va->va_mtime);
20284d9c625SLionel Sambuc timespec50_to_timespec(&va50->va_birthtime, &va->va_birthtime);
20384d9c625SLionel Sambuc va->va_gen = va50->va_gen;
20484d9c625SLionel Sambuc va->va_flags = va50->va_flags;
20584d9c625SLionel Sambuc va->va_rdev = (uint32_t)va50->va_rdev;
20684d9c625SLionel Sambuc va->va_bytes = va50->va_bytes;
20784d9c625SLionel Sambuc va->va_filerev = va50->va_filerev;
20884d9c625SLionel Sambuc va->va_vaflags = va50->va_flags;
20984d9c625SLionel Sambuc }
210*0a6a1f1dSLionel Sambuc #endif /* COMPAT_50 */
21184d9c625SLionel Sambuc
21284d9c625SLionel Sambuc /*
21384d9c625SLionel Sambuc * XXX: cannot assert that sleeping is possible
21484d9c625SLionel Sambuc * (this always a valid assumption for now)
21584d9c625SLionel Sambuc */
21684d9c625SLionel Sambuc #define INIT(name, extra) \
21784d9c625SLionel Sambuc struct puffs50_##name *cmsg; \
21884d9c625SLionel Sambuc struct puffs_##name *omsg; \
21984d9c625SLionel Sambuc creq =kmem_zalloc(sizeof(struct puffs50_##name)+extra,KM_SLEEP);\
22084d9c625SLionel Sambuc cmsg = (struct puffs50_##name *)creq; \
22184d9c625SLionel Sambuc omsg = (struct puffs_##name *)oreq; \
22284d9c625SLionel Sambuc delta = sizeof(struct puffs50_##name)-sizeof(struct puffs_##name);
22384d9c625SLionel Sambuc #define ASSIGN(field) \
22484d9c625SLionel Sambuc cmsg->field = omsg->field;
22584d9c625SLionel Sambuc
22684d9c625SLionel Sambuc bool
puffs_compat_outgoing(struct puffs_req * oreq,struct puffs_req ** creqp,ssize_t * deltap)22784d9c625SLionel Sambuc puffs_compat_outgoing(struct puffs_req *oreq,
22884d9c625SLionel Sambuc struct puffs_req **creqp, ssize_t *deltap)
22984d9c625SLionel Sambuc {
230*0a6a1f1dSLionel Sambuc bool rv = false;
231*0a6a1f1dSLionel Sambuc #ifdef COMPAT_50
23284d9c625SLionel Sambuc struct puffs_req *creq = NULL;
23384d9c625SLionel Sambuc ssize_t delta = 0;
23484d9c625SLionel Sambuc
23584d9c625SLionel Sambuc if (PUFFSOP_OPCLASS(oreq->preq_opclass) == PUFFSOP_VFS
23684d9c625SLionel Sambuc && oreq->preq_optype == PUFFS_VFS_FHTOVP) {
23784d9c625SLionel Sambuc INIT(vfsmsg_fhtonode,
23884d9c625SLionel Sambuc ((struct puffs_vfsmsg_fhtonode *)oreq)->pvfsr_dsize);
23984d9c625SLionel Sambuc
24084d9c625SLionel Sambuc ASSIGN(pvfsr_pr);
24184d9c625SLionel Sambuc ASSIGN(pvfsr_dsize);
24284d9c625SLionel Sambuc memcpy(cmsg->pvfsr_data, omsg->pvfsr_data, cmsg->pvfsr_dsize);
24384d9c625SLionel Sambuc } else if (PUFFSOP_OPCLASS(oreq->preq_opclass) == PUFFSOP_VN) {
24484d9c625SLionel Sambuc switch (oreq->preq_optype) {
24584d9c625SLionel Sambuc case PUFFS_VN_LOOKUP:
24684d9c625SLionel Sambuc {
24784d9c625SLionel Sambuc INIT(vnmsg_lookup, 0);
24884d9c625SLionel Sambuc
24984d9c625SLionel Sambuc ASSIGN(pvn_pr);
25084d9c625SLionel Sambuc ASSIGN(pvnr_cn);
25184d9c625SLionel Sambuc ASSIGN(pvnr_cn_cred);
25284d9c625SLionel Sambuc
25384d9c625SLionel Sambuc break;
25484d9c625SLionel Sambuc }
25584d9c625SLionel Sambuc
25684d9c625SLionel Sambuc case PUFFS_VN_CREATE:
25784d9c625SLionel Sambuc {
25884d9c625SLionel Sambuc INIT(vnmsg_create, 0);
25984d9c625SLionel Sambuc
26084d9c625SLionel Sambuc ASSIGN(pvn_pr);
26184d9c625SLionel Sambuc ASSIGN(pvnr_cn);
26284d9c625SLionel Sambuc ASSIGN(pvnr_cn_cred);
26384d9c625SLionel Sambuc vattr_to_50(&omsg->pvnr_va, &cmsg->pvnr_va);
26484d9c625SLionel Sambuc
26584d9c625SLionel Sambuc break;
26684d9c625SLionel Sambuc }
26784d9c625SLionel Sambuc
26884d9c625SLionel Sambuc case PUFFS_VN_MKNOD:
26984d9c625SLionel Sambuc {
27084d9c625SLionel Sambuc INIT(vnmsg_mknod, 0);
27184d9c625SLionel Sambuc
27284d9c625SLionel Sambuc ASSIGN(pvn_pr);
27384d9c625SLionel Sambuc ASSIGN(pvnr_cn);
27484d9c625SLionel Sambuc ASSIGN(pvnr_cn_cred);
27584d9c625SLionel Sambuc vattr_to_50(&omsg->pvnr_va, &cmsg->pvnr_va);
27684d9c625SLionel Sambuc
27784d9c625SLionel Sambuc break;
27884d9c625SLionel Sambuc }
27984d9c625SLionel Sambuc
28084d9c625SLionel Sambuc case PUFFS_VN_MKDIR:
28184d9c625SLionel Sambuc {
28284d9c625SLionel Sambuc INIT(vnmsg_mkdir, 0);
28384d9c625SLionel Sambuc
28484d9c625SLionel Sambuc ASSIGN(pvn_pr);
28584d9c625SLionel Sambuc ASSIGN(pvnr_cn);
28684d9c625SLionel Sambuc ASSIGN(pvnr_cn_cred);
28784d9c625SLionel Sambuc vattr_to_50(&omsg->pvnr_va, &cmsg->pvnr_va);
28884d9c625SLionel Sambuc
28984d9c625SLionel Sambuc break;
29084d9c625SLionel Sambuc }
29184d9c625SLionel Sambuc
29284d9c625SLionel Sambuc case PUFFS_VN_SYMLINK:
29384d9c625SLionel Sambuc {
29484d9c625SLionel Sambuc INIT(vnmsg_symlink, 0);
29584d9c625SLionel Sambuc
29684d9c625SLionel Sambuc ASSIGN(pvn_pr);
29784d9c625SLionel Sambuc ASSIGN(pvnr_cn);
29884d9c625SLionel Sambuc ASSIGN(pvnr_cn_cred);
29984d9c625SLionel Sambuc vattr_to_50(&omsg->pvnr_va, &cmsg->pvnr_va);
30084d9c625SLionel Sambuc memcpy(cmsg->pvnr_link, omsg->pvnr_link,
30184d9c625SLionel Sambuc sizeof(cmsg->pvnr_link));
30284d9c625SLionel Sambuc
30384d9c625SLionel Sambuc break;
30484d9c625SLionel Sambuc }
30584d9c625SLionel Sambuc
30684d9c625SLionel Sambuc case PUFFS_VN_SETATTR:
30784d9c625SLionel Sambuc {
30884d9c625SLionel Sambuc INIT(vnmsg_setattr, 0);
30984d9c625SLionel Sambuc
31084d9c625SLionel Sambuc ASSIGN(pvn_pr);
31184d9c625SLionel Sambuc ASSIGN(pvnr_cred);
31284d9c625SLionel Sambuc vattr_to_50(&omsg->pvnr_va, &cmsg->pvnr_va);
31384d9c625SLionel Sambuc
31484d9c625SLionel Sambuc break;
31584d9c625SLionel Sambuc }
31684d9c625SLionel Sambuc case PUFFS_VN_GETATTR:
31784d9c625SLionel Sambuc {
31884d9c625SLionel Sambuc INIT(vnmsg_getattr, 0);
31984d9c625SLionel Sambuc
32084d9c625SLionel Sambuc ASSIGN(pvn_pr);
32184d9c625SLionel Sambuc ASSIGN(pvnr_cred);
32284d9c625SLionel Sambuc
32384d9c625SLionel Sambuc break;
32484d9c625SLionel Sambuc }
32584d9c625SLionel Sambuc
32684d9c625SLionel Sambuc default:
32784d9c625SLionel Sambuc break;
32884d9c625SLionel Sambuc }
32984d9c625SLionel Sambuc }
33084d9c625SLionel Sambuc
33184d9c625SLionel Sambuc if (creq) {
33284d9c625SLionel Sambuc *creqp = creq;
33384d9c625SLionel Sambuc *deltap = delta;
33484d9c625SLionel Sambuc rv = true;
33584d9c625SLionel Sambuc }
336*0a6a1f1dSLionel Sambuc #endif
33784d9c625SLionel Sambuc
33884d9c625SLionel Sambuc return rv;
33984d9c625SLionel Sambuc }
34084d9c625SLionel Sambuc #undef INIT
34184d9c625SLionel Sambuc #undef ASSIGN
34284d9c625SLionel Sambuc
34384d9c625SLionel Sambuc #define INIT(name) \
34484d9c625SLionel Sambuc struct puffs50_##name *cmsg = (void *)preq; \
34584d9c625SLionel Sambuc struct puffs_##name *omsg = (void *)creq;
34684d9c625SLionel Sambuc #define ASSIGN(field) \
34784d9c625SLionel Sambuc omsg->field = cmsg->field;
34884d9c625SLionel Sambuc
34984d9c625SLionel Sambuc void
puffs_compat_incoming(struct puffs_req * preq,struct puffs_req * creq)35084d9c625SLionel Sambuc puffs_compat_incoming(struct puffs_req *preq, struct puffs_req *creq)
35184d9c625SLionel Sambuc {
35284d9c625SLionel Sambuc
353*0a6a1f1dSLionel Sambuc #ifdef COMPAT_50
35484d9c625SLionel Sambuc if (PUFFSOP_OPCLASS(preq->preq_opclass) == PUFFSOP_VFS
35584d9c625SLionel Sambuc && preq->preq_optype == PUFFS_VFS_FHTOVP) {
35684d9c625SLionel Sambuc INIT(vfsmsg_fhtonode);
35784d9c625SLionel Sambuc
35884d9c625SLionel Sambuc ASSIGN(pvfsr_pr);
35984d9c625SLionel Sambuc
36084d9c625SLionel Sambuc ASSIGN(pvfsr_fhcookie);
36184d9c625SLionel Sambuc ASSIGN(pvfsr_vtype);
36284d9c625SLionel Sambuc ASSIGN(pvfsr_size);
36384d9c625SLionel Sambuc ASSIGN(pvfsr_rdev);
36484d9c625SLionel Sambuc } else if (PUFFSOP_OPCLASS(preq->preq_opclass) == PUFFSOP_VN) {
36584d9c625SLionel Sambuc switch (preq->preq_optype) {
36684d9c625SLionel Sambuc case PUFFS_VN_LOOKUP:
36784d9c625SLionel Sambuc {
36884d9c625SLionel Sambuc INIT(vnmsg_lookup);
36984d9c625SLionel Sambuc
37084d9c625SLionel Sambuc ASSIGN(pvn_pr);
37184d9c625SLionel Sambuc ASSIGN(pvnr_newnode);
37284d9c625SLionel Sambuc ASSIGN(pvnr_vtype);
37384d9c625SLionel Sambuc ASSIGN(pvnr_size);
37484d9c625SLionel Sambuc ASSIGN(pvnr_rdev);
37584d9c625SLionel Sambuc
37684d9c625SLionel Sambuc break;
37784d9c625SLionel Sambuc }
37884d9c625SLionel Sambuc
37984d9c625SLionel Sambuc case PUFFS_VN_CREATE:
38084d9c625SLionel Sambuc {
38184d9c625SLionel Sambuc INIT(vnmsg_create);
38284d9c625SLionel Sambuc
38384d9c625SLionel Sambuc ASSIGN(pvn_pr);
38484d9c625SLionel Sambuc ASSIGN(pvnr_newnode);
38584d9c625SLionel Sambuc
38684d9c625SLionel Sambuc break;
38784d9c625SLionel Sambuc }
38884d9c625SLionel Sambuc
38984d9c625SLionel Sambuc case PUFFS_VN_MKNOD:
39084d9c625SLionel Sambuc {
39184d9c625SLionel Sambuc INIT(vnmsg_mknod);
39284d9c625SLionel Sambuc
39384d9c625SLionel Sambuc ASSIGN(pvn_pr);
39484d9c625SLionel Sambuc ASSIGN(pvnr_newnode);
39584d9c625SLionel Sambuc
39684d9c625SLionel Sambuc break;
39784d9c625SLionel Sambuc }
39884d9c625SLionel Sambuc
39984d9c625SLionel Sambuc case PUFFS_VN_MKDIR:
40084d9c625SLionel Sambuc {
40184d9c625SLionel Sambuc INIT(vnmsg_mkdir);
40284d9c625SLionel Sambuc
40384d9c625SLionel Sambuc ASSIGN(pvn_pr);
40484d9c625SLionel Sambuc ASSIGN(pvnr_newnode);
40584d9c625SLionel Sambuc
40684d9c625SLionel Sambuc break;
40784d9c625SLionel Sambuc }
40884d9c625SLionel Sambuc
40984d9c625SLionel Sambuc case PUFFS_VN_SYMLINK:
41084d9c625SLionel Sambuc {
41184d9c625SLionel Sambuc INIT(vnmsg_symlink);
41284d9c625SLionel Sambuc
41384d9c625SLionel Sambuc ASSIGN(pvn_pr);
41484d9c625SLionel Sambuc ASSIGN(pvnr_newnode);
41584d9c625SLionel Sambuc
41684d9c625SLionel Sambuc break;
41784d9c625SLionel Sambuc }
41884d9c625SLionel Sambuc
41984d9c625SLionel Sambuc case PUFFS_VN_SETATTR:
42084d9c625SLionel Sambuc {
42184d9c625SLionel Sambuc INIT(vnmsg_setattr);
42284d9c625SLionel Sambuc
42384d9c625SLionel Sambuc ASSIGN(pvn_pr);
42484d9c625SLionel Sambuc
42584d9c625SLionel Sambuc break;
42684d9c625SLionel Sambuc }
42784d9c625SLionel Sambuc case PUFFS_VN_GETATTR:
42884d9c625SLionel Sambuc {
42984d9c625SLionel Sambuc INIT(vnmsg_getattr);
43084d9c625SLionel Sambuc
43184d9c625SLionel Sambuc ASSIGN(pvn_pr);
43284d9c625SLionel Sambuc vattr_from_50(&cmsg->pvnr_va, &omsg->pvnr_va);
43384d9c625SLionel Sambuc
43484d9c625SLionel Sambuc break;
43584d9c625SLionel Sambuc }
43684d9c625SLionel Sambuc
43784d9c625SLionel Sambuc default:
43884d9c625SLionel Sambuc panic("puffs compat ops come in pairs");
43984d9c625SLionel Sambuc }
44084d9c625SLionel Sambuc }
441*0a6a1f1dSLionel Sambuc #endif /* COMPAT_50 */
44284d9c625SLionel Sambuc }
443