Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/miscfs/kernfs From Ilya Zykov: Unbreak kernfs which was ...
details: https://anonhg.NetBSD.org/src/rev/290c546c4f7b
branches: trunk
changeset: 328586:290c546c4f7b
user: christos <christos%NetBSD.org@localhost>
date: Tue Apr 08 17:56:10 2014 +0000
description:
>From Ilya Zykov: Unbreak kernfs which was broken by this commit
|Make the spec_node table implementation private to spec_vnops.c.
|To retrieve a spec_node, two new lookup functions (by device or by mount)
|are implemented. Both return a referenced vnode, for an opened block device
|the opened vnode is returned so further diagnostic checks "vp == ... sd_bdevvp"
|will not fire. Otherwise any vnode matching the criteria gets returned.
|No objections on tech-kern.
The effect was that ls /kernfs appeared empty in most cases.
diffstat:
sys/miscfs/kernfs/kernfs_subr.c | 35 +++++++----------------------------
sys/miscfs/kernfs/kernfs_vnops.c | 25 ++++++++++---------------
2 files changed, 17 insertions(+), 43 deletions(-)
diffs (137 lines):
diff -r 1cd6316a3345 -r 290c546c4f7b sys/miscfs/kernfs/kernfs_subr.c
--- a/sys/miscfs/kernfs/kernfs_subr.c Tue Apr 08 17:55:18 2014 +0000
+++ b/sys/miscfs/kernfs/kernfs_subr.c Tue Apr 08 17:56:10 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: kernfs_subr.c,v 1.26 2014/02/27 16:51:38 hannken Exp $ */
+/* $NetBSD: kernfs_subr.c,v 1.27 2014/04/08 17:56:10 christos Exp $ */
/*
* Copyright (c) 1993
@@ -73,7 +73,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kernfs_subr.c,v 1.26 2014/02/27 16:51:38 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kernfs_subr.c,v 1.27 2014/04/08 17:56:10 christos Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -88,6 +88,7 @@
#include <sys/mount.h>
#include <miscfs/kernfs/kernfs.h>
+#include <miscfs/specfs/specdev.h>
void kernfs_hashins(struct kernfs_node *);
void kernfs_hashrem(struct kernfs_node *);
@@ -147,32 +148,6 @@
return (0);
}
- if (kfs_type == KFSdevice) {
- /* /kern/rootdev = look for device and obey */
- /* /kern/rrootdev = look for device and obey */
- dev_t *dp;
- struct vnode *fvp;
-
-#ifdef DIAGNOSTIC
- if (!kt)
- panic("kernfs: kt == NULL for KFSdevice");
-#endif
- dp = kt->kt_data;
- loop:
- if (*dp == NODEV || !vfinddev(*dp, kt->kt_vtype, &fvp)) {
- mutex_exit(&kfs_hashlock);
- return (ENOENT);
- }
- vp = fvp;
- if (vn_lock(fvp, LK_EXCLUSIVE)) {
- vrele(fvp);
- goto loop;
- }
- *vpp = vp;
- mutex_exit(&kfs_hashlock);
- return (0);
- }
-
error = getnewvnode(VT_KERNFS, mp, kernfs_vnodeop_p, NULL, &vp);
if (error) {
*vpp = NULL;
@@ -220,6 +195,10 @@
if (kfs_type == KFSkern)
vp->v_vflag = VV_ROOT;
+ if (kfs_type == KFSdevice) {
+ spec_node_init(vp, *(dev_t *)kt->kt_data);
+ }
+
kernfs_hashins(kfs);
uvm_vnp_setsize(vp, 0);
mutex_exit(&kfs_hashlock);
diff -r 1cd6316a3345 -r 290c546c4f7b sys/miscfs/kernfs/kernfs_vnops.c
--- a/sys/miscfs/kernfs/kernfs_vnops.c Tue Apr 08 17:55:18 2014 +0000
+++ b/sys/miscfs/kernfs/kernfs_vnops.c Tue Apr 08 17:56:10 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: kernfs_vnops.c,v 1.150 2014/02/07 15:29:22 hannken Exp $ */
+/* $NetBSD: kernfs_vnops.c,v 1.151 2014/04/08 17:56:10 christos Exp $ */
/*
* Copyright (c) 1992, 1993
@@ -39,7 +39,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kernfs_vnops.c,v 1.150 2014/02/07 15:29:22 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kernfs_vnops.c,v 1.151 2014/04/08 17:56:10 christos Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -59,6 +59,7 @@
#include <miscfs/genfs/genfs.h>
#include <miscfs/kernfs/kernfs.h>
+#include <miscfs/specfs/specdev.h>
#include <uvm/uvm_extern.h>
@@ -653,6 +654,11 @@
vap->va_bytes = vap->va_size = DEV_BSIZE;
break;
+ case KFSdevice:
+ vap->va_nlink = 1;
+ vap->va_rdev = ap->a_vp->v_rdev;
+ break;
+
case KFSroot:
vap->va_nlink = 1;
vap->va_bytes = vap->va_size = DEV_BSIZE;
@@ -670,7 +676,6 @@
case KFSstring:
case KFShostname:
case KFSavenrun:
- case KFSdevice:
case KFSmsgbuf:
vap->va_nlink = 1;
total = 0;
@@ -832,18 +837,8 @@
if ((error = kernfs_allocvp(ap->a_vp->v_mount, &vp, kt->kt_tag, kt,
value)) != 0)
return error;
- if (kt->kt_tag == KFSdevice) {
- struct vattr va;
-
- error = VOP_GETATTR(vp, &va, ap->a_cred);
- if (error != 0) {
- return error;
- }
- d->d_fileno = va.va_fileid;
- } else {
- kfs = VTOKERN(vp);
- d->d_fileno = kfs->kfs_fileno;
- }
+ kfs = VTOKERN(vp);
+ d->d_fileno = kfs->kfs_fileno;
vput(vp);
return 0;
}
Home |
Main Index |
Thread Index |
Old Index