ee3a8634baa0cc5d33d003afab802b85958761f2
[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 (afs_globalVp) {
82             afs_PutVCache(afs_globalVp);
83             afs_globalVp = NULL;
84         }
85
86         if (!(code = afs_InitReq(&treq, u.u_cred)) &&
87             !(code = afs_CheckInit())) {
88             tvp = afs_GetVCache(&afs_rootFid, &treq, NULL, NULL);
89             /* we really want this to stay around */
90             if (tvp) {
91                 afs_globalVp = tvp;
92             } else
93                 code = ENOENT;
94         }
95     }
96     if (tvp) {
97         VN_HOLD(AFSTOV(tvp));
98
99         AFSTOV(tvp)->v_flag |= VROOT;       /* No-op on Ultrix 2.2 */
100         afs_globalVFS = afsp;
101         *avpp = AFSTOV(tvp);
102     }
103
104     afs_Trace3(afs_iclSetp, CM_TRACE_GOPEN, ICL_TYPE_POINTER, *avpp,
105                ICL_TYPE_INT32, 0, ICL_TYPE_INT32, code);
106     return code;
107 }
108
109 afs_sync(afsp)
110     struct vfs *afsp; 
111 {
112     AFS_STATCNT(afs_sync);
113     return 0;
114 }
115
116 afs_statfs(afsp, abp)
117     register struct vfs *afsp;
118     struct statfs *abp;
119  {
120         AFS_STATCNT(afs_statfs);
121         abp->f_type = 0;
122         abp->f_bsize = afsp->vfs_bsize;
123         abp->f_fsid.val[0] = AFS_VFSMAGIC; /* magic */
124         abp->f_fsid.val[1] = (afs_int32) AFS_VFSFSID;
125         return 0;
126 }
127
128 afs_mountroot()
129 {
130     AFS_STATCNT(afs_mountroot);
131     return(EINVAL);
132 }
133
134 afs_swapvp() 
135 {
136     AFS_STATCNT(afs_swapvp);
137     return(EINVAL);
138 }