SCCS-vsn: sys/miscfs/portal/portal_vfsops.c 8.5
SCCS-vsn: sys/miscfs/portal/portal_vnops.c 8.6
*
* %sccs.include.redist.c%
*
*
* %sccs.include.redist.c%
*
- * @(#)portal_vfsops.c 8.4 (Berkeley) %G%
+ * @(#)portal_vfsops.c 8.5 (Berkeley) %G%
*
* $Id: portal_vfsops.c,v 1.5 1992/05/30 10:25:27 jsp Exp jsp $
*/
*
* $Id: portal_vfsops.c,v 1.5 1992/05/30 10:25:27 jsp Exp jsp $
*/
-#ifdef PORTAL_DIAGNOSTIC
- printf("portal_init\n"); /* printed during system boot */
-#endif
}
/*
* Mount the per-process file descriptors (/dev/fd)
*/
}
/*
* Mount the per-process file descriptors (/dev/fd)
*/
portal_mount(mp, path, data, ndp, p)
struct mount *mp;
char *path;
portal_mount(mp, path, data, ndp, p)
struct mount *mp;
char *path;
-#ifdef PORTAL_DIAGNOSTIC
- printf("portal_mount(mp = %x)\n", mp);
-#endif
-
/*
* Update is a no-op
*/
/*
* Update is a no-op
*/
VTOPORTAL(rvp)->pt_arg = 0;
VTOPORTAL(rvp)->pt_size = 0;
VTOPORTAL(rvp)->pt_fileid = PORTAL_ROOTFILEID;
VTOPORTAL(rvp)->pt_arg = 0;
VTOPORTAL(rvp)->pt_size = 0;
VTOPORTAL(rvp)->pt_fileid = PORTAL_ROOTFILEID;
-#ifdef PORTAL_DIAGNOSTIC
- printf("portal_mount: root vp = %x\n", rvp);
-#endif
fmp->pm_root = rvp;
fmp->pm_server = fp; fp->f_count++;
fmp->pm_root = rvp;
fmp->pm_server = fp; fp->f_count++;
bcopy("portal", mp->mnt_stat.f_mntfromname, sizeof("portal"));
#endif
bcopy("portal", mp->mnt_stat.f_mntfromname, sizeof("portal"));
#endif
-#ifdef PORTAL_DIAGNOSTIC
- printf("portal_mount: config %s at %s\n",
- mp->mnt_stat.f_mntfromname, mp->mnt_stat.f_mntonname);
-#endif
portal_start(mp, flags, p)
struct mount *mp;
int flags;
portal_start(mp, flags, p)
struct mount *mp;
int flags;
portal_unmount(mp, mntflags, p)
struct mount *mp;
int mntflags;
portal_unmount(mp, mntflags, p)
struct mount *mp;
int mntflags;
struct vnode *rootvp = VFSTOPORTAL(mp)->pm_root;
int error, flags = 0;
struct vnode *rootvp = VFSTOPORTAL(mp)->pm_root;
int error, flags = 0;
-#ifdef PORTAL_DIAGNOSTIC
- printf("portal_unmount(mp = %x)\n", mp);
-#endif
if (mntflags & MNT_FORCE) {
/* portal can never be rootfs so don't check for it */
if (mntflags & MNT_FORCE) {
/* portal can never be rootfs so don't check for it */
* moment, but who knows...
*/
#ifdef notyet
* moment, but who knows...
*/
#ifdef notyet
-#ifdef PORTAL_DIAGNOSTIC
- printf("portal_unmount: calling mntflushbuf\n");
-#endif
-#ifdef PORTAL_DIAGNOSTIC
- printf("portal_unmount: calling mntinvalbuf\n");
-#endif
if (mntinvalbuf(mp, 1))
return (EBUSY);
#endif
if (rootvp->v_usecount > 1)
return (EBUSY);
if (mntinvalbuf(mp, 1))
return (EBUSY);
#endif
if (rootvp->v_usecount > 1)
return (EBUSY);
-#ifdef PORTAL_DIAGNOSTIC
- printf("portal_unmount: calling vflush\n");
-#endif
if (error = vflush(mp, rootvp, flags))
return (error);
if (error = vflush(mp, rootvp, flags))
return (error);
-#ifdef PORTAL_DIAGNOSTIC
- vprint("portal root", rootvp);
-#endif
/*
* Release reference on underlying root vnode
*/
/*
* Release reference on underlying root vnode
*/
* daemon to wake up, and then the accept will get ECONNABORTED
* which it interprets as a request to go and bury itself.
*/
* daemon to wake up, and then the accept will get ECONNABORTED
* which it interprets as a request to go and bury itself.
*/
-#ifdef PORTAL_DIAGNOSTIC
- printf("portal_unmount: shutdown socket\n");
-#endif
soshutdown((struct socket *) VFSTOPORTAL(mp)->pm_server->f_data, 2);
/*
* Discard reference to underlying file. Must call closef because
* this may be the last reference.
*/
soshutdown((struct socket *) VFSTOPORTAL(mp)->pm_server->f_data, 2);
/*
* Discard reference to underlying file. Must call closef because
* this may be the last reference.
*/
-#ifdef PORTAL_DIAGNOSTIC
- printf("portal_unmount: closef(%x)\n", VFSTOPORTAL(mp)->pm_server);
-#endif
closef(VFSTOPORTAL(mp)->pm_server, (struct proc *) 0);
/*
* Finally, throw away the portalmount structure
closef(VFSTOPORTAL(mp)->pm_server, (struct proc *) 0);
/*
* Finally, throw away the portalmount structure
portal_root(mp, vpp)
struct mount *mp;
struct vnode **vpp;
{
struct vnode *vp;
portal_root(mp, vpp)
struct mount *mp;
struct vnode **vpp;
{
struct vnode *vp;
-#ifdef PORTAL_DIAGNOSTIC
- printf("portal_root(mp = %x)\n", mp);
-#endif
/*
* Return locked reference to root.
/*
* Return locked reference to root.
portal_quotactl(mp, cmd, uid, arg, p)
struct mount *mp;
int cmd;
portal_quotactl(mp, cmd, uid, arg, p)
struct mount *mp;
int cmd;
portal_statfs(mp, sbp, p)
struct mount *mp;
struct statfs *sbp;
struct proc *p;
{
portal_statfs(mp, sbp, p)
struct mount *mp;
struct statfs *sbp;
struct proc *p;
{
-#ifdef PORTAL_DIAGNOSTIC
- printf("portal_statfs(mp = %x)\n", mp);
-#endif
sbp->f_type = MOUNT_PORTAL;
sbp->f_flags = 0;
sbp->f_type = MOUNT_PORTAL;
sbp->f_flags = 0;
portal_sync(mp, waitfor)
struct mount *mp;
int waitfor;
portal_sync(mp, waitfor)
struct mount *mp;
int waitfor;
portal_vget(mp, ino, vpp)
struct mount *mp;
ino_t ino;
portal_vget(mp, ino, vpp)
struct mount *mp;
ino_t ino;
portal_fhtovp(mp, fhp, vpp)
struct mount *mp;
struct fid *fhp;
portal_fhtovp(mp, fhp, vpp)
struct mount *mp;
struct fid *fhp;
portal_vptofh(vp, fhp)
struct vnode *vp;
struct fid *fhp;
portal_vptofh(vp, fhp)
struct vnode *vp;
struct fid *fhp;
*
* %sccs.include.redist.c%
*
*
* %sccs.include.redist.c%
*
- * @(#)portal_vnops.c 8.5 (Berkeley) %G%
+ * @(#)portal_vnops.c 8.6 (Berkeley) %G%
*
* $Id: portal_vnops.c,v 1.4 1992/05/30 10:05:24 jsp Exp jsp $
*/
*
* $Id: portal_vnops.c,v 1.4 1992/05/30 10:05:24 jsp Exp jsp $
*/
* vp is the current namei directory
* cnp is the name to locate in that directory...
*/
* vp is the current namei directory
* cnp is the name to locate in that directory...
*/
portal_lookup(ap)
struct vop_lookup_args /* {
struct vnode * a_dvp;
portal_lookup(ap)
struct vop_lookup_args /* {
struct vnode * a_dvp;
-#ifdef PORTAL_DIAGNOSTIC
- printf("portal_lookup(%s)\n", pname);
-#endif
if (ap->a_cnp->cn_namelen == 1 && *pname == '.') {
*ap->a_vpp = ap->a_dvp;
VREF(ap->a_dvp);
if (ap->a_cnp->cn_namelen == 1 && *pname == '.') {
*ap->a_vpp = ap->a_dvp;
VREF(ap->a_dvp);
-#ifdef PORTAL_DIAGNOSTIC
- printf("portal_lookup: allocate new vnode\n");
-#endif
error = getnewvnode(VT_PORTAL, ap->a_dvp->v_mount, portal_vnodeop_p, &fvp);
if (error)
goto bad;
error = getnewvnode(VT_PORTAL, ap->a_dvp->v_mount, portal_vnodeop_p, &fvp);
if (error)
goto bad;
*ap->a_vpp = fvp;
/*VOP_LOCK(fvp);*/
*ap->a_vpp = fvp;
/*VOP_LOCK(fvp);*/
-#ifdef PORTAL_DIAGNOSTIC
- printf("portal_lookup: newvp = %x\n", fvp);
-#endif
return (0);
bad:;
if (fvp) {
return (0);
bad:;
if (fvp) {
-#ifdef PORTAL_DIAGNOSTIC
- printf("portal_lookup: vrele(%x)\n", fvp);
-#endif
vrele(fvp);
}
*ap->a_vpp = NULL;
vrele(fvp);
}
*ap->a_vpp = NULL;
-#ifdef PORTAL_DIAGNOSTIC
- printf("portal_lookup: error = %d\n", error);
-#endif
struct socket *so2;
{
/* from unp_connect, bypassing the namei stuff... */
struct socket *so2;
{
/* from unp_connect, bypassing the namei stuff... */
struct socket *so3;
struct unpcb *unp2;
struct unpcb *unp3;
struct socket *so3;
struct unpcb *unp2;
struct unpcb *unp3;
-#ifdef PORTAL_DIAGNOSTIC
- printf("portal_connect\n");
-#endif
-
if (so2 == 0)
return (ECONNREFUSED);
if (so2 == 0)
return (ECONNREFUSED);
if ((so2->so_options & SO_ACCEPTCONN) == 0)
return (ECONNREFUSED);
if ((so2->so_options & SO_ACCEPTCONN) == 0)
return (ECONNREFUSED);
-#ifdef PORTAL_DIAGNOSTIC
- printf("portal_connect: calling sonewconn\n");
-#endif
-
if ((so3 = sonewconn(so2, 0)) == 0)
return (ECONNREFUSED);
if ((so3 = sonewconn(so2, 0)) == 0)
return (ECONNREFUSED);
-#ifdef PORTAL_DIAGNOSTIC
- printf("portal_connect: calling unp_connect2\n");
-#endif
return (unp_connect2(so, so2));
}
return (unp_connect2(so, so2));
}
portal_open(ap)
struct vop_open_args /* {
struct vnode *a_vp;
portal_open(ap)
struct vop_open_args /* {
struct vnode *a_vp;
if (vp->v_flag & VROOT)
return (0);
if (vp->v_flag & VROOT)
return (0);
-#ifdef PORTAL_DIAGNOSTIC
- printf("portal_open(%x)\n", vp);
-#endif
-
/*
* Can't be opened unless the caller is set up
* to deal with the side effects. Check for this
/*
* Can't be opened unless the caller is set up
* to deal with the side effects. Check for this
/*
* Reserve some buffer space
*/
/*
* Reserve some buffer space
*/
-#ifdef PORTAL_DIAGNOSTIC
- printf("portal_open: calling soreserve\n");
-#endif
res = pt->pt_size + sizeof(pcred) + 512; /* XXX */
error = soreserve(so, res, res);
if (error)
res = pt->pt_size + sizeof(pcred) + 512; /* XXX */
error = soreserve(so, res, res);
if (error)
/*
* Kick off connection
*/
/*
* Kick off connection
*/
-#ifdef PORTAL_DIAGNOSTIC
- printf("portal_open: calling portal_connect\n");
-#endif
error = portal_connect(so, (struct socket *)fmp->pm_server->f_data);
if (error)
goto bad;
error = portal_connect(so, (struct socket *)fmp->pm_server->f_data);
if (error)
goto bad;
/*
* Wait for connection to complete
*/
/*
* Wait for connection to complete
*/
-#ifdef PORTAL_DIAGNOSTIC
- printf("portal_open: waiting for connect\n");
-#endif
/*
* XXX: Since the mount point is holding a reference on the
* underlying server socket, it is not easy to find out whether
/*
* XXX: Since the mount point is holding a reference on the
* underlying server socket, it is not easy to find out whether
if (fmp->pm_server->f_count == 1) {
error = ECONNREFUSED;
splx(s);
if (fmp->pm_server->f_count == 1) {
error = ECONNREFUSED;
splx(s);
-#ifdef PORTAL_DIAGNOSTIC
- printf("portal_open: server process has gone away\n");
-#endif
goto bad;
}
(void) tsleep((caddr_t) &so->so_timeo, PSOCK, "portalcon", 5 * hz);
goto bad;
}
(void) tsleep((caddr_t) &so->so_timeo, PSOCK, "portalcon", 5 * hz);
so->so_rcv.sb_flags |= SB_NOINTR;
so->so_snd.sb_flags |= SB_NOINTR;
so->so_rcv.sb_flags |= SB_NOINTR;
so->so_snd.sb_flags |= SB_NOINTR;
-#ifdef PORTAL_DIAGNOSTIC
- printf("portal_open: constructing data uio\n");
-#endif
pcred.pcr_flag = ap->a_mode;
pcred.pcr_uid = ap->a_cred->cr_uid;
pcred.pcr_flag = ap->a_mode;
pcred.pcr_uid = ap->a_cred->cr_uid;
auio.uio_offset = 0;
auio.uio_resid = aiov[0].iov_len + aiov[1].iov_len;
auio.uio_offset = 0;
auio.uio_resid = aiov[0].iov_len + aiov[1].iov_len;
-#ifdef PORTAL_DIAGNOSTIC
- printf("portal_open: sending data to server\n");
-#endif
error = sosend(so, (struct mbuf *) 0, &auio,
(struct mbuf *) 0, (struct mbuf *) 0, 0);
if (error)
error = sosend(so, (struct mbuf *) 0, &auio,
(struct mbuf *) 0, (struct mbuf *) 0, 0);
if (error)
do {
struct mbuf *m = 0;
int flags = MSG_WAITALL;
do {
struct mbuf *m = 0;
int flags = MSG_WAITALL;
-#ifdef PORTAL_DIAGNOSTIC
- printf("portal_open: receiving data from server\n");
- printf("portal_open: so = %x, cm = %x, resid = %d\n",
- so, cm, auio.uio_resid);
- printf("portal_open, uio=%x, mp0=%x, controlp=%x\n", &auio, &cm);
-#endif
error = soreceive(so, (struct mbuf **) 0, &auio,
&m, &cm, &flags);
error = soreceive(so, (struct mbuf **) 0, &auio,
&m, &cm, &flags);
-#ifdef PORTAL_DIAGNOSTIC
- printf("portal_open: after receiving data\n");
- printf("portal_open: so = %x, cm = %x, resid = %d\n",
- so, cm, auio.uio_resid);
-#endif
} else {
error = EINVAL;
}
} else {
error = EINVAL;
}
-#ifdef PORTAL_DIAGNOSTIC
- printf("portal_open: error returned is %d\n", error);
-#endif
-#ifdef PORTAL_DIAGNOSTIC
- printf("portal_open: no rights received\n");
-#endif
error = ECONNRESET; /* XXX */
#ifdef notdef
break;
error = ECONNRESET; /* XXX */
#ifdef notdef
break;
goto bad;
if (auio.uio_resid) {
goto bad;
if (auio.uio_resid) {
-#ifdef PORTAL_DIAGNOSTIC
- printf("portal_open: still need another %d bytes\n", auio.uio_resid);
-#endif
error = 0;
#ifdef notdef
error = EMSGSIZE;
error = 0;
#ifdef notdef
error = EMSGSIZE;
* may have been received, or that the rights chain may have more
* than a single mbuf in it. What to do?
*/
* may have been received, or that the rights chain may have more
* than a single mbuf in it. What to do?
*/
-#ifdef PORTAL_DIAGNOSTIC
- printf("portal_open: about to break apart control message\n");
-#endif
cmsg = mtod(cm, struct cmsghdr *);
newfds = (cmsg->cmsg_len - sizeof(*cmsg)) / sizeof (int);
if (newfds == 0) {
cmsg = mtod(cm, struct cmsghdr *);
newfds = (cmsg->cmsg_len - sizeof(*cmsg)) / sizeof (int);
if (newfds == 0) {
-#ifdef PORTAL_DIAGNOSTIC
- printf("portal_open: received no fds\n");
-#endif
error = ECONNREFUSED;
goto bad;
}
error = ECONNREFUSED;
goto bad;
}
* Check that the mode the file is being opened for is a subset
* of the mode of the existing descriptor.
*/
* Check that the mode the file is being opened for is a subset
* of the mode of the existing descriptor.
*/
-#ifdef PORTAL_DIAGNOSTIC
- printf("portal_open: checking file flags, fd = %d\n", fd);
-#endif
fp = p->p_fd->fd_ofiles[fd];
if (((ap->a_mode & (FREAD|FWRITE)) | fp->f_flag) != fp->f_flag) {
portal_closefd(p, fd);
fp = p->p_fd->fd_ofiles[fd];
if (((ap->a_mode & (FREAD|FWRITE)) | fp->f_flag) != fp->f_flag) {
portal_closefd(p, fd);
-#ifdef PORTAL_DIAGNOSTIC
- printf("portal_open: got fd = %d\n", fd);
-#endif
/*
* Save the dup fd in the proc structure then return the
* special error code (ENXIO) which causes magic things to
/*
* Save the dup fd in the proc structure then return the
* special error code (ENXIO) which causes magic things to
* And discard the control message.
*/
if (cm) {
* And discard the control message.
*/
if (cm) {
-#ifdef PORTAL_DIAGNOSTIC
- printf("portal_open: free'ing control message\n");
-#endif
-#ifdef PORTAL_DIAGNOSTIC
- printf("portal_open: calling soshutdown\n");
-#endif
-#ifdef PORTAL_DIAGNOSTIC
- printf("portal_open: calling soclose\n");
-#endif
-#ifdef PORTAL_DIAGNOSTIC
- if (error != ENODEV)
- printf("portal_open: error = %d\n", error);
-#endif
portal_getattr(ap)
struct vop_getattr_args /* {
struct vnode *a_vp;
portal_getattr(ap)
struct vop_getattr_args /* {
struct vnode *a_vp;
vap->va_bytes = 0;
/* vap->va_qsize = 0; */
if (vp->v_flag & VROOT) {
vap->va_bytes = 0;
/* vap->va_qsize = 0; */
if (vp->v_flag & VROOT) {
-#ifdef PORTAL_DIAGNOSTIC
- printf("portal_getattr: stat rootdir\n");
-#endif
vap->va_type = VDIR;
vap->va_mode = S_IRUSR|S_IWUSR|S_IXUSR|
S_IRGRP|S_IWGRP|S_IXGRP|
vap->va_type = VDIR;
vap->va_mode = S_IRUSR|S_IWUSR|S_IXUSR|
S_IRGRP|S_IWGRP|S_IXGRP|
vap->va_nlink = 2;
vap->va_fileid = 2;
} else {
vap->va_nlink = 2;
vap->va_fileid = 2;
} else {
-#ifdef PORTAL_DIAGNOSTIC
- printf("portal_getattr: stat portal\n");
-#endif
vap->va_type = VREG;
vap->va_mode = S_IRUSR|S_IWUSR|
S_IRGRP|S_IWGRP|
vap->va_type = VREG;
vap->va_mode = S_IRUSR|S_IWUSR|
S_IRGRP|S_IWGRP|
portal_setattr(ap)
struct vop_setattr_args /* {
struct vnode *a_vp;
portal_setattr(ap)
struct vop_setattr_args /* {
struct vnode *a_vp;
struct proc *a_p;
} */ *ap;
{
struct proc *a_p;
} */ *ap;
{
/*
* Can't mess with the root vnode
*/
/*
* Can't mess with the root vnode
*/
* Fake readdir, just return empty directory.
* It is hard to deal with '.' and '..' so don't bother.
*/
* Fake readdir, just return empty directory.
* It is hard to deal with '.' and '..' so don't bother.
*/
portal_readdir(ap)
struct vop_readdir_args /* {
struct vnode *a_vp;
portal_readdir(ap)
struct vop_readdir_args /* {
struct vnode *a_vp;
struct ucred *a_cred;
} */ *ap;
{
struct ucred *a_cred;
} */ *ap;
{
- /* *ap->a_eofflagp = 1; */
portal_inactive(ap)
struct vop_inactive_args /* {
struct vnode *a_vp;
} */ *ap;
{
portal_inactive(ap)
struct vop_inactive_args /* {
struct vnode *a_vp;
} */ *ap;
{
-#ifdef PORTAL_DIAGNOSTIC
- if (VTOPORTAL(ap->a_vp)->pt_arg)
- printf("portal_inactive(%x, %s)\n", ap->a_vp, VTOPORTAL(ap->a_vp)->pt_arg);
- else
- printf("portal_inactive(%x)\n", ap->a_vp);
-#endif
- /*vgone(ap->a_vp);*/
portal_reclaim(ap)
struct vop_reclaim_args /* {
struct vnode *a_vp;
} */ *ap;
{
struct portalnode *pt = VTOPORTAL(ap->a_vp);
portal_reclaim(ap)
struct vop_reclaim_args /* {
struct vnode *a_vp;
} */ *ap;
{
struct portalnode *pt = VTOPORTAL(ap->a_vp);
-#ifdef PORTAL_DIAGOISTIC
- printf("portal_reclaim(%x)\n", ap->a_vp);
-#endif
if (pt->pt_arg) {
free((caddr_t) pt->pt_arg, M_TEMP);
pt->pt_arg = 0;
}
FREE(ap->a_vp->v_data, M_TEMP);
ap->a_vp->v_data = 0;
if (pt->pt_arg) {
free((caddr_t) pt->pt_arg, M_TEMP);
pt->pt_arg = 0;
}
FREE(ap->a_vp->v_data, M_TEMP);
ap->a_vp->v_data = 0;
* Print out the contents of a Portal vnode.
*/
/* ARGSUSED */
* Print out the contents of a Portal vnode.
*/
/* ARGSUSED */
portal_print(ap)
struct vop_print_args /* {
struct vnode *a_vp;
portal_print(ap)
struct vop_print_args /* {
struct vnode *a_vp;
portal_vfree(ap)
struct vop_vfree_args /* {
struct vnode *a_pvp;
portal_vfree(ap)
struct vop_vfree_args /* {
struct vnode *a_pvp;
/*
* Portal vnode unsupported operation
*/
/*
* Portal vnode unsupported operation
*/
/*
* Portal "should never get here" operation
*/
/*
* Portal "should never get here" operation
*/
/*
* Portal vnode null operation
*/
/*
* Portal vnode null operation
*/