This source file includes following definitions.
- portal_mount
- portal_start
- portal_unmount
- portal_root
- portal_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/systm.h>
45 #include <sys/time.h>
46 #include <sys/types.h>
47 #include <sys/proc.h>
48 #include <sys/filedesc.h>
49 #include <sys/file.h>
50 #include <sys/vnode.h>
51 #include <sys/mount.h>
52 #include <sys/namei.h>
53 #include <sys/malloc.h>
54 #include <sys/mbuf.h>
55 #include <sys/socket.h>
56 #include <sys/socketvar.h>
57 #include <sys/protosw.h>
58 #include <sys/domain.h>
59 #include <sys/un.h>
60 #include <miscfs/portal/portal.h>
61
62 #define portal_init ((int (*)(struct vfsconf *))nullop)
63
64 int portal_mount(struct mount *, const char *, void *,
65 struct nameidata *, struct proc *);
66 int portal_start(struct mount *, int, struct proc *);
67 int portal_unmount(struct mount *, int, struct proc *);
68 int portal_root(struct mount *, struct vnode **);
69 int portal_statfs(struct mount *, struct statfs *, struct proc *);
70
71
72
73
74
75 int
76 portal_mount(struct mount *mp, const char *path, void *data, struct nameidata *ndp,
77 struct proc *p)
78 {
79 struct file *fp;
80 struct portal_args args;
81 struct portalmount *fmp;
82 struct socket *so;
83 struct vnode *rvp;
84 size_t size;
85 int error;
86
87
88
89
90 if (mp->mnt_flag & MNT_UPDATE)
91 return (EOPNOTSUPP);
92
93 error = copyin(data, &args, sizeof(struct portal_args));
94 if (error)
95 return (error);
96
97 if ((error = getsock(p->p_fd, args.pa_socket, &fp)) != 0)
98 return (error);
99 so = (struct socket *) fp->f_data;
100 if (so->so_proto->pr_domain->dom_family != AF_UNIX) {
101 FRELE(fp);
102 return (ESOCKTNOSUPPORT);
103 }
104
105 error = getnewvnode(VT_PORTAL, mp, portal_vnodeop_p, &rvp);
106 if (error) {
107 FRELE(fp);
108 return (error);
109 }
110 MALLOC(rvp->v_data, void *, sizeof(struct portalnode),
111 M_TEMP, M_WAITOK);
112
113 fmp = (struct portalmount *) malloc(sizeof(struct portalmount),
114 M_MISCFSMNT, M_WAITOK);
115 rvp->v_type = VDIR;
116 rvp->v_flag |= VROOT;
117 VTOPORTAL(rvp)->pt_arg = 0;
118 VTOPORTAL(rvp)->pt_size = 0;
119 VTOPORTAL(rvp)->pt_fileid = PORTAL_ROOTFILEID;
120 fmp->pm_root = rvp;
121 fmp->pm_server = fp;
122 fp->f_count++;
123 FRELE(fp);
124
125 mp->mnt_flag |= MNT_LOCAL;
126 mp->mnt_data = fmp;
127 vfs_getnewfsid(mp);
128
129 (void) copyinstr(path, mp->mnt_stat.f_mntonname, MNAMELEN - 1, &size);
130 bzero(mp->mnt_stat.f_mntonname + size, MNAMELEN - size);
131 (void) copyinstr(args.pa_config, mp->mnt_stat.f_mntfromname,
132 MNAMELEN - 1, &size);
133 bzero(mp->mnt_stat.f_mntfromname + size, MNAMELEN - size);
134 return (0);
135 }
136
137 int
138 portal_start(struct mount *mp, int flags, struct proc *p)
139 {
140
141 return (0);
142 }
143
144 int
145 portal_unmount(struct mount *mp, int mntflags, struct proc *p)
146 {
147 struct vnode *rvp = VFSTOPORTAL(mp)->pm_root;
148 int error, flags = 0;
149
150 if (mntflags & MNT_FORCE) {
151 flags |= FORCECLOSE;
152 }
153
154
155
156
157
158
159 #ifdef notyet
160 mntflushbuf(mp, 0);
161 if (mntinvalbuf(mp, 1))
162 return (EBUSY);
163 #endif
164 if (rvp->v_usecount > 1 && !(flags & FORCECLOSE))
165 return (EBUSY);
166 if ((error = vflush(mp, rvp, flags)) != 0)
167 return (error);
168
169
170
171
172 vrele(rvp);
173
174
175
176 vgone(rvp);
177
178
179
180
181
182 FREF(VFSTOPORTAL(mp)->pm_server);
183 soshutdown((struct socket *) VFSTOPORTAL(mp)->pm_server->f_data, 2);
184
185
186
187
188 closef(VFSTOPORTAL(mp)->pm_server, NULL);
189
190
191
192 free(mp->mnt_data, M_MISCFSMNT);
193 mp->mnt_data = 0;
194 return (0);
195 }
196
197 int
198 portal_root(struct mount *mp, struct vnode **vpp)
199 {
200 struct vnode *vp;
201 struct proc *p = curproc;
202
203
204
205
206 vp = VFSTOPORTAL(mp)->pm_root;
207 VREF(vp);
208 vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p);
209 *vpp = vp;
210 return (0);
211 }
212
213 int
214 portal_statfs(struct mount *mp, struct statfs *sbp, struct proc *p)
215 {
216
217 sbp->f_bsize = DEV_BSIZE;
218 sbp->f_iosize = DEV_BSIZE;
219 sbp->f_blocks = 2;
220 sbp->f_bfree = 0;
221 sbp->f_bavail = 0;
222 sbp->f_files = 1;
223 sbp->f_ffree = 0;
224 if (sbp != &mp->mnt_stat) {
225 bcopy(&mp->mnt_stat.f_fsid, &sbp->f_fsid, sizeof(sbp->f_fsid));
226 bcopy(mp->mnt_stat.f_mntonname, sbp->f_mntonname, MNAMELEN);
227 bcopy(mp->mnt_stat.f_mntfromname, sbp->f_mntfromname, MNAMELEN);
228 }
229 strncpy(sbp->f_fstypename, mp->mnt_vfc->vfc_name, MFSNAMELEN);
230 return (0);
231 }
232
233
234 #define portal_sync ((int (*)(struct mount *, int, struct ucred *, \
235 struct proc *))nullop)
236
237 #define portal_fhtovp ((int (*)(struct mount *, struct fid *, \
238 struct vnode **))eopnotsupp)
239 #define portal_quotactl ((int (*)(struct mount *, int, uid_t, caddr_t, \
240 struct proc *))eopnotsupp)
241 #define portal_sysctl ((int (*)(int *, u_int, void *, size_t *, void *, \
242 size_t, struct proc *))eopnotsupp)
243 #define portal_vget ((int (*)(struct mount *, ino_t, struct vnode **)) \
244 eopnotsupp)
245 #define portal_vptofh ((int (*)(struct vnode *, struct fid *))eopnotsupp)
246 #define portal_checkexp ((int (*)(struct mount *, struct mbuf *, \
247 int *, struct ucred **))eopnotsupp)
248
249 const struct vfsops portal_vfsops = {
250 portal_mount,
251 portal_start,
252 portal_unmount,
253 portal_root,
254 portal_quotactl,
255 portal_statfs,
256 portal_sync,
257 portal_vget,
258 portal_fhtovp,
259 portal_vptofh,
260 portal_init,
261 portal_sysctl,
262 portal_checkexp
263 };