2010-01-08 14:35:07 +03:00
|
|
|
/* $NetBSD: ptyfs_vfsops.c,v 1.42 2010/01/08 11:35:09 pooka Exp $ */
|
2004-11-11 21:56:25 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (c) 1992, 1993, 1995
|
|
|
|
* The Regents of the University of California. All rights reserved.
|
|
|
|
*
|
|
|
|
* This code is derived from software donated to Berkeley by
|
|
|
|
* Jan-Simon Pendry.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. Neither the name of the University nor the names of its contributors
|
|
|
|
* may be used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Pseudo-tty Filesystem
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <sys/cdefs.h>
|
2010-01-08 14:35:07 +03:00
|
|
|
__KERNEL_RCSID(0, "$NetBSD: ptyfs_vfsops.c,v 1.42 2010/01/08 11:35:09 pooka Exp $");
|
2004-11-11 21:56:25 +03:00
|
|
|
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/sysctl.h>
|
|
|
|
#include <sys/conf.h>
|
|
|
|
#include <sys/proc.h>
|
|
|
|
#include <sys/vnode.h>
|
|
|
|
#include <sys/mount.h>
|
|
|
|
#include <sys/namei.h>
|
2004-11-25 08:15:10 +03:00
|
|
|
#include <sys/stat.h>
|
2004-11-11 21:56:25 +03:00
|
|
|
#include <sys/dirent.h>
|
|
|
|
#include <sys/malloc.h>
|
|
|
|
#include <sys/syslog.h>
|
|
|
|
#include <sys/select.h>
|
2006-04-13 21:44:24 +04:00
|
|
|
#include <sys/filedesc.h>
|
2004-11-11 21:56:25 +03:00
|
|
|
#include <sys/tty.h>
|
|
|
|
#include <sys/pty.h>
|
2006-05-15 01:31:52 +04:00
|
|
|
#include <sys/kauth.h>
|
2008-05-10 06:26:09 +04:00
|
|
|
#include <sys/module.h>
|
2004-11-11 21:56:25 +03:00
|
|
|
|
2004-11-11 22:19:59 +03:00
|
|
|
#include <fs/ptyfs/ptyfs.h>
|
2008-01-28 17:31:15 +03:00
|
|
|
#include <miscfs/genfs/genfs.h>
|
2004-11-11 21:56:25 +03:00
|
|
|
#include <miscfs/specfs/specdev.h>
|
|
|
|
|
2008-05-10 06:26:09 +04:00
|
|
|
MODULE(MODULE_CLASS_VFS, ptyfs, NULL);
|
|
|
|
|
2007-06-30 13:37:53 +04:00
|
|
|
MALLOC_JUSTDEFINE(M_PTYFSMNT, "ptyfs mount", "ptyfs mount structures");
|
2007-09-24 04:42:12 +04:00
|
|
|
MALLOC_JUSTDEFINE(M_PTYFSTMP, "ptyfs temp", "ptyfs temporary structures");
|
2004-11-11 21:56:25 +03:00
|
|
|
|
2007-08-01 01:14:15 +04:00
|
|
|
VFS_PROTOS(ptyfs);
|
2004-11-11 21:56:25 +03:00
|
|
|
|
2008-06-28 05:34:05 +04:00
|
|
|
static struct sysctllog *ptyfs_sysctl_log;
|
|
|
|
|
2005-12-11 15:16:03 +03:00
|
|
|
static int ptyfs__allocvp(struct ptm_pty *, struct lwp *, struct vnode **,
|
2004-11-11 21:56:25 +03:00
|
|
|
dev_t, char);
|
2006-04-13 21:44:24 +04:00
|
|
|
static int ptyfs__makename(struct ptm_pty *, struct lwp *, char *, size_t,
|
|
|
|
dev_t, char);
|
2006-07-24 02:06:03 +04:00
|
|
|
static void ptyfs__getvattr(struct ptm_pty *, struct lwp *, struct vattr *);
|
2004-11-11 21:56:25 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* ptm glue: When we mount, we make ptm point to us.
|
|
|
|
*/
|
|
|
|
struct ptm_pty *ptyfs_save_ptm;
|
2005-10-01 09:30:12 +04:00
|
|
|
static int ptyfs_count;
|
2004-11-11 21:56:25 +03:00
|
|
|
|
|
|
|
struct ptm_pty ptm_ptyfspty = {
|
|
|
|
ptyfs__allocvp,
|
|
|
|
ptyfs__makename,
|
2004-11-25 08:15:10 +03:00
|
|
|
ptyfs__getvattr,
|
2004-11-11 21:56:25 +03:00
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
2009-03-15 19:43:55 +03:00
|
|
|
static const char *
|
|
|
|
ptyfs__getpath(struct lwp *l, const struct mount *mp)
|
|
|
|
{
|
|
|
|
#define MAXBUF (sizeof(mp->mnt_stat.f_mntonname) + 32)
|
|
|
|
struct cwdinfo *cwdi = l->l_proc->p_cwdi;
|
|
|
|
char *buf;
|
|
|
|
const char *rv;
|
|
|
|
size_t len;
|
|
|
|
char *bp;
|
|
|
|
int error;
|
|
|
|
struct ptyfsmount *pmnt = mp->mnt_data;
|
|
|
|
|
|
|
|
rv = mp->mnt_stat.f_mntonname;
|
|
|
|
if (cwdi->cwdi_rdir == NULL ||
|
|
|
|
(pmnt->pmnt_flags & PTYFSMNT_CHROOT) == 0)
|
|
|
|
return rv;
|
|
|
|
|
|
|
|
buf = malloc(MAXBUF, M_TEMP, M_WAITOK);
|
|
|
|
bp = buf + MAXBUF;
|
|
|
|
*--bp = '\0';
|
|
|
|
error = getcwd_common(cwdi->cwdi_rdir, rootvnode, &bp,
|
|
|
|
buf, MAXBUF / 2, 0, l);
|
|
|
|
if (error) /* XXX */
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
len = strlen(bp);
|
|
|
|
if (len < sizeof(mp->mnt_stat.f_mntonname)) /* XXX */
|
|
|
|
rv += len;
|
|
|
|
out:
|
|
|
|
free(buf, M_TEMP);
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2004-11-11 21:56:25 +03:00
|
|
|
static int
|
2006-04-13 21:44:24 +04:00
|
|
|
ptyfs__makename(struct ptm_pty *pt, struct lwp *l, char *tbuf, size_t bufsiz,
|
|
|
|
dev_t dev, char ms)
|
2004-11-11 21:56:25 +03:00
|
|
|
{
|
|
|
|
struct mount *mp = pt->arg;
|
|
|
|
size_t len;
|
|
|
|
|
|
|
|
switch (ms) {
|
|
|
|
case 'p':
|
|
|
|
/* We don't provide access to the master, should we? */
|
2005-05-30 01:00:29 +04:00
|
|
|
len = snprintf(tbuf, bufsiz, "/dev/null");
|
2004-11-11 21:56:25 +03:00
|
|
|
break;
|
|
|
|
case 't':
|
2009-03-15 19:43:55 +03:00
|
|
|
len = snprintf(tbuf, bufsiz, "%s/%llu", ptyfs__getpath(l, mp),
|
2009-01-11 05:45:45 +03:00
|
|
|
(unsigned long long)minor(dev));
|
2004-11-11 21:56:25 +03:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return len >= bufsiz ? ENOSPC : 0;
|
|
|
|
}
|
|
|
|
|
2004-11-25 08:15:10 +03:00
|
|
|
|
2004-11-11 21:56:25 +03:00
|
|
|
static int
|
|
|
|
/*ARGSUSED*/
|
2005-12-11 15:16:03 +03:00
|
|
|
ptyfs__allocvp(struct ptm_pty *pt, struct lwp *l, struct vnode **vpp,
|
2004-11-11 21:56:25 +03:00
|
|
|
dev_t dev, char ms)
|
|
|
|
{
|
|
|
|
struct mount *mp = pt->arg;
|
|
|
|
ptyfstype type;
|
|
|
|
|
|
|
|
switch (ms) {
|
|
|
|
case 'p':
|
|
|
|
type = PTYFSptc;
|
|
|
|
break;
|
|
|
|
case 't':
|
|
|
|
type = PTYFSpts;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return EINVAL;
|
|
|
|
}
|
|
|
|
|
2005-12-11 15:16:03 +03:00
|
|
|
return ptyfs_allocvp(mp, vpp, type, minor(dev), l);
|
2004-11-11 21:56:25 +03:00
|
|
|
}
|
|
|
|
|
2004-11-25 08:15:10 +03:00
|
|
|
|
|
|
|
static void
|
2006-07-24 02:06:03 +04:00
|
|
|
ptyfs__getvattr(struct ptm_pty *pt, struct lwp *l, struct vattr *vattr)
|
2004-11-25 08:15:10 +03:00
|
|
|
{
|
|
|
|
struct mount *mp = pt->arg;
|
|
|
|
struct ptyfsmount *pmnt = VFSTOPTY(mp);
|
2010-01-08 14:35:07 +03:00
|
|
|
vattr_null(vattr);
|
2004-11-25 08:15:10 +03:00
|
|
|
/* get real uid */
|
2006-07-24 02:06:03 +04:00
|
|
|
vattr->va_uid = kauth_cred_getuid(l->l_cred);
|
2004-11-25 08:15:10 +03:00
|
|
|
vattr->va_gid = pmnt->pmnt_gid;
|
|
|
|
vattr->va_mode = pmnt->pmnt_mode;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-11-11 21:56:25 +03:00
|
|
|
void
|
|
|
|
ptyfs_init(void)
|
|
|
|
{
|
2007-06-30 13:37:53 +04:00
|
|
|
|
2004-11-11 21:56:25 +03:00
|
|
|
malloc_type_attach(M_PTYFSMNT);
|
2007-09-24 04:42:12 +04:00
|
|
|
malloc_type_attach(M_PTYFSTMP);
|
2004-11-11 21:56:25 +03:00
|
|
|
ptyfs_hashinit();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ptyfs_reinit(void)
|
|
|
|
{
|
|
|
|
ptyfs_hashreinit();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ptyfs_done(void)
|
|
|
|
{
|
2007-06-30 13:37:53 +04:00
|
|
|
|
2004-11-11 21:56:25 +03:00
|
|
|
ptyfs_hashdone();
|
2007-09-24 04:42:12 +04:00
|
|
|
malloc_type_detach(M_PTYFSTMP);
|
2007-06-30 13:37:53 +04:00
|
|
|
malloc_type_detach(M_PTYFSMNT);
|
2004-11-11 21:56:25 +03:00
|
|
|
}
|
|
|
|
|
2009-03-21 04:11:53 +03:00
|
|
|
#define OSIZE sizeof(struct { int f; gid_t g; mode_t m; })
|
2004-11-11 21:56:25 +03:00
|
|
|
/*
|
|
|
|
* Mount the Pseudo tty params filesystem
|
|
|
|
*/
|
|
|
|
int
|
2007-11-26 22:01:26 +03:00
|
|
|
ptyfs_mount(struct mount *mp, const char *path, void *data, size_t *data_len)
|
2004-11-11 21:56:25 +03:00
|
|
|
{
|
2007-11-26 22:01:26 +03:00
|
|
|
struct lwp *l = curlwp;
|
2004-11-11 21:56:25 +03:00
|
|
|
int error = 0;
|
2004-11-25 08:15:10 +03:00
|
|
|
struct ptyfsmount *pmnt;
|
2007-07-12 23:35:32 +04:00
|
|
|
struct ptyfs_args *args = data;
|
|
|
|
|
2009-03-21 04:11:53 +03:00
|
|
|
if (*data_len != sizeof *args && *data_len != OSIZE)
|
2007-07-12 23:35:32 +04:00
|
|
|
return EINVAL;
|
2004-11-11 21:56:25 +03:00
|
|
|
|
|
|
|
if (UIO_MX & (UIO_MX - 1)) {
|
|
|
|
log(LOG_ERR, "ptyfs: invalid directory entry size");
|
|
|
|
return EINVAL;
|
|
|
|
}
|
|
|
|
|
2004-11-25 08:15:10 +03:00
|
|
|
if (mp->mnt_flag & MNT_GETARGS) {
|
|
|
|
pmnt = VFSTOPTY(mp);
|
|
|
|
if (pmnt == NULL)
|
|
|
|
return EIO;
|
2007-07-12 23:35:32 +04:00
|
|
|
args->mode = pmnt->pmnt_mode;
|
|
|
|
args->gid = pmnt->pmnt_gid;
|
2009-03-15 19:43:55 +03:00
|
|
|
if (args->version >= PTYFS_ARGSVERSION) {
|
|
|
|
args->flags = pmnt->pmnt_flags;
|
|
|
|
*data_len = sizeof *args;
|
|
|
|
} else {
|
2009-03-21 04:11:53 +03:00
|
|
|
*data_len = OSIZE;
|
2009-03-15 19:43:55 +03:00
|
|
|
}
|
2007-07-12 23:35:32 +04:00
|
|
|
return 0;
|
2004-11-25 08:15:10 +03:00
|
|
|
}
|
|
|
|
|
2006-04-28 23:17:45 +04:00
|
|
|
/* Don't allow more than one mount */
|
|
|
|
if (ptyfs_count)
|
|
|
|
return EBUSY;
|
|
|
|
|
2004-11-11 21:56:25 +03:00
|
|
|
if (mp->mnt_flag & MNT_UPDATE)
|
|
|
|
return EOPNOTSUPP;
|
|
|
|
|
2009-03-21 04:11:53 +03:00
|
|
|
if (args->version > PTYFS_ARGSVERSION)
|
2005-05-11 21:38:54 +04:00
|
|
|
return EINVAL;
|
2004-11-25 08:15:10 +03:00
|
|
|
|
2007-09-24 04:42:12 +04:00
|
|
|
pmnt = malloc(sizeof(struct ptyfsmount), M_PTYFSMNT, M_WAITOK);
|
2004-11-25 08:15:10 +03:00
|
|
|
|
|
|
|
mp->mnt_data = pmnt;
|
2007-07-12 23:35:32 +04:00
|
|
|
pmnt->pmnt_gid = args->gid;
|
|
|
|
pmnt->pmnt_mode = args->mode;
|
2009-03-15 19:43:55 +03:00
|
|
|
if (args->version >= PTYFS_ARGSVERSION)
|
|
|
|
pmnt->pmnt_flags = args->flags;
|
|
|
|
else
|
|
|
|
pmnt->pmnt_flags = 0;
|
2004-11-11 21:56:25 +03:00
|
|
|
mp->mnt_flag |= MNT_LOCAL;
|
|
|
|
vfs_getnewfsid(mp);
|
|
|
|
|
|
|
|
if ((error = set_statvfs_info(path, UIO_USERSPACE, "ptyfs",
|
2007-07-17 15:19:31 +04:00
|
|
|
UIO_SYSSPACE, mp->mnt_op->vfs_name, mp, l)) != 0) {
|
2008-05-13 09:36:43 +04:00
|
|
|
free(pmnt, M_PTYFSMNT);
|
2004-11-11 21:56:25 +03:00
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Point pty access to us */
|
|
|
|
|
|
|
|
ptm_ptyfspty.arg = mp;
|
|
|
|
ptyfs_save_ptm = pty_sethandler(&ptm_ptyfspty);
|
2005-10-01 09:30:12 +04:00
|
|
|
ptyfs_count++;
|
2004-11-11 21:56:25 +03:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*ARGSUSED*/
|
|
|
|
int
|
2007-11-26 22:01:26 +03:00
|
|
|
ptyfs_start(struct mount *mp, int flags)
|
2004-11-11 21:56:25 +03:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*ARGSUSED*/
|
|
|
|
int
|
2007-11-26 22:01:26 +03:00
|
|
|
ptyfs_unmount(struct mount *mp, int mntflags)
|
2004-11-11 21:56:25 +03:00
|
|
|
{
|
|
|
|
int error;
|
|
|
|
int flags = 0;
|
|
|
|
|
|
|
|
if (mntflags & MNT_FORCE)
|
|
|
|
flags |= FORCECLOSE;
|
|
|
|
|
|
|
|
if ((error = vflush(mp, 0, flags)) != 0)
|
|
|
|
return (error);
|
|
|
|
|
|
|
|
/* Restore where pty access was pointing */
|
|
|
|
(void)pty_sethandler(ptyfs_save_ptm);
|
|
|
|
ptyfs_save_ptm = NULL;
|
2005-09-29 18:45:56 +04:00
|
|
|
ptm_ptyfspty.arg = NULL;
|
2004-11-25 08:15:10 +03:00
|
|
|
|
2004-11-11 21:56:25 +03:00
|
|
|
/*
|
2004-11-25 08:15:10 +03:00
|
|
|
* Finally, throw away the ptyfsmount structure
|
2004-11-11 21:56:25 +03:00
|
|
|
*/
|
2008-05-13 09:36:43 +04:00
|
|
|
free(mp->mnt_data, M_PTYFSMNT);
|
2008-05-13 12:31:12 +04:00
|
|
|
mp->mnt_data = NULL;
|
2005-10-01 09:30:12 +04:00
|
|
|
ptyfs_count--;
|
2004-11-25 08:15:10 +03:00
|
|
|
|
2004-11-11 21:56:25 +03:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
ptyfs_root(struct mount *mp, struct vnode **vpp)
|
|
|
|
{
|
|
|
|
/* setup "." */
|
|
|
|
return ptyfs_allocvp(mp, vpp, PTYFSroot, 0, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*ARGSUSED*/
|
|
|
|
int
|
2006-11-16 04:32:37 +03:00
|
|
|
ptyfs_sync(struct mount *mp, int waitfor,
|
2007-11-26 22:01:26 +03:00
|
|
|
kauth_cred_t uc)
|
2004-11-11 21:56:25 +03:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Kernfs flat namespace lookup.
|
|
|
|
* Currently unsupported.
|
|
|
|
*/
|
|
|
|
/*ARGSUSED*/
|
|
|
|
int
|
2006-11-16 04:32:37 +03:00
|
|
|
ptyfs_vget(struct mount *mp, ino_t ino,
|
|
|
|
struct vnode **vpp)
|
2004-11-11 21:56:25 +03:00
|
|
|
{
|
|
|
|
return EOPNOTSUPP;
|
|
|
|
}
|
|
|
|
|
|
|
|
extern const struct vnodeopv_desc ptyfs_vnodeop_opv_desc;
|
|
|
|
|
|
|
|
const struct vnodeopv_desc * const ptyfs_vnodeopv_descs[] = {
|
|
|
|
&ptyfs_vnodeop_opv_desc,
|
|
|
|
NULL,
|
|
|
|
};
|
|
|
|
|
|
|
|
struct vfsops ptyfs_vfsops = {
|
|
|
|
MOUNT_PTYFS,
|
2007-07-12 23:35:32 +04:00
|
|
|
sizeof (struct ptyfs_args),
|
2004-11-11 21:56:25 +03:00
|
|
|
ptyfs_mount,
|
|
|
|
ptyfs_start,
|
|
|
|
ptyfs_unmount,
|
|
|
|
ptyfs_root,
|
2007-11-26 22:01:26 +03:00
|
|
|
(void *)eopnotsupp, /* vfs_quotactl */
|
2009-11-30 13:59:19 +03:00
|
|
|
genfs_statvfs,
|
2004-11-11 21:56:25 +03:00
|
|
|
ptyfs_sync,
|
|
|
|
ptyfs_vget,
|
2006-12-09 19:11:50 +03:00
|
|
|
(void *)eopnotsupp, /* vfs_fhtovp */
|
|
|
|
(void *)eopnotsupp, /* vfs_vptofp */
|
2004-11-11 21:56:25 +03:00
|
|
|
ptyfs_init,
|
|
|
|
ptyfs_reinit,
|
|
|
|
ptyfs_done,
|
|
|
|
NULL, /* vfs_mountroot */
|
2007-11-26 22:01:26 +03:00
|
|
|
(void *)eopnotsupp,
|
|
|
|
(void *)eopnotsupp,
|
2007-07-27 02:57:36 +04:00
|
|
|
(void *)eopnotsupp, /* vfs_suspendctl */
|
2008-01-28 17:31:15 +03:00
|
|
|
genfs_renamelock_enter,
|
|
|
|
genfs_renamelock_exit,
|
2008-04-29 22:18:08 +04:00
|
|
|
(void *)eopnotsupp,
|
2004-11-11 21:56:25 +03:00
|
|
|
ptyfs_vnodeopv_descs,
|
2006-09-03 08:56:33 +04:00
|
|
|
0,
|
|
|
|
{ NULL, NULL },
|
2004-11-11 21:56:25 +03:00
|
|
|
};
|
2008-05-10 06:26:09 +04:00
|
|
|
|
|
|
|
static int
|
|
|
|
ptyfs_modcmd(modcmd_t cmd, void *arg)
|
|
|
|
{
|
2008-06-28 05:34:05 +04:00
|
|
|
int error;
|
2008-05-10 06:26:09 +04:00
|
|
|
|
|
|
|
switch (cmd) {
|
|
|
|
case MODULE_CMD_INIT:
|
2008-06-28 05:34:05 +04:00
|
|
|
error = vfs_attach(&ptyfs_vfsops);
|
|
|
|
if (error != 0)
|
|
|
|
break;
|
|
|
|
sysctl_createv(&ptyfs_sysctl_log, 0, NULL, NULL,
|
|
|
|
CTLFLAG_PERMANENT,
|
|
|
|
CTLTYPE_NODE, "vfs", NULL,
|
|
|
|
NULL, 0, NULL, 0,
|
|
|
|
CTL_VFS, CTL_EOL);
|
|
|
|
sysctl_createv(&ptyfs_sysctl_log, 0, NULL, NULL,
|
|
|
|
CTLFLAG_PERMANENT,
|
|
|
|
CTLTYPE_NODE, "ptyfs",
|
|
|
|
SYSCTL_DESCR("Pty file system"),
|
|
|
|
NULL, 0, NULL, 0,
|
|
|
|
CTL_VFS, 23, CTL_EOL);
|
|
|
|
/*
|
|
|
|
* XXX the "23" above could be dynamic, thereby eliminating
|
|
|
|
* one more instance of the "number to vfs" mapping problem,
|
|
|
|
* but "23" is the order as taken from sys/mount.h
|
|
|
|
*/
|
|
|
|
break;
|
2008-05-10 06:26:09 +04:00
|
|
|
case MODULE_CMD_FINI:
|
2008-06-28 05:34:05 +04:00
|
|
|
error = vfs_detach(&ptyfs_vfsops);
|
|
|
|
if (error != 0)
|
|
|
|
break;
|
|
|
|
sysctl_teardown(&ptyfs_sysctl_log);
|
|
|
|
break;
|
2008-05-10 06:26:09 +04:00
|
|
|
default:
|
2008-06-28 05:34:05 +04:00
|
|
|
error = ENOTTY;
|
|
|
|
break;
|
2008-05-10 06:26:09 +04:00
|
|
|
}
|
2008-06-28 05:34:05 +04:00
|
|
|
|
|
|
|
return (error);
|
2008-05-10 06:26:09 +04:00
|
|
|
}
|