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
11 * osi_vfsops.c for HPUX
13 #include <afsconfig.h>
14 #include "afs/param.h"
19 #include "afs/sysincludes.h" /* Standard vendor system headers */
20 #include "afsincludes.h" /* Afs-based standard headers */
21 #include "afs/afs_stats.h" /* statistics stuff */
22 #include <sys/scall_kernprivate.h>
24 #if defined(AFS_HPUX1123_ENV)
25 #include <sys/moddefs.h>
26 #endif /* AFS_HPUX1123_ENV */
28 #if defined(AFS_HPUX1123_ENV)
29 /* defind DLKM tables so we can load dynamicly */
30 /* we still need an afs_unload to unload */
31 /* Note: There is to be a dependency on the
32 * the name of the struct <name>_wrapper, and the
33 * name of the dynamicly loaded file <name>
34 * We will define -DAFS_WRAPPER=<name>_wrapper
35 * and -DAFS_CONF_DATA=<name>_conf_data and pass into
39 extern struct mod_operations mod_misc_ops;
40 extern struct mod_conf_data AFS_CONF_DATA;
42 static int afs_load(void *arg);
43 /* static int afs_unload(void *arg); */
45 struct mod_type_data afs_mod_link = {
50 struct modlink afs_modlink[] = {
51 {&mod_misc_ops, &afs_mod_link},
55 struct modwrapper AFS_WRAPPER = {
58 NULL, /* should be afs_unload if we had one */
64 #endif /* AFS_HPUX1123_ENV */
66 static char afs_mountpath[512];
67 struct vfs *afs_globalVFS = 0;
68 struct vcache *afs_globalVp = 0;
71 afs_mount(struct vfs *afsp, char *path, smountargs_t * data)
74 AFS_STATCNT(afs_mount);
76 if (afs_globalVFS) { /* Don't allow remounts. */
78 return (setuerror(EBUSY));
82 afsp->vfs_bsize = 8192;
83 afsp->vfs_fsid[0] = AFS_VFSMAGIC; /* magic */
84 afsp->vfs_fsid[1] = AFS_VFSFSID;
85 strcpy(afsp->vfs_name, "AFS");
86 afsp->vfs_name[3] = '\0';
88 strncpy(afs_mountpath, path, sizeof(afs_mountpath));
89 afs_mountpath[sizeof afs_mountpath - 1] = '\0';
91 #ifndef AFS_NONFSTRANS
92 /* Set up the xlator in case it wasn't done elsewhere */
102 afs_unmount(struct vfs *afsp)
105 AFS_STATCNT(afs_unmount);
115 afs_root(struct vfs *afsp, struct vnode **avpp, char *unused1)
118 struct vrequest treq;
119 register struct vcache *tvp = 0;
121 AFS_STATCNT(afs_root);
123 if (afs_globalVp && (afs_globalVp->f.states & CStatd)) {
127 afs_PutVCache(afs_globalVp);
131 if (!(code = afs_InitReq(&treq, p_cred(u.u_procp)))
132 && !(code = afs_CheckInit())) {
133 tvp = afs_GetVCache(&afs_rootFid, &treq, NULL, NULL);
134 /* we really want this to stay around */
142 VN_HOLD(AFSTOV(tvp));
143 SET_V_FLAG(AFSTOV(tvp), VROOT);
145 afs_globalVFS = afsp;
149 afs_Trace2(afs_iclSetp, CM_TRACE_VFSROOT, ICL_TYPE_POINTER, *avpp,
150 ICL_TYPE_INT32, code);
157 afs_statfs(register struct vfs *afsp, struct k_statvfs *abp)
160 AFS_STATCNT(afs_statfs);
163 abp->f_frsize = 1024;
164 abp->f_bsize = afsp->vfs_bsize;
165 /* Fake a high number below to satisfy programs that use the statfs
166 * call to make sure that there's enough space in the device partition
167 * before storing something there.
169 abp->f_blocks = abp->f_bfree = abp->f_bavail = abp->f_files =
170 abp->f_ffree = abp->f_favail = 9000000;
171 abp->f_fsid = (AFS_VFSMAGIC << 16) || AFS_VFSFSID;
178 afs_sync(struct vfs *unused1, int unused2)
180 AFS_STATCNT(afs_sync);
185 afs_vget(struct vfs *afsp, struct vnode **avcp, struct fid *fidp)
188 struct vrequest treq;
190 AFS_STATCNT(afs_vget);
194 if ((code = afs_InitReq(&treq, p_cred(u.u_procp))) == 0) {
195 code = afs_osi_vget((struct vcache **)avcp, fidp, &treq);
198 afs_Trace3(afs_iclSetp, CM_TRACE_VGET, ICL_TYPE_POINTER, *avcp,
199 ICL_TYPE_INT32, treq.uid, ICL_TYPE_FID, fidp);
200 code = afs_CheckCode(code, &treq, 42);
207 afs_getmount(struct vfs *vfsp, char *fsmntdir, struct mount_data *mdp,
216 (afs_mountpath, fsmntdir, strlen(afs_mountpath) + 1, &l));
220 struct vfsops Afs_vfsops = {
228 (vfs_freeze_t *) 0, /* vfs_freeze */
229 (vfs_thaw_t *) 0, /* vfs_thaw */
230 (vfs_quota_t *) 0, /* vfs_quota */
231 (vfs_mountroot_t *) 0, /* vfs_mountroot. Note: afs_mountroot_nullop in this
232 * position panicked HP 11.00+
234 (vfs_size_t *) 0 /* vfs_size */
237 static int afs_Starting = 0;
240 #if !defined(AFS_HPUX110_ENV)
241 sema_t afs_global_sema = {
242 NULL, 0, NULL, NULL, NULL, NULL, 0, 0, 0, 0, 0, 0, 0, /* sa_type */
243 0, 0, 0, 0, 0, 0, 0, NULL, /* sa_link */
250 b_sema_t afs_global_sema = { 0 };
256 register ulong_t context;
258 SPINLOCK_USAV(sched_lock, context);
261 SPINUNLOCK_USAV(sched_lock, context);
262 #if defined(AFS_HPUX110_ENV)
263 b_initsema(&afs_global_sema, 1, NFS_LOCK_ORDER2, "AFS GLOCK");
264 /* afsHash(64); *//* 64 buckets */
266 initsema(&afs_global_sema, 1, FILESYS_SEMA_PRI, FILESYS_SEMA_ORDER);
267 afsHash(64); /* 64 buckets */
270 SPINUNLOCK_USAV(sched_lock, context);
273 osi_Panic("osi_Init lost initialization race");
277 #if defined(AFS_HPUX1123_ENV)
278 /* DLKM routine called when loaded */
285 #endif /* AFS_HPUX1123_ENV */
288 * afsc_link - Initialize VFS
290 int afs_vfs_slot = -1;
295 extern int Afs_syscall(), afs_xioctl(), Afs_xsetgroups();
297 /* For now nothing special is required during AFS initialization. */
298 AFS_STATCNT(afsc_link);
300 if ((afs_vfs_slot = add_vfs_type("afs", &Afs_vfsops)) < 0)
302 sysent_assign_function(AFS_SYSCALL, 7, (void (*)())Afs_syscall,
304 sysent_define_arg(AFS_SYSCALL, 0, longArg);
305 sysent_define_arg(AFS_SYSCALL, 1, longArg);
306 sysent_define_arg(AFS_SYSCALL, 2, longArg);
307 sysent_define_arg(AFS_SYSCALL, 3, longArg);
308 sysent_define_arg(AFS_SYSCALL, 4, longArg);
309 sysent_define_arg(AFS_SYSCALL, 5, longArg);
310 sysent_define_arg(AFS_SYSCALL, 6, longArg);
311 sysent_returns_long(AFS_SYSCALL);
314 sysent_assign_function(80, 2, (void (*)())Afs_xsetgroups, "setgroups");
315 sysent_define_arg(80, 0, longArg);
316 sysent_define_arg(80, 1, longArg);
317 sysent_returns_long(80);