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 <afsconfig.h>
20 #include "afs/param.h"
35 #include "rpc/types.h"
37 #include "netinet/in.h"
41 #include "h/syspest.h"
44 #include "afs/afs_osi.h"
45 #define RFTP_INTERNALS 1
46 #include "afs/volerrors.h"
50 #include "afs/exporter.h"
52 #include "afs/afs_stats.h"
54 /* In Aix one may specify an init routine routine which is called once during
55 * initialization of all gfs; one day we might need to actual do somehing here.
58 char *gfsp; /* this is really struct gfs *, but we do not use it */
60 extern int afs_gn_strategy();
61 #define AFS_VM_BUFS 50
63 /* For now nothing special is required during AFS initialization. */
64 AFS_STATCNT(afs_init);
66 (void)vm_mount(D_REMOTE, afs_gn_strategy, AFS_VM_BUFS);
71 /* Some extra handling is needed when calling the aix's version of the local
72 * RDWR module, particularly the usage of the uio structure to the lower
73 * routine. Note of significant importance to the AFS port is the offset
74 * in/out parameter, which in two cases returns a new value back. The cases
75 * are: (1) when it's a FIFO file (it's reset to zero) which we don't yet
76 * support in AFS and (2) in a regular case when we write
77 * (i.e. rw == UIO_WRITE) and are in appending mode (i.e. FAPPEND bit on)
78 * where offset is set to the file's size. None of these cases apply to us
79 * currently so no problems occur; caution if things change!
82 gop_rdwr(rw, vp, base, len, offset, segflg, unit, aresid)
86 #ifdef AFS_64BIT_KERNEL
93 int unit; /* Ignored */
95 struct uio uio_struct;
96 struct iovec uiovector;
99 memset(&uio_struct, 0, sizeof(uio_struct));
100 memset(&uiovector, 0, sizeof(uiovector));
102 AFS_STATCNT(gop_rdwr);
103 /* Set up the uio structure */
104 uiovector.iov_base = (caddr_t) base;
105 uiovector.iov_len = len;
107 uio_struct.uio_iov = &uiovector;
108 uio_struct.uio_iovcnt = 1;
109 uio_struct.uio_offset = *offset;
110 uio_struct.uio_segflg = AFS_UIOSYS;
111 uio_struct.uio_resid = len;
112 uio_struct.uio_fmode = (rw == UIO_READ ? FREAD : FWRITE);
114 #ifdef AFS_64BIT_KERNEL
116 VNOP_RDWR(vp, rw, (int32long64_t) (rw == UIO_READ ? FREAD : FWRITE),
117 &uio_struct, (ext_t) 0, (caddr_t) 0, (struct vattr *)0,
121 VNOP_RDWR(vp, rw, (rw == UIO_READ ? FREAD : FWRITE), &uio_struct,
122 NULL, NULL, NULL, &afs_osi_cred);
124 *aresid = uio_struct.uio_resid;
129 /* Since in AIX a vnode is included in linked lists of its associated vfs and
130 * gnode we need to remove these links when removing an AFS vnode (part of the
131 * vcache entry). Note that since the accompanied gnode was alloced during
132 * vcache creation, we have to free it here too. We don't bother with the
133 * vnode itself since it's part of the vcache entry and it's handled fine by
136 * Note that there is a 1-1 mapping from AFS vnodes to gnodes, so there is
137 * no linked list of gnodes to remove this element from.
143 struct vfs *vfsp = vp->v_vfsp;
145 /* Unlink the vnode from the list the vfs has hanging of it */
146 tvp = vfsp->vfs_vnodes;
148 vfsp->vfs_vnodes = vp->v_vfsnext;
149 if (vp->v_vfsnext != NULL)
150 vp->v_vfsnext->v_vfsprev = vp->v_vfsprev;
151 if (vp->v_vfsprev != NULL)
152 vp->v_vfsprev->v_vfsnext = vp->v_vfsnext;
155 /* Free the allocated gnode that was accompanying the vcache's vnode */
157 osi_FreeSmallSpace(vp->v_gnode);
165 * afs_suser() returns true if the caller is superuser, false otherwise.
167 * Note that it must NOT set errno.
170 afs_suser(void *credp)