Commit | Line | Data |
---|---|---|
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 | ||
18 | struct vfsops Afs_vfsops = { | |
19 | afs_mount, | |
20 | afs_unmount, | |
21 | afs_root, | |
22 | afs_statfs, | |
23 | afs_sync, | |
24 | }; | |
25 | ||
26 | struct vfs *afs_globalVFS = 0; | |
27 | struct vcache *afs_globalVp = 0; | |
28 | int afs_rootCellIndex = 0; | |
29 | ||
30 | #if !defined(AFS_USR_AIX_ENV) | |
31 | #include "sys/syscall.h" | |
32 | #endif | |
33 | ||
34 | int | |
35 | afs_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 | ||
51 | int | |
52 | afs_unmount(struct vfs *afsp) | |
53 | { | |
54 | AFS_STATCNT(afs_unmount); | |
55 | afs_globalVFS = 0; | |
56 | afs_shutdown(); | |
57 | return 0; | |
58 | } | |
59 | ||
60 | int | |
61 | afs_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 | ||
100 | int | |
101 | afs_sync(struct vfs *afsp) | |
102 | { | |
103 | AFS_STATCNT(afs_sync); | |
104 | return 0; | |
105 | } | |
106 | ||
107 | int | |
108 | afs_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 | ||
118 | int | |
119 | afs_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 | ||
138 | int | |
139 | afs_mountroot(void) | |
140 | { | |
141 | AFS_STATCNT(afs_mountroot); | |
142 | return (EINVAL); | |
143 | } | |
144 | ||
145 | int | |
146 | afs_swapvp(void) | |
147 | { | |
148 | AFS_STATCNT(afs_swapvp); | |
149 | return (EINVAL); | |
150 | } |