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