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