Commit | Line | Data |
---|---|---|
76434cf5 | 1 | /* |
76434cf5 | 2 | * Copyright (c) 1993 Jan-Simon Pendry |
1611db1e KB |
3 | * Copyright (c) 1993 |
4 | * The Regents of the University of California. All rights reserved. | |
76434cf5 JSP |
5 | * |
6 | * This code is derived from software contributed to Berkeley by | |
7 | * Jan-Simon Pendry. | |
8 | * | |
9 | * %sccs.include.redist.c% | |
10 | * | |
679a7c6b | 11 | * @(#)procfs_vfsops.c 8.5 (Berkeley) %G% |
76434cf5 JSP |
12 | * |
13 | * From: | |
14 | * $Id: procfs_vfsops.c,v 3.1 1993/12/15 09:40:17 jsp Exp $ | |
15 | */ | |
16 | ||
17 | /* | |
18 | * procfs VFS interface | |
19 | */ | |
20 | ||
21 | #include <sys/param.h> | |
22 | #include <sys/time.h> | |
23 | #include <sys/kernel.h> | |
24 | #include <sys/proc.h> | |
25 | #include <sys/buf.h> | |
26 | #include <sys/syslog.h> | |
27 | #include <sys/mount.h> | |
28 | #include <sys/signalvar.h> | |
29 | #include <sys/vnode.h> | |
30 | #include <miscfs/procfs/procfs.h> | |
31 | #include <vm/vm.h> /* for PAGE_SIZE */ | |
32 | ||
33 | /* | |
34 | * VFS Operations. | |
35 | * | |
36 | * mount system call | |
37 | */ | |
38 | /* ARGSUSED */ | |
39 | procfs_mount(mp, path, data, ndp, p) | |
40 | struct mount *mp; | |
41 | char *path; | |
42 | caddr_t data; | |
43 | struct nameidata *ndp; | |
44 | struct proc *p; | |
45 | { | |
46 | u_int size; | |
76434cf5 JSP |
47 | |
48 | if (UIO_MX & (UIO_MX-1)) { | |
49 | log(LOG_ERR, "procfs: invalid directory entry size"); | |
50 | return (EINVAL); | |
51 | } | |
52 | ||
53 | if (mp->mnt_flag & MNT_UPDATE) | |
54 | return (EOPNOTSUPP); | |
55 | ||
56 | mp->mnt_flag |= MNT_LOCAL; | |
57 | mp->mnt_data = 0; | |
58 | getnewfsid(mp, MOUNT_PROCFS); | |
59 | ||
60 | (void) copyinstr(path, (caddr_t)mp->mnt_stat.f_mntonname, MNAMELEN, &size); | |
61 | bzero(mp->mnt_stat.f_mntonname + size, MNAMELEN - size); | |
62 | ||
487e3d29 JSP |
63 | size = sizeof("procfs") - 1; |
64 | bcopy("procfs", mp->mnt_stat.f_mntfromname, size); | |
76434cf5 JSP |
65 | bzero(mp->mnt_stat.f_mntfromname + size, MNAMELEN - size); |
66 | ||
67 | return (0); | |
68 | } | |
69 | ||
70 | /* | |
71 | * unmount system call | |
72 | */ | |
73 | procfs_unmount(mp, mntflags, p) | |
74 | struct mount *mp; | |
75 | int mntflags; | |
76 | struct proc *p; | |
77 | { | |
78 | int error; | |
79 | extern int doforce; | |
80 | int flags = 0; | |
81 | ||
82 | if (mntflags & MNT_FORCE) { | |
83 | /* procfs can never be rootfs so don't check for it */ | |
84 | if (!doforce) | |
85 | return (EINVAL); | |
86 | flags |= FORCECLOSE; | |
87 | } | |
88 | ||
89 | if (error = vflush(mp, 0, flags)) | |
90 | return (error); | |
91 | ||
92 | return (0); | |
93 | } | |
94 | ||
95 | procfs_root(mp, vpp) | |
96 | struct mount *mp; | |
97 | struct vnode **vpp; | |
98 | { | |
76434cf5 | 99 | |
679a7c6b | 100 | return (procfs_allocvp(mp, vpp, 0, Proot)); |
76434cf5 JSP |
101 | } |
102 | ||
76434cf5 JSP |
103 | /* ARGSUSED */ |
104 | procfs_start(mp, flags, p) | |
105 | struct mount *mp; | |
106 | int flags; | |
107 | struct proc *p; | |
108 | { | |
109 | ||
110 | return (0); | |
111 | } | |
112 | ||
113 | /* | |
114 | * Get file system statistics. | |
115 | */ | |
116 | procfs_statfs(mp, sbp, p) | |
117 | struct mount *mp; | |
118 | struct statfs *sbp; | |
119 | struct proc *p; | |
120 | { | |
121 | sbp->f_type = MOUNT_PROCFS; | |
122 | sbp->f_bsize = PAGE_SIZE; | |
123 | sbp->f_iosize = PAGE_SIZE; | |
124 | sbp->f_blocks = 1; /* avoid divide by zero in some df's */ | |
125 | sbp->f_bfree = 0; | |
126 | sbp->f_bavail = 0; | |
127 | sbp->f_files = maxproc; /* approx */ | |
128 | sbp->f_ffree = maxproc - nprocs; /* approx */ | |
129 | ||
130 | if (sbp != &mp->mnt_stat) { | |
131 | bcopy(&mp->mnt_stat.f_fsid, &sbp->f_fsid, sizeof(sbp->f_fsid)); | |
132 | bcopy(mp->mnt_stat.f_mntonname, sbp->f_mntonname, MNAMELEN); | |
133 | bcopy(mp->mnt_stat.f_mntfromname, sbp->f_mntfromname, MNAMELEN); | |
134 | } | |
135 | ||
136 | return (0); | |
137 | } | |
138 | ||
139 | ||
140 | procfs_quotactl(mp, cmds, uid, arg, p) | |
141 | struct mount *mp; | |
142 | int cmds; | |
143 | uid_t uid; | |
144 | caddr_t arg; | |
145 | struct proc *p; | |
146 | { | |
147 | ||
148 | return (EOPNOTSUPP); | |
149 | } | |
150 | ||
151 | procfs_sync(mp, waitfor) | |
152 | struct mount *mp; | |
153 | int waitfor; | |
154 | { | |
155 | ||
156 | return (0); | |
157 | } | |
158 | ||
159 | procfs_vget(mp, ino, vpp) | |
160 | struct mount *mp; | |
161 | ino_t ino; | |
162 | struct vnode **vpp; | |
163 | { | |
164 | ||
165 | return (EOPNOTSUPP); | |
166 | } | |
167 | ||
168 | procfs_fhtovp(mp, fhp, vpp) | |
169 | struct mount *mp; | |
170 | struct fid *fhp; | |
171 | struct vnode **vpp; | |
172 | { | |
173 | ||
174 | return (EINVAL); | |
175 | } | |
176 | ||
177 | procfs_vptofh(vp, fhp) | |
178 | struct vnode *vp; | |
179 | struct fid *fhp; | |
180 | { | |
181 | ||
182 | return EINVAL; | |
183 | } | |
184 | ||
185 | procfs_init() | |
186 | { | |
187 | ||
188 | return (0); | |
189 | } | |
190 | ||
191 | struct vfsops procfs_vfsops = { | |
192 | procfs_mount, | |
193 | procfs_start, | |
194 | procfs_unmount, | |
195 | procfs_root, | |
196 | procfs_quotactl, | |
197 | procfs_statfs, | |
198 | procfs_sync, | |
199 | procfs_vget, | |
200 | procfs_fhtovp, | |
201 | procfs_vptofh, | |
202 | procfs_init, | |
203 | }; |