257 if (secpolicy_hyprlofs_control(cr) != 0)
258 return (EPERM);
259
260 if (mvp->v_type != VDIR)
261 return (ENOTDIR);
262
263 if (uap->flags & MS_REMOUNT)
264 return (EBUSY);
265
266 mutex_enter(&mvp->v_lock);
267 if ((uap->flags & MS_OVERLAY) == 0 &&
268 (mvp->v_count != 1 || (mvp->v_flag & VROOT))) {
269 mutex_exit(&mvp->v_lock);
270 return (EBUSY);
271 }
272 mutex_exit(&mvp->v_lock);
273
274 /* Having the resource be anything but "swap" doesn't make sense. */
275 vfs_setresource(vfsp, "swap", 0);
276
277 if (error = pn_get(uap->dir,
278 (uap->flags & MS_SYSSPACE) ? UIO_SYSSPACE : UIO_USERSPACE, &dpn))
279 goto out;
280
281 if ((hm = hyprlofs_memalloc(sizeof (hlfsmount_t), 0)) == NULL) {
282 pn_free(&dpn);
283 error = ENOMEM;
284 goto out;
285 }
286
287 /* Get an available minor device number for this mount */
288 mutex_enter(&hyprlofs_minor_lock);
289 do {
290 hyprlofs_minor = (hyprlofs_minor + 1) & L_MAXMIN32;
291 hm->hlm_dev = makedevice(hyprlofs_major, hyprlofs_minor);
292 } while (vfs_devismounted(hm->hlm_dev));
293 mutex_exit(&hyprlofs_minor_lock);
294
295 /*
296 * Set but don't bother entering the mutex since hlfsmount is not on
297 * the mount list yet.
298 */
|
257 if (secpolicy_hyprlofs_control(cr) != 0)
258 return (EPERM);
259
260 if (mvp->v_type != VDIR)
261 return (ENOTDIR);
262
263 if (uap->flags & MS_REMOUNT)
264 return (EBUSY);
265
266 mutex_enter(&mvp->v_lock);
267 if ((uap->flags & MS_OVERLAY) == 0 &&
268 (mvp->v_count != 1 || (mvp->v_flag & VROOT))) {
269 mutex_exit(&mvp->v_lock);
270 return (EBUSY);
271 }
272 mutex_exit(&mvp->v_lock);
273
274 /* Having the resource be anything but "swap" doesn't make sense. */
275 vfs_setresource(vfsp, "swap", 0);
276
277 if ((error = pn_get(uap->dir,
278 (uap->flags & MS_SYSSPACE) ? UIO_SYSSPACE : UIO_USERSPACE,
279 &dpn)) != 0)
280 goto out;
281
282 if ((hm = hyprlofs_memalloc(sizeof (hlfsmount_t), 0)) == NULL) {
283 pn_free(&dpn);
284 error = ENOMEM;
285 goto out;
286 }
287
288 /* Get an available minor device number for this mount */
289 mutex_enter(&hyprlofs_minor_lock);
290 do {
291 hyprlofs_minor = (hyprlofs_minor + 1) & L_MAXMIN32;
292 hm->hlm_dev = makedevice(hyprlofs_major, hyprlofs_minor);
293 } while (vfs_devismounted(hm->hlm_dev));
294 mutex_exit(&hyprlofs_minor_lock);
295
296 /*
297 * Set but don't bother entering the mutex since hlfsmount is not on
298 * the mount list yet.
299 */
|