This source file includes following definitions.
- procfs_mount
- procfs_unmount
- procfs_root
- procfs_start
- procfs_statfs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43 #include <sys/param.h>
44 #include <sys/time.h>
45 #include <sys/kernel.h>
46 #include <sys/systm.h>
47 #include <sys/proc.h>
48 #include <sys/buf.h>
49 #include <sys/syslog.h>
50 #include <sys/mount.h>
51 #include <sys/signalvar.h>
52 #include <sys/vnode.h>
53 #include <sys/malloc.h>
54
55 #include <miscfs/procfs/procfs.h>
56
57 #include <uvm/uvm_extern.h>
58
59 int procfs_mount(struct mount *, const char *, void *,
60 struct nameidata *, struct proc *);
61 int procfs_start(struct mount *, int, struct proc *);
62 int procfs_unmount(struct mount *, int, struct proc *);
63 int procfs_statfs(struct mount *, struct statfs *, struct proc *);
64
65
66
67
68
69
70 int
71 procfs_mount(struct mount *mp, const char *path, void *data, struct nameidata *ndp,
72 struct proc *p)
73 {
74 size_t size;
75 struct procfsmount *pmnt;
76 struct procfs_args args;
77 int error;
78
79 if (UIO_MX & (UIO_MX-1)) {
80 log(LOG_ERR, "procfs: invalid directory entry size");
81 return (EINVAL);
82 }
83
84 if (mp->mnt_flag & MNT_UPDATE)
85 return (EOPNOTSUPP);
86
87 if (data != NULL) {
88 error = copyin(data, &args, sizeof args);
89 if (error != 0)
90 return (error);
91
92 if (args.version != PROCFS_ARGSVERSION)
93 return (EINVAL);
94 } else
95 args.flags = 0;
96
97 mp->mnt_flag |= MNT_LOCAL;
98 pmnt = (struct procfsmount *) malloc(sizeof(struct procfsmount),
99 M_MISCFSMNT, M_WAITOK);
100
101 mp->mnt_data = pmnt;
102 vfs_getnewfsid(mp);
103
104 (void) copyinstr(path, mp->mnt_stat.f_mntonname, MNAMELEN - 1, &size);
105 bzero(mp->mnt_stat.f_mntonname + size, MNAMELEN - size);
106 bzero(mp->mnt_stat.f_mntfromname, MNAMELEN);
107 bcopy("procfs", mp->mnt_stat.f_mntfromname, sizeof("procfs"));
108 bcopy(&args, &mp->mnt_stat.mount_info.procfs_args, sizeof(args));
109
110 #ifdef notyet
111 pmnt->pmnt_exechook = exechook_establish(procfs_revoke_vnodes, mp);
112 #endif
113 pmnt->pmnt_flags = args.flags;
114
115 return (0);
116 }
117
118
119
120
121 int
122 procfs_unmount(struct mount *mp, int mntflags, struct proc *p)
123 {
124 int error;
125 extern int doforce;
126 int flags = 0;
127
128 if (mntflags & MNT_FORCE) {
129
130 if (!doforce)
131 return (EINVAL);
132 flags |= FORCECLOSE;
133 }
134
135 if ((error = vflush(mp, 0, flags)) != 0)
136 return (error);
137
138 free(VFSTOPROC(mp), M_MISCFSMNT);
139 mp->mnt_data = 0;
140
141 return (0);
142 }
143
144 int
145 procfs_root(struct mount *mp, struct vnode **vpp)
146 {
147 int error;
148
149 error = procfs_allocvp(mp, vpp, 0, Proot);
150 if (error)
151 return (error);
152 vn_lock(*vpp, LK_EXCLUSIVE, curproc);
153
154 return (0);
155 }
156
157
158 int
159 procfs_start(struct mount *mp, int flags, struct proc *p)
160 {
161
162 return (0);
163 }
164
165
166
167
168 int
169 procfs_statfs(struct mount *mp, struct statfs *sbp, struct proc *p)
170 {
171 struct vmtotal vmtotals;
172
173 uvm_total(&vmtotals);
174 sbp->f_bsize = PAGE_SIZE;
175 sbp->f_iosize = PAGE_SIZE;
176 sbp->f_blocks = vmtotals.t_vm;
177 sbp->f_bfree = vmtotals.t_vm - vmtotals.t_avm;
178 sbp->f_bavail = 0;
179 sbp->f_files = maxproc;
180 sbp->f_ffree = maxproc - nprocs;
181 if (sbp != &mp->mnt_stat) {
182 bcopy(&mp->mnt_stat.f_fsid, &sbp->f_fsid, sizeof(sbp->f_fsid));
183 bcopy(mp->mnt_stat.f_mntonname, sbp->f_mntonname, MNAMELEN);
184 bcopy(mp->mnt_stat.f_mntfromname, sbp->f_mntfromname, MNAMELEN);
185 bcopy(&mp->mnt_stat.mount_info.procfs_args,
186 &sbp->mount_info.procfs_args, sizeof(struct procfs_args));
187 }
188 strncpy(sbp->f_fstypename, mp->mnt_vfc->vfc_name, MFSNAMELEN);
189 return (0);
190 }
191
192
193 #define procfs_sync ((int (*)(struct mount *, int, struct ucred *, \
194 struct proc *))nullop)
195
196 #define procfs_fhtovp ((int (*)(struct mount *, struct fid *, \
197 struct vnode **))eopnotsupp)
198 #define procfs_quotactl ((int (*)(struct mount *, int, uid_t, caddr_t, \
199 struct proc *))eopnotsupp)
200 #define procfs_sysctl ((int (*)(int *, u_int, void *, size_t *, void *, \
201 size_t, struct proc *))eopnotsupp)
202 #define procfs_vget ((int (*)(struct mount *, ino_t, struct vnode **)) \
203 eopnotsupp)
204 #define procfs_vptofh ((int (*)(struct vnode *, struct fid *))eopnotsupp)
205 #define procfs_checkexp ((int (*)(struct mount *, struct mbuf *, \
206 int *, struct ucred **))eopnotsupp)
207
208 const struct vfsops procfs_vfsops = {
209 procfs_mount,
210 procfs_start,
211 procfs_unmount,
212 procfs_root,
213 procfs_quotactl,
214 procfs_statfs,
215 procfs_sync,
216 procfs_vget,
217 procfs_fhtovp,
218 procfs_vptofh,
219 procfs_init,
220 procfs_sysctl,
221 procfs_checkexp
222 };