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 "../afs/param.h" /* Should be always first */
14 #include "../afs/sysincludes.h" /* Standard vendor system headers */
15 #include "../afs/afsincludes.h" /* Afs-based standard headers */
16 #include "../afs/afs_stats.h" /* statistics stuff */
17 #include <sys/scall_kernprivate.h>
20 static char afs_mountpath[512];
21 struct vfs *afs_globalVFS = 0;
22 struct vcache *afs_globalVp = 0;
24 int afs_mount(struct vfs *afsp, char *path, smountargs_t *data)
27 AFS_STATCNT(afs_mount);
29 if (afs_globalVFS) { /* Don't allow remounts. */
31 return (setuerror(EBUSY));
35 afsp->vfs_bsize = 8192;
36 afsp->vfs_fsid[0] = AFS_VFSMAGIC; /* magic */
37 afsp->vfs_fsid[1] = AFS_VFSFSID;
38 strcpy(afsp->vfs_name, "AFS");
39 afsp->vfs_name[3] = '\0';
41 strncpy(afs_mountpath, path, sizeof(afs_mountpath));
42 afs_mountpath[sizeof afs_mountpath - 1] = '\0';
44 #ifndef AFS_NONFSTRANS
45 /* Set up the xlator in case it wasn't done elsewhere */
54 int afs_unmount(struct vfs *afsp)
57 AFS_STATCNT(afs_unmount);
66 int afs_root (struct vfs *afsp, struct vnode **avpp, char *unused1)
70 register struct vcache *tvp=0;
72 AFS_STATCNT(afs_root);
74 if (afs_globalVp && (afs_globalVp->states & CStatd)) {
77 if (!(code = afs_InitReq(&treq, p_cred(u.u_procp))) &&
78 !(code = afs_CheckInit())) {
79 tvp = afs_GetVCache(&afs_rootFid, &treq, (afs_int32 *)0,
80 (struct vcache*)0, WRITE_LOCK);
81 /* we really want this to stay around */
89 VN_HOLD((struct vnode *)tvp);
90 SET_V_FLAG( ((struct vnode *)tvp), VROOT);
93 *avpp = (struct vnode *) tvp;
96 afs_Trace2(afs_iclSetp, CM_TRACE_VFSROOT, ICL_TYPE_POINTER, *avpp,
97 ICL_TYPE_INT32, code);
103 int afs_statfs(register struct vfs *afsp, struct k_statvfs *abp)
106 AFS_STATCNT(afs_statfs);
109 abp->f_frsize = 1024;
110 abp->f_bsize = afsp->vfs_bsize;
111 /* Fake a high number below to satisfy programs that use the statfs
112 * call to make sure that there's enough space in the device partition
113 * before storing something there.
115 abp->f_blocks = abp->f_bfree = abp->f_bavail = abp->f_files =
116 abp->f_ffree = abp->f_favail = 9000000;
117 abp->f_fsid = (AFS_VFSMAGIC << 16) || AFS_VFSFSID;
123 int afs_sync(struct vfs *unused1, int unused2)
125 AFS_STATCNT(afs_sync);
129 int afs_vget(struct vfs *afsp, struct vnode **avcp, struct fid *fidp)
132 struct vrequest treq;
134 AFS_STATCNT(afs_vget);
138 if ((code = afs_InitReq(&treq, p_cred(u.u_procp)))==0) {
139 code = afs_osi_vget((struct vcache**)avcp, fidp, &treq);
142 afs_Trace3(afs_iclSetp, CM_TRACE_VGET, ICL_TYPE_POINTER, *avcp,
143 ICL_TYPE_INT32, treq.uid, ICL_TYPE_FID, fidp);
144 code = afs_CheckCode(code, &treq, 42);
150 int afs_getmount(struct vfs *vfsp, char *fsmntdir, struct mount_data *mdp, char *unused1)
157 return(copyoutstr(afs_mountpath, fsmntdir, strlen(afs_mountpath)+1, &l));
161 struct vfsops Afs_vfsops = {
169 (vfs_freeze_t *)0, /* vfs_freeze */
170 (vfs_thaw_t *)0, /* vfs_thaw */
171 (vfs_quota_t *)0, /* vfs_quota */
172 (vfs_mountroot_t *)0, /* vfs_mountroot. Note: afs_mountroot_nullop in this
173 * position panicked HP 11.00+
175 (vfs_size_t *)0 /* vfs_size */
178 static int afs_Starting = 0;
181 sema_t afs_global_sema = {
182 NULL, 0, NULL, NULL, NULL, NULL, 0, 0, 0, 0, 0, 0, 0, /* sa_type */
183 0, 0, 0, 0, 0, 0, 0, NULL, /* sa_link */
193 register ulong_t context;
195 SPINLOCK_USAV(sched_lock, context);
196 if ( !afs_Starting ) {
198 SPINUNLOCK_USAV(sched_lock, context);
199 initsema(&afs_global_sema, 1, FILESYS_SEMA_PRI, FILESYS_SEMA_ORDER);
200 afsHash(64); /* 64 buckets */
202 SPINUNLOCK_USAV(sched_lock, context);
205 osi_Panic("osi_Init lost initialization race");
210 * afsc_link - Initialize VFS
217 extern int Afs_syscall(), afs_xioctl(), Afs_xsetgroups();
219 /* For now nothing special is required during AFS initialization. */
220 AFS_STATCNT(afsc_link);
222 if ( (afs_vfs_slot=add_vfs_type("afs", &Afs_vfsops)) < 0 )
224 sysent_assign_function(AFS_SYSCALL, 7, (void (*)())Afs_syscall, "Afs_syscall");
225 sysent_define_arg(AFS_SYSCALL, 0, longArg);
226 sysent_define_arg(AFS_SYSCALL, 1, longArg);
227 sysent_define_arg(AFS_SYSCALL, 2, longArg);
228 sysent_define_arg(AFS_SYSCALL, 3, longArg);
229 sysent_define_arg(AFS_SYSCALL, 4, longArg);
230 sysent_define_arg(AFS_SYSCALL, 5, longArg);
231 sysent_define_arg(AFS_SYSCALL, 6, longArg);
232 sysent_returns_long(AFS_SYSCALL);
235 sysent_assign_function(80, 2, (void (*)())Afs_xsetgroups, "setgroups");
236 sysent_define_arg(80, 0, longArg);
237 sysent_define_arg(80, 1, longArg);
238 sysent_returns_long(80);