Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/miscfs/procfs Make symlinks for directories that point t...
details: https://anonhg.NetBSD.org/src/rev/c87e2927628b
branches: trunk
changeset: 545998:c87e2927628b
user: christos <christos%NetBSD.org@localhost>
date: Fri Apr 18 21:55:35 2003 +0000
description:
Make symlinks for directories that point to the actual directory.
Make symlinks to [kqueue] and [misc] for kqueue and misc fds.
diffstat:
sys/miscfs/procfs/procfs_subr.c | 24 ++++++---
sys/miscfs/procfs/procfs_vnops.c | 97 +++++++++++++++++++++++++--------------
2 files changed, 77 insertions(+), 44 deletions(-)
diffs (196 lines):
diff -r 37f3f72ec675 -r c87e2927628b sys/miscfs/procfs/procfs_subr.c
--- a/sys/miscfs/procfs/procfs_subr.c Fri Apr 18 21:36:38 2003 +0000
+++ b/sys/miscfs/procfs/procfs_subr.c Fri Apr 18 21:55:35 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: procfs_subr.c,v 1.50 2003/04/17 20:50:46 jdolecek Exp $ */
+/* $NetBSD: procfs_subr.c,v 1.51 2003/04/18 21:55:35 christos Exp $ */
/*
* Copyright (c) 1994 Christopher G. Demetriou. All rights reserved.
@@ -41,7 +41,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: procfs_subr.c,v 1.50 2003/04/17 20:50:46 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: procfs_subr.c,v 1.51 2003/04/18 21:55:35 christos Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -162,13 +162,12 @@
case DTYPE_VNODE:
vxp = (struct vnode *)fp->f_data;
- /* Do not allow opening directories */
- if (vxp->v_type == VDIR) {
- error = EOPNOTSUPP;
- FILE_UNUSE(fp, pown);
- goto bad;
- }
-
+ /*
+ * We make symlinks for directories
+ * to avoid cycles.
+ */
+ if (vxp->v_type == VDIR)
+ goto symlink;
vp->v_type = vxp->v_type;
break;
case DTYPE_PIPE:
@@ -177,6 +176,13 @@
case DTYPE_SOCKET:
vp->v_type = VSOCK;
break;
+ case DTYPE_KQUEUE:
+ case DTYPE_MISC:
+ symlink:
+ pfs->pfs_mode = S_IRUSR|S_IXUSR|S_IRGRP|
+ S_IXGRP|S_IROTH|S_IXOTH;
+ vp->v_type = VLNK;
+ break;
default:
error = EOPNOTSUPP;
FILE_UNUSE(fp, pown);
diff -r 37f3f72ec675 -r c87e2927628b sys/miscfs/procfs/procfs_vnops.c
--- a/sys/miscfs/procfs/procfs_vnops.c Fri Apr 18 21:36:38 2003 +0000
+++ b/sys/miscfs/procfs/procfs_vnops.c Fri Apr 18 21:55:35 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: procfs_vnops.c,v 1.101 2003/04/17 20:50:46 jdolecek Exp $ */
+/* $NetBSD: procfs_vnops.c,v 1.102 2003/04/18 21:55:35 christos Exp $ */
/*
* Copyright (c) 1993 Jan-Simon Pendry
@@ -44,7 +44,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: procfs_vnops.c,v 1.101 2003/04/17 20:50:46 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: procfs_vnops.c,v 1.102 2003/04/18 21:55:35 christos Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -912,11 +912,8 @@
fvp = (struct vnode *)fp->f_data;
/* Don't show directories */
- if (fvp->v_type == VDIR) {
- FILE_UNUSE(fp, p);
- error = ENOENT;
- break;
- }
+ if (fvp->v_type == VDIR)
+ goto symlink;
VREF(fvp);
FILE_UNUSE(fp, p);
@@ -926,6 +923,7 @@
error = 0;
break;
default:
+ symlink:
FILE_UNUSE(fp, p);
error = procfs_allocvp(dvp->v_mount, vpp, pfs->pfs_pid,
Pfd, fd);
@@ -1100,29 +1098,6 @@
for (; uio->uio_resid >= UIO_MX && i < fdp->fd_nfiles; i++) {
if ((fp = fd_getfile(fdp, i - 2)) == NULL)
continue;
- FILE_USE(fp);
-
- /*
- * Only show supported file descriptors - must
- * match procfs_allocvp() set.
- */
- switch(fp->f_type) {
- case DTYPE_VNODE:
- /* Don't show directories */
- if (((struct vnode *)fp->f_data)->v_type==VDIR){
- FILE_UNUSE(fp, p);
- continue;
- }
- case DTYPE_PIPE:
- case DTYPE_SOCKET:
- FILE_UNUSE(fp, p);
- break;
- default:
- /* unsupported, skip */
- FILE_UNUSE(fp, p);
- continue;
- }
-
d.d_fileno = PROCFS_FILENO(pfs->pfs_pid, Pfd, i - 2);
d.d_namlen = snprintf(d.d_name, sizeof(d.d_name),
"%lld", (long long)(i - 2));
@@ -1281,16 +1256,68 @@
{
struct vop_readlink_args *ap = v;
char buf[16]; /* should be enough */
+ char *bp = buf;
+ char *path = NULL;
int len;
+ int error = 0;
+ struct pfsnode *pfs = VTOPFS(ap->a_vp);
- if (VTOPFS(ap->a_vp)->pfs_fileno == PROCFS_FILENO(0, Pcurproc, -1))
+ if (pfs->pfs_fileno == PROCFS_FILENO(0, Pcurproc, -1))
len = sprintf(buf, "%ld", (long)curproc->p_pid);
- else if (VTOPFS(ap->a_vp)->pfs_fileno == PROCFS_FILENO(0, Pself, -1))
+ else if (pfs->pfs_fileno == PROCFS_FILENO(0, Pself, -1))
len = sprintf(buf, "%s", "curproc");
- else
- return (EINVAL);
+ else {
+ struct file *fp;
+ struct proc *pown;
+ struct vnode *vxp, *vp;
- return (uiomove((caddr_t)buf, len, ap->a_uio));
+ if ((error = procfs_getfp(pfs, &pown, &fp)) != 0)
+ return error;
+ FILE_USE(fp);
+ switch (fp->f_type) {
+ case DTYPE_VNODE:
+ vxp = (struct vnode *)fp->f_data;
+ if (vxp->v_type != VDIR) {
+ FILE_UNUSE(fp, pown);
+ return EINVAL;
+ }
+ if ((path = malloc(MAXPATHLEN, M_TEMP, M_WAITOK))
+ == NULL) {
+ FILE_UNUSE(fp, pown);
+ return ENOMEM;
+ }
+ bp = path + MAXPATHLEN;
+ *--bp = '\0';
+ vp = curproc->p_cwdi->cwdi_rdir;
+ if (vp == NULL)
+ vp = rootvnode;
+ error = getcwd_common(vxp, vp, &bp, path,
+ MAXPATHLEN / 2, 0, curproc);
+ FILE_UNUSE(fp, pown);
+ if (error) {
+ free(path, M_TEMP);
+ return error;
+ }
+ len = strlen(bp);
+ break;
+
+ case DTYPE_MISC:
+ len = sprintf(buf, "%s", "[misc]");
+ break;
+
+ case DTYPE_KQUEUE:
+ len = sprintf(buf, "%s", "[kqueue]");
+ break;
+
+ default:
+ return EINVAL;
+ }
+ }
+
+ error = uiomove((caddr_t)bp, len, ap->a_uio);
+ if (path)
+ free(path, M_TEMP);
+ return error;
}
/*
Home |
Main Index |
Thread Index |
Old Index