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