2 * Copyright 2000, International Business Machines Corporation and others.
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
19 #include "../afs/param.h"
20 #include "../h/systm.h"
21 #include "../h/types.h"
22 #include "../h/errno.h"
23 #include "../h/stat.h"
24 #include "../h/user.h"
26 #include "../h/vattr.h"
27 #include "../h/file.h"
29 #include "../h/chownx.h"
30 #include "../h/systm.h"
31 #include "../h/access.h"
32 #include "../rpc/types.h"
33 #include "../afs/osi_vfs.h"
34 #include "../netinet/in.h"
35 #include "../h/mbuf.h"
36 #include "../rpc/types.h"
37 #include "../rpc/xdr.h"
38 #include "../h/vmuser.h"
39 #include "../h/syspest.h"
41 #include "../afs/stds.h"
42 #include "../afs/afs_osi.h"
43 #define RFTP_INTERNALS 1
44 #include "../afs/volerrors.h"
45 #include "../afsint/afsint.h"
46 #include "../afsint/vldbint.h"
47 #include "../afs/lock.h"
48 #include "../afs/exporter.h"
49 #include "../afs/afs.h"
50 #include "../afs/afs_stats.h"
52 /* In Aix one may specify an init routine routine which is called once during
53 * initialization of all gfs; one day we might need to actual do somehing here.
56 char *gfsp; /* this is really struct gfs *, but we do not use it */
58 extern int afs_gn_strategy();
59 #define AFS_VM_BUFS 50
61 /* For now nothing special is required during AFS initialization. */
62 AFS_STATCNT(afs_init);
64 (void) vm_mount(D_REMOTE, afs_gn_strategy, AFS_VM_BUFS);
69 /* Some extra handling is needed when calling the aix's version of the local
70 * RDWR module, particularly the usage of the uio structure to the lower
71 * routine. Note of significant importance to the AFS port is the offset
72 * in/out parameter, which in two cases returns a new value back. The cases
73 * are: (1) when it's a FIFO file (it's reset to zero) which we don't yet
74 * support in AFS and (2) in a regular case when we write
75 * (i.e. rw == UIO_WRITE) and are in appending mode (i.e. FAPPEND bit on)
76 * where offset is set to the file's size. None of these cases apply to us
77 * currently so no problems occur; caution if things change!
80 gop_rdwr(rw, vp, base, len, offset, segflg, unit, aresid)
87 int unit; /* Ignored */
89 struct uio uio_struct;
90 struct iovec uiovector;
93 AFS_STATCNT(gop_rdwr);
94 /* Set up the uio structure */
95 uiovector.iov_base = (caddr_t) base;
96 uiovector.iov_len = len;
98 uio_struct.uio_iov = &uiovector;
99 uio_struct.uio_iovcnt = 1;
100 uio_struct.uio_offset = *offset;
101 uio_struct.uio_segflg = AFS_UIOSYS;
102 uio_struct.uio_resid = len;
103 uio_struct.uio_fmode = (rw == UIO_READ ? FREAD : FWRITE);
105 code = VNOP_RDWR(vp, rw, (rw == UIO_READ ? FREAD : FWRITE), &uio_struct,
106 NULL, NULL, NULL, &afs_osi_cred);
107 *aresid = uio_struct.uio_resid;
112 /* Since in AIX a vnode is included in linked lists of its associated vfs and
113 * gnode we need to remove these links when removing an AFS vnode (part of the
114 * vcache entry). Note that since the accompanied gnode was alloced during
115 * vcache creation, we have to free it here too. We don't bother with the
116 * vnode itself since it's part of the vcache entry and it's handled fine by
119 * Note that there is a 1-1 mapping from AFS vnodes to gnodes, so there is
120 * no linked list of gnodes to remove this element from.
125 register struct vnode *tvp;
126 register struct vfs *vfsp = vp->v_vfsp;
128 /* Unlink the vnode from the list the vfs has hanging of it */
129 tvp = vfsp->vfs_vnodes;
131 vfsp->vfs_vnodes = vp->v_vfsnext;
132 if (vp->v_vfsnext != NULL)
133 vp->v_vfsnext->v_vfsprev = vp->v_vfsprev;
134 if (vp->v_vfsprev != NULL)
135 vp->v_vfsprev->v_vfsnext = vp->v_vfsnext;
138 /* Free the allocated gnode that was accompanying the vcache's vnode */
140 osi_FreeSmallSpace(vp->v_gnode);
148 * afs_suser() returns true if the caller is superuser, false otherwise.
150 * Note that it must NOT set errno.