Merge 1.8.0~pre4 packaging into master
[pkg-k5-afs_openafs.git] / src / afs / UKERNEL / osi_vfsops.c
blobb50af8f0fd3c1443af5e84461777f1971ca7128c
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 */
10 #include <afsconfig.h>
11 #include "afs/param.h"
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 */
18 struct vfsops Afs_vfsops = {
19 afs_mount,
20 afs_unmount,
21 afs_root,
22 afs_statfs,
23 afs_sync,
26 struct vfs *afs_globalVFS = 0;
27 struct vcache *afs_globalVp = 0;
28 int afs_rootCellIndex = 0;
30 #if !defined(AFS_USR_AIX_ENV)
31 #include "sys/syscall.h"
32 #endif
34 int
35 afs_mount(struct vfs *afsp, char *path, void *data)
37 AFS_STATCNT(afs_mount);
39 if (afs_globalVFS) {
40 /* Don't allow remounts since some system (like AIX) don't handle it well */
41 return (setuerror(EBUSY));
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;
48 return 0;
51 int
52 afs_unmount(struct vfs *afsp)
54 AFS_STATCNT(afs_unmount);
55 afs_globalVFS = 0;
56 afs_shutdown();
57 return 0;
60 int
61 afs_root(OSI_VFS_DECL(afsp), struct vnode **avpp)
63 afs_int32 code = 0;
64 struct vrequest treq;
65 struct vcache *tvp = 0;
66 OSI_VFS_CONVERT(afsp);
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;
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;
87 if (tvp) {
88 VN_HOLD(AFSTOV(tvp));
90 AFSTOV(tvp)->v_flag |= VROOT; /* No-op on Ultrix 2.2 */
91 afs_globalVFS = afsp;
92 *avpp = AFSTOV(tvp);
95 afs_Trace3(afs_iclSetp, CM_TRACE_GOPEN, ICL_TYPE_POINTER, *avpp,
96 ICL_TYPE_INT32, 0, ICL_TYPE_INT32, code);
97 return code;
101 afs_sync(struct vfs *afsp)
103 AFS_STATCNT(afs_sync);
104 return 0;
108 afs_statfs(struct vfs *afsp, struct statfs *abp)
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;
119 afs_statvfs(struct vfs *afsp, struct statvfs *abp)
121 AFS_STATCNT(afs_statfs);
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;
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
135 return 0;
139 afs_mountroot(void)
141 AFS_STATCNT(afs_mountroot);
142 return (EINVAL);
146 afs_swapvp(void)
148 AFS_STATCNT(afs_swapvp);
149 return (EINVAL);