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"
17 #include "afs/sysincludes.h" /* Standard vendor system headers */
18 #include "afsincludes.h" /* Afs-based standard headers */
19 #include "afs/afs_stats.h" /* statistics stuff */
20 #include <sys/scall_kernprivate.h>
22 #if defined(AFS_HPUX1123_ENV)
23 #include <sys/moddefs.h>
24 #endif /* AFS_HPUX1123_ENV */
26 #if defined(AFS_HPUX1123_ENV)
27 /* defind DLKM tables so we can load dynamicly */
28 /* we still need an afs_unload to unload */
29 /* Note: There is to be a dependency on the
30 * the name of the struct <name>_wrapper, and the
31 * name of the dynamicly loaded file <name>
32 * We will define -DAFS_WRAPPER=<name>_wrapper
33 * and -DAFS_CONF_DATA=<name>_conf_data and pass into
37 extern struct mod_operations mod_misc_ops;
38 extern struct mod_conf_data AFS_CONF_DATA;
40 static int afs_load(void *arg);
41 /* static int afs_unload(void *arg); */
43 struct mod_type_data afs_mod_link = {
48 struct modlink afs_modlink[] = {
49 {&mod_misc_ops, &afs_mod_link},
53 struct modwrapper AFS_WRAPPER = {
56 NULL, /* should be afs_unload if we had one */
62 #endif /* AFS_HPUX1123_ENV */
64 static char afs_mountpath[512];
65 struct vfs *afs_globalVFS = 0;
66 struct vcache *afs_globalVp = 0;
69 afs_mount(struct vfs *afsp, char *path, smountargs_t * data)
72 AFS_STATCNT(afs_mount);
74 if (afs_globalVFS) { /* Don't allow remounts. */
76 return (setuerror(EBUSY));
80 afsp->vfs_bsize = 8192;
81 afsp->vfs_fsid[0] = AFS_VFSMAGIC; /* magic */
82 afsp->vfs_fsid[1] = AFS_VFSFSID;
83 strcpy(afsp->vfs_name, "AFS");
84 afsp->vfs_name[3] = '\0';
86 strncpy(afs_mountpath, path, sizeof(afs_mountpath));
87 afs_mountpath[sizeof afs_mountpath - 1] = '\0';
89 #ifndef AFS_NONFSTRANS
90 /* Set up the xlator in case it wasn't done elsewhere */
100 afs_unmount(struct vfs *afsp)
103 AFS_STATCNT(afs_unmount);
113 afs_root(struct vfs *afsp, struct vnode **avpp, char *unused1)
116 struct vrequest treq;
117 struct vcache *tvp = 0;
119 AFS_STATCNT(afs_root);
121 if (afs_globalVp && (afs_globalVp->f.states & CStatd)) {
125 afs_PutVCache(afs_globalVp);
129 if (!(code = afs_InitReq(&treq, p_cred(u.u_procp)))
130 && !(code = afs_CheckInit())) {
131 tvp = afs_GetVCache(&afs_rootFid, &treq, NULL, NULL);
132 /* we really want this to stay around */
140 VN_HOLD(AFSTOV(tvp));
141 SET_V_FLAG(AFSTOV(tvp), VROOT);
143 afs_globalVFS = afsp;
147 afs_Trace2(afs_iclSetp, CM_TRACE_VFSROOT, ICL_TYPE_POINTER, *avpp,
148 ICL_TYPE_INT32, code);
155 afs_statfs(struct vfs *afsp, struct k_statvfs *abp)
158 AFS_STATCNT(afs_statfs);
161 abp->f_frsize = 1024;
162 abp->f_bsize = afsp->vfs_bsize;
163 /* Fake a high number below to satisfy programs that use the statfs
164 * call to make sure that there's enough space in the device partition
165 * before storing something there.
167 abp->f_blocks = abp->f_bfree = abp->f_bavail = abp->f_files =
168 abp->f_ffree = abp->f_favail = AFS_VFS_FAKEFREE;
169 abp->f_fsid = (AFS_VFSMAGIC << 16) || AFS_VFSFSID;
176 afs_sync(struct vfs *unused1, int unused2)
178 AFS_STATCNT(afs_sync);
183 afs_vget(struct vfs *afsp, struct vnode **avcp, struct fid *fidp)
186 struct vrequest treq;
188 AFS_STATCNT(afs_vget);
192 if ((code = afs_InitReq(&treq, p_cred(u.u_procp))) == 0) {
193 code = afs_osi_vget((struct vcache **)avcp, fidp, &treq);
196 afs_Trace3(afs_iclSetp, CM_TRACE_VGET, ICL_TYPE_POINTER, *avcp,
197 ICL_TYPE_INT32, treq.uid, ICL_TYPE_FID, fidp);
198 code = afs_CheckCode(code, &treq, 42);
205 afs_getmount(struct vfs *vfsp, char *fsmntdir, struct mount_data *mdp,
214 (afs_mountpath, fsmntdir, strlen(afs_mountpath) + 1, &l));
218 struct vfsops Afs_vfsops = {
226 (vfs_freeze_t *) 0, /* vfs_freeze */
227 (vfs_thaw_t *) 0, /* vfs_thaw */
228 (vfs_quota_t *) 0, /* vfs_quota */
229 (vfs_mountroot_t *) 0, /* vfs_mountroot. Note: afs_mountroot_nullop in this
230 * position panicked HP 11.00+
232 (vfs_size_t *) 0 /* vfs_size */
235 static int afs_Starting = 0;
238 #if !defined(AFS_HPUX110_ENV)
239 sema_t afs_global_sema = {
240 NULL, 0, NULL, NULL, NULL, NULL, 0, 0, 0, 0, 0, 0, 0, /* sa_type */
241 0, 0, 0, 0, 0, 0, 0, NULL, /* sa_link */
248 b_sema_t afs_global_sema = { 0 };
256 SPINLOCK_USAV(sched_lock, context);
259 SPINUNLOCK_USAV(sched_lock, context);
260 #if defined(AFS_HPUX110_ENV)
261 b_initsema(&afs_global_sema, 1, NFS_LOCK_ORDER2, "AFS GLOCK");
262 /* afsHash(64); *//* 64 buckets */
264 initsema(&afs_global_sema, 1, FILESYS_SEMA_PRI, FILESYS_SEMA_ORDER);
265 afsHash(64); /* 64 buckets */
268 SPINUNLOCK_USAV(sched_lock, context);
271 osi_Panic("osi_Init lost initialization race");
275 #if defined(AFS_HPUX1123_ENV)
276 /* DLKM routine called when loaded */
283 #endif /* AFS_HPUX1123_ENV */
286 * afsc_link - Initialize VFS
288 int afs_vfs_slot = -1;
293 extern int Afs_syscall(), afs_xioctl(), Afs_xsetgroups();
295 /* For now nothing special is required during AFS initialization. */
296 AFS_STATCNT(afsc_link);
298 if ((afs_vfs_slot = add_vfs_type("afs", &Afs_vfsops)) < 0)
300 sysent_assign_function(AFS_SYSCALL, 7, (void (*)())Afs_syscall,
302 sysent_define_arg(AFS_SYSCALL, 0, longArg);
303 sysent_define_arg(AFS_SYSCALL, 1, longArg);
304 sysent_define_arg(AFS_SYSCALL, 2, longArg);
305 sysent_define_arg(AFS_SYSCALL, 3, longArg);
306 sysent_define_arg(AFS_SYSCALL, 4, longArg);
307 sysent_define_arg(AFS_SYSCALL, 5, longArg);
308 sysent_define_arg(AFS_SYSCALL, 6, longArg);
309 sysent_returns_long(AFS_SYSCALL);
312 sysent_assign_function(80, 2, (void (*)())Afs_xsetgroups, "setgroups");
313 sysent_define_arg(80, 0, longArg);
314 sysent_define_arg(80, 1, longArg);
315 sysent_returns_long(80);