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 | * | |
d9e87534 | 11 | * @(#)procfs_vfsops.c 8.6 (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> | |
d9e87534 | 22 | #include <sys/systm.h> |
76434cf5 JSP |
23 | #include <sys/time.h> |
24 | #include <sys/kernel.h> | |
25 | #include <sys/proc.h> | |
26 | #include <sys/buf.h> | |
27 | #include <sys/syslog.h> | |
28 | #include <sys/mount.h> | |
29 | #include <sys/signalvar.h> | |
30 | #include <sys/vnode.h> | |
31 | #include <miscfs/procfs/procfs.h> | |
32 | #include <vm/vm.h> /* for PAGE_SIZE */ | |
33 | ||
34 | /* | |
35 | * VFS Operations. | |
36 | * | |
37 | * mount system call | |
38 | */ | |
39 | /* ARGSUSED */ | |
40 | procfs_mount(mp, path, data, ndp, p) | |
41 | struct mount *mp; | |
42 | char *path; | |
43 | caddr_t data; | |
44 | struct nameidata *ndp; | |
45 | struct proc *p; | |
46 | { | |
47 | u_int size; | |
76434cf5 JSP |
48 | |
49 | if (UIO_MX & (UIO_MX-1)) { | |
50 | log(LOG_ERR, "procfs: invalid directory entry size"); | |
51 | return (EINVAL); | |
52 | } | |
53 | ||
54 | if (mp->mnt_flag & MNT_UPDATE) | |
55 | return (EOPNOTSUPP); | |
56 | ||
57 | mp->mnt_flag |= MNT_LOCAL; | |
58 | mp->mnt_data = 0; | |
d9e87534 | 59 | vfs_getnewfsid(mp); |
76434cf5 JSP |
60 | |
61 | (void) copyinstr(path, (caddr_t)mp->mnt_stat.f_mntonname, MNAMELEN, &size); | |
62 | bzero(mp->mnt_stat.f_mntonname + size, MNAMELEN - size); | |
63 | ||
487e3d29 JSP |
64 | size = sizeof("procfs") - 1; |
65 | bcopy("procfs", mp->mnt_stat.f_mntfromname, size); | |
76434cf5 JSP |
66 | bzero(mp->mnt_stat.f_mntfromname + size, MNAMELEN - size); |
67 | ||
68 | return (0); | |
69 | } | |
70 | ||
71 | /* | |
72 | * unmount system call | |
73 | */ | |
74 | procfs_unmount(mp, mntflags, p) | |
75 | struct mount *mp; | |
76 | int mntflags; | |
77 | struct proc *p; | |
78 | { | |
79 | int error; | |
80 | extern int doforce; | |
81 | int flags = 0; | |
82 | ||
83 | if (mntflags & MNT_FORCE) { | |
84 | /* procfs can never be rootfs so don't check for it */ | |
85 | if (!doforce) | |
86 | return (EINVAL); | |
87 | flags |= FORCECLOSE; | |
88 | } | |
89 | ||
90 | if (error = vflush(mp, 0, flags)) | |
91 | return (error); | |
92 | ||
93 | return (0); | |
94 | } | |
95 | ||
96 | procfs_root(mp, vpp) | |
97 | struct mount *mp; | |
98 | struct vnode **vpp; | |
99 | { | |
76434cf5 | 100 | |
679a7c6b | 101 | return (procfs_allocvp(mp, vpp, 0, Proot)); |
76434cf5 JSP |
102 | } |
103 | ||
76434cf5 JSP |
104 | /* ARGSUSED */ |
105 | procfs_start(mp, flags, p) | |
106 | struct mount *mp; | |
107 | int flags; | |
108 | struct proc *p; | |
109 | { | |
110 | ||
111 | return (0); | |
112 | } | |
113 | ||
114 | /* | |
115 | * Get file system statistics. | |
116 | */ | |
117 | procfs_statfs(mp, sbp, p) | |
118 | struct mount *mp; | |
119 | struct statfs *sbp; | |
120 | struct proc *p; | |
121 | { | |
76434cf5 JSP |
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) { | |
d9e87534 | 131 | sbp->f_type = mp->mnt_vfc->vfc_typenum; |
76434cf5 JSP |
132 | bcopy(&mp->mnt_stat.f_fsid, &sbp->f_fsid, sizeof(sbp->f_fsid)); |
133 | bcopy(mp->mnt_stat.f_mntonname, sbp->f_mntonname, MNAMELEN); | |
134 | bcopy(mp->mnt_stat.f_mntfromname, sbp->f_mntfromname, MNAMELEN); | |
135 | } | |
136 | ||
137 | return (0); | |
138 | } | |
139 | ||
d9e87534 KM |
140 | procfs_init(vfsp) |
141 | struct vfsconf *vfsp; | |
76434cf5 JSP |
142 | { |
143 | ||
144 | return (0); | |
145 | } | |
146 | ||
d9e87534 KM |
147 | #define procfs_fhtovp ((int (*) __P((struct mount *, struct fid *, \ |
148 | struct mbuf *, struct vnode **, int *, struct ucred **)))einval) | |
149 | #define procfs_quotactl ((int (*) __P((struct mount *, int, uid_t, caddr_t, \ | |
150 | struct proc *)))eopnotsupp) | |
151 | #define procfs_sync ((int (*) __P((struct mount *, int, struct ucred *, \ | |
152 | struct proc *)))nullop) | |
153 | #define procfs_sysctl ((int (*) __P((int *, u_int, void *, size_t *, void *, \ | |
154 | size_t, struct proc *)))eopnotsupp) | |
155 | #define procfs_vget ((int (*) __P((struct mount *, ino_t, struct vnode **))) \ | |
156 | eopnotsupp) | |
157 | #define procfs_vptofh ((int (*) __P((struct vnode *, struct fid *)))einval) | |
76434cf5 JSP |
158 | |
159 | struct vfsops procfs_vfsops = { | |
160 | procfs_mount, | |
161 | procfs_start, | |
162 | procfs_unmount, | |
163 | procfs_root, | |
164 | procfs_quotactl, | |
165 | procfs_statfs, | |
166 | procfs_sync, | |
167 | procfs_vget, | |
168 | procfs_fhtovp, | |
169 | procfs_vptofh, | |
170 | procfs_init, | |
d9e87534 | 171 | procfs_sysctl, |
76434cf5 | 172 | }; |