include-afsconfig-before-param-h-20010712
[openafs.git] / src / afs / UKERNEL / osi_vfsops.c
1 /*
2  * Copyright 2000, International Business Machines Corporation and others.
3  * All Rights Reserved.
4  * 
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
8  */
9
10 #include <afsconfig.h>
11 #include "../afs/param.h"
12
13 RCSID("$Header$");
14
15 #include "../afs/sysincludes.h" /* Standard vendor system headers */
16 #include "../afs/afsincludes.h" /* Afs-based standard headers */
17 #include "../afs/afs_stats.h"   /* statistics stuff */
18
19
20 int afs_mount();
21 int afs_unmount();
22 int afs_root();
23 int afs_statfs();
24 int afs_sync();
25
26 struct vfsops Afs_vfsops = {
27     afs_mount,
28     afs_unmount,
29     afs_root,
30     afs_statfs,
31     afs_sync,
32 };
33
34 struct vfs *afs_globalVFS = 0;
35 struct vcache *afs_globalVp = 0;
36 int afs_rootCellIndex = 0;
37
38 #if !defined(AFS_USR_AIX_ENV)
39 #include "../sys/syscall.h"
40 #endif
41
42 afs_mount(afsp, path, data)
43     char *path;
44     caddr_t data; 
45     struct vfs *afsp;
46 {
47     AFS_STATCNT(afs_mount);
48
49     if (afs_globalVFS) {
50         /* Don't allow remounts since some system (like AIX) don't handle it well */
51         return (setuerror(EBUSY));
52     }
53     afs_globalVFS = afsp;
54     afsp->vfs_bsize = 8192;
55     afsp->vfs_fsid.val[0] = AFS_VFSMAGIC; /* magic */
56     afsp->vfs_fsid.val[1] = (afs_int32) AFS_VFSFSID; 
57
58     return 0;
59 }
60
61 afs_unmount (afsp)
62     struct vfs *afsp; {
63     AFS_STATCNT(afs_unmount);
64     afs_globalVFS = 0;
65     afs_shutdown();
66     return 0;
67 }
68
69 afs_root (OSI_VFS_ARG(afsp), avpp)
70     OSI_VFS_DECL(afsp);
71     struct vnode **avpp; {
72     register afs_int32 code = 0;
73     struct vrequest treq;
74     register struct vcache *tvp=0;
75     OSI_VFS_CONVERT(afsp)
76
77     AFS_STATCNT(afs_root);
78     if (afs_globalVp && (afs_globalVp->states & CStatd)) {
79         tvp = afs_globalVp;
80     } else {
81         if (!(code = afs_InitReq(&treq, u.u_cred)) &&
82             !(code = afs_CheckInit())) {
83             tvp = afs_GetVCache(&afs_rootFid, &treq, (afs_int32 *)0,
84                                 (struct vcache*)0, WRITE_LOCK);
85             /* we really want this to stay around */
86             if (tvp) {
87                 afs_globalVp = tvp;
88             } else
89                 code = ENOENT;
90         }
91     }
92     if (tvp) {
93         VN_HOLD((struct vnode *)tvp);
94
95         tvp->v.v_flag |= VROOT;     /* No-op on Ultrix 2.2 */
96         afs_globalVFS = afsp;
97         *avpp = (struct vnode *) tvp;
98     }
99
100     afs_Trace3(afs_iclSetp, CM_TRACE_GOPEN, ICL_TYPE_POINTER, *avpp,
101                ICL_TYPE_INT32, 0, ICL_TYPE_INT32, code);
102     return code;
103 }
104
105 afs_sync(afsp)
106     struct vfs *afsp; 
107 {
108     AFS_STATCNT(afs_sync);
109     return 0;
110 }
111
112 afs_statfs(afsp, abp)
113     register struct vfs *afsp;
114     struct statfs *abp;
115  {
116         AFS_STATCNT(afs_statfs);
117         abp->f_type = 0;
118         abp->f_bsize = afsp->vfs_bsize;
119         abp->f_fsid.val[0] = AFS_VFSMAGIC; /* magic */
120         abp->f_fsid.val[1] = (afs_int32) AFS_VFSFSID;
121         return 0;
122 }
123
124 afs_mountroot()
125 {
126     AFS_STATCNT(afs_mountroot);
127     return(EINVAL);
128 }
129
130 afs_swapvp() 
131 {
132     AFS_STATCNT(afs_swapvp);
133     return(EINVAL);
134 }