CVS commit: src/sys/miscfs/kernfs
Module Name:src Committed By: jdolecek Date: Tue Apr 7 08:35:49 UTC 2020 Modified Files: src/sys/miscfs/kernfs: kernfs_vfsops.c Log Message: switch to kmem_zalloc() instead of malloc() for struct kernfs_mount To generate a diff of this commit: cvs rdiff -u -r1.99 -r1.100 src/sys/miscfs/kernfs/kernfs_vfsops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/miscfs/kernfs/kernfs_vfsops.c diff -u src/sys/miscfs/kernfs/kernfs_vfsops.c:1.99 src/sys/miscfs/kernfs/kernfs_vfsops.c:1.100 --- src/sys/miscfs/kernfs/kernfs_vfsops.c:1.99 Mon Mar 16 21:20:11 2020 +++ src/sys/miscfs/kernfs/kernfs_vfsops.c Tue Apr 7 08:35:49 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: kernfs_vfsops.c,v 1.99 2020/03/16 21:20:11 pgoyette Exp $ */ +/* $NetBSD: kernfs_vfsops.c,v 1.100 2020/04/07 08:35:49 jdolecek Exp $ */ /* * Copyright (c) 1992, 1993, 1995 @@ -39,7 +39,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kernfs_vfsops.c,v 1.99 2020/03/16 21:20:11 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kernfs_vfsops.c,v 1.100 2020/04/07 08:35:49 jdolecek Exp $"); #ifdef _KERNEL_OPT #include "opt_compat_netbsd.h" @@ -54,7 +54,6 @@ __KERNEL_RCSID(0, "$NetBSD: kernfs_vfsop #include #include #include -#include #include #include #include @@ -65,8 +64,6 @@ __KERNEL_RCSID(0, "$NetBSD: kernfs_vfsop MODULE(MODULE_CLASS_VFS, kernfs, NULL); -MALLOC_JUSTDEFINE(M_KERNFSMNT, "kernfs mount", "kernfs mount structures"); - dev_t rrootdev = NODEV; kmutex_t kfs_lock; @@ -78,7 +75,6 @@ void kernfs_init(void) { - malloc_type_attach(M_KERNFSMNT); mutex_init(&kfs_lock, MUTEX_DEFAULT, IPL_NONE); } @@ -93,7 +89,6 @@ kernfs_done(void) { mutex_destroy(&kfs_lock); - malloc_type_detach(M_KERNFSMNT); } void @@ -141,7 +136,7 @@ kernfs_mount(struct mount *mp, const cha if (mp->mnt_flag & MNT_UPDATE) return (EOPNOTSUPP); - fmp = malloc(sizeof(struct kernfs_mount), M_KERNFSMNT, M_WAITOK|M_ZERO); + fmp = kmem_zalloc(sizeof(struct kernfs_mount), KM_SLEEP); TAILQ_INIT(&fmp->nodelist); mp->mnt_stat.f_namemax = KERNFS_MAXNAMLEN; @@ -151,7 +146,7 @@ kernfs_mount(struct mount *mp, const cha if ((error = set_statvfs_info(path, UIO_USERSPACE, "kernfs", UIO_SYSSPACE, mp->mnt_op->vfs_name, mp, l)) != 0) { - free(fmp, M_KERNFSMNT); + kmem_free(fmp, sizeof(struct kernfs_mount)); return error; } @@ -181,7 +176,7 @@ kernfs_unmount(struct mount *mp, int mnt /* * Finally, throw away the kernfs_mount structure */ - free(mp->mnt_data, M_KERNFSMNT); + kmem_free(mp->mnt_data, sizeof(struct kernfs_mount)); mp->mnt_data = NULL; return (0); }
CVS commit: src/sys/miscfs/kernfs
Module Name:src Committed By: riastradh Date: Tue Feb 4 04:19:24 UTC 2020 Modified Files: src/sys/miscfs/kernfs: kernfs.h kernfs_vfsops.c kernfs_vnops.c Log Message: Use specfs vnops for specnodes in kernfs. While here, don't filter out rootdev and rrootdev merely because they're not cached. Fixes the elusive /kern/rootdev and /kern/rrootdev nodes, which only appeared sometimes when they felt like it, and fixes operations on /kern/rootdev and /kern/rrootdev always returning EOPNOTSUPP. We didn't seem to have a single PR for these issues but the following PRs are all relevant: PR bin/13564 PR kern/38265 PR kern/38778 PR kern/45974 XXX pullup-9, pullup-8, pullup-7, pullup-6, pullup-5, pullup-4, pullup-3, pullup-2, pullup-1.4T... To generate a diff of this commit: cvs rdiff -u -r1.42 -r1.43 src/sys/miscfs/kernfs/kernfs.h cvs rdiff -u -r1.97 -r1.98 src/sys/miscfs/kernfs/kernfs_vfsops.c cvs rdiff -u -r1.162 -r1.163 src/sys/miscfs/kernfs/kernfs_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/miscfs/kernfs/kernfs.h diff -u src/sys/miscfs/kernfs/kernfs.h:1.42 src/sys/miscfs/kernfs/kernfs.h:1.43 --- src/sys/miscfs/kernfs/kernfs.h:1.42 Fri Jan 17 20:08:09 2020 +++ src/sys/miscfs/kernfs/kernfs.h Tue Feb 4 04:19:24 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: kernfs.h,v 1.42 2020/01/17 20:08:09 ad Exp $ */ +/* $NetBSD: kernfs.h,v 1.43 2020/02/04 04:19:24 riastradh Exp $ */ /* * Copyright (c) 1992, 1993 @@ -122,6 +122,7 @@ extern const struct kern_target kern_tar extern int nkern_targets; extern const int static_nkern_targets; extern int (**kernfs_vnodeop_p)(void *); +extern int (**kernfs_specop_p)(void *); extern struct vfsops kernfs_vfsops; extern dev_t rrootdev; extern kmutex_t kfs_lock; Index: src/sys/miscfs/kernfs/kernfs_vfsops.c diff -u src/sys/miscfs/kernfs/kernfs_vfsops.c:1.97 src/sys/miscfs/kernfs/kernfs_vfsops.c:1.98 --- src/sys/miscfs/kernfs/kernfs_vfsops.c:1.97 Fri Jan 17 20:08:09 2020 +++ src/sys/miscfs/kernfs/kernfs_vfsops.c Tue Feb 4 04:19:24 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: kernfs_vfsops.c,v 1.97 2020/01/17 20:08:09 ad Exp $ */ +/* $NetBSD: kernfs_vfsops.c,v 1.98 2020/02/04 04:19:24 riastradh Exp $ */ /* * Copyright (c) 1992, 1993, 1995 @@ -39,7 +39,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kernfs_vfsops.c,v 1.97 2020/01/17 20:08:09 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kernfs_vfsops.c,v 1.98 2020/02/04 04:19:24 riastradh Exp $"); #ifdef _KERNEL_OPT #include "opt_compat_netbsd.h" @@ -283,6 +283,7 @@ again: vp->v_vflag = VV_ROOT; if (kt->kt_tag == KFSdevice) { + vp->v_op = kernfs_specop_p; spec_node_init(vp, *(dev_t *)kt->kt_data); } @@ -293,9 +294,11 @@ again: } extern const struct vnodeopv_desc kernfs_vnodeop_opv_desc; +extern const struct vnodeopv_desc kernfs_specop_opv_desc; const struct vnodeopv_desc * const kernfs_vnodeopv_descs[] = { &kernfs_vnodeop_opv_desc, + &kernfs_specop_opv_desc, NULL, }; Index: src/sys/miscfs/kernfs/kernfs_vnops.c diff -u src/sys/miscfs/kernfs/kernfs_vnops.c:1.162 src/sys/miscfs/kernfs/kernfs_vnops.c:1.163 --- src/sys/miscfs/kernfs/kernfs_vnops.c:1.162 Thu Jan 2 15:42:27 2020 +++ src/sys/miscfs/kernfs/kernfs_vnops.c Tue Feb 4 04:19:24 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: kernfs_vnops.c,v 1.162 2020/01/02 15:42:27 thorpej Exp $ */ +/* $NetBSD: kernfs_vnops.c,v 1.163 2020/02/04 04:19:24 riastradh Exp $ */ /* * Copyright (c) 1992, 1993 @@ -39,7 +39,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kernfs_vnops.c,v 1.162 2020/01/02 15:42:27 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kernfs_vnops.c,v 1.163 2020/02/04 04:19:24 riastradh Exp $"); #include #include @@ -227,6 +227,54 @@ const struct vnodeopv_entry_desc kernfs_ const struct vnodeopv_desc kernfs_vnodeop_opv_desc = { &kernfs_vnodeop_p, kernfs_vnodeop_entries }; +int (**kernfs_specop_p)(void *); +const struct vnodeopv_entry_desc kernfs_specop_entries[] = { + { &vop_default_desc, vn_default_error }, + { &vop_lookup_desc, spec_lookup }, /* lookup */ + { &vop_create_desc, spec_create }, /* create */ + { &vop_mknod_desc, spec_mknod }, /* mknod */ + { &vop_open_desc, spec_open }, /* open */ + { &vop_close_desc, spec_close }, /* close */ + { &vop_access_desc, kernfs_access }, /* access */ + { &vop_getattr_desc, kernfs_getattr }, /* getattr */ + { &vop_setattr_desc, kernfs_setattr }, /* setattr */ + { &vop_read_desc, spec_read }, /* read */ + { &vop_write_desc, spec_write }, /* write */ + { &vop_fallocate_desc, spec_fallocate }, /* fallocate */ + { &vop_fdiscard_desc, spec_fdiscard }, /* fdiscard */ + { &vop_fcntl_desc, spec_fcntl }, /* fcntl */ + { &vop_ioctl_desc, spec_ioctl }, /* ioctl */ + { &vop_poll_desc, spec_poll }, /* poll */ + { &vop_revoke_desc, spec_revoke }, /* revoke */ + { &vop_fsync_desc, spec_fsync }, /* fsync */ + { &vop_seek_desc, spec_seek }, /* seek */ + { &vop_remove_desc,
CVS commit: src/sys/miscfs/kernfs
Module Name:src Committed By: ad Date: Mon Feb 24 20:44:25 UTC 2020 Modified Files: src/sys/miscfs/kernfs: kernfs_vnops.c Log Message: v_interlock -> vmobjlock To generate a diff of this commit: cvs rdiff -u -r1.163 -r1.164 src/sys/miscfs/kernfs/kernfs_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/miscfs/kernfs/kernfs_vnops.c diff -u src/sys/miscfs/kernfs/kernfs_vnops.c:1.163 src/sys/miscfs/kernfs/kernfs_vnops.c:1.164 --- src/sys/miscfs/kernfs/kernfs_vnops.c:1.163 Tue Feb 4 04:19:24 2020 +++ src/sys/miscfs/kernfs/kernfs_vnops.c Mon Feb 24 20:44:25 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: kernfs_vnops.c,v 1.163 2020/02/04 04:19:24 riastradh Exp $ */ +/* $NetBSD: kernfs_vnops.c,v 1.164 2020/02/24 20:44:25 ad Exp $ */ /* * Copyright (c) 1992, 1993 @@ -39,7 +39,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kernfs_vnops.c,v 1.163 2020/02/04 04:19:24 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kernfs_vnops.c,v 1.164 2020/02/24 20:44:25 ad Exp $"); #include #include @@ -1229,7 +1229,7 @@ kernfs_getpages(void *v) } */ *ap = v; if ((ap->a_flags & PGO_LOCKED) == 0) - mutex_exit(ap->a_vp->v_interlock); + rw_exit(ap->a_vp->v_uobj.vmobjlock); return (EFAULT); }
CVS commit: src/sys/miscfs/kernfs
Module Name:src Committed By: dholland Date: Tue Jul 6 03:22:44 UTC 2021 Modified Files: src/sys/miscfs/kernfs: kernfs_vnops.c Log Message: Add missing VOP_KQFILTER to kernfs. Not sure if lack of it can be used for local DoS or not, but best to fix. To generate a diff of this commit: cvs rdiff -u -r1.168 -r1.169 src/sys/miscfs/kernfs/kernfs_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/miscfs/kernfs/kernfs_vnops.c diff -u src/sys/miscfs/kernfs/kernfs_vnops.c:1.168 src/sys/miscfs/kernfs/kernfs_vnops.c:1.169 --- src/sys/miscfs/kernfs/kernfs_vnops.c:1.168 Tue Jun 29 22:34:08 2021 +++ src/sys/miscfs/kernfs/kernfs_vnops.c Tue Jul 6 03:22:44 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: kernfs_vnops.c,v 1.168 2021/06/29 22:34:08 dholland Exp $ */ +/* $NetBSD: kernfs_vnops.c,v 1.169 2021/07/06 03:22:44 dholland Exp $ */ /* * Copyright (c) 1992, 1993 @@ -39,7 +39,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kernfs_vnops.c,v 1.168 2021/06/29 22:34:08 dholland Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kernfs_vnops.c,v 1.169 2021/07/06 03:22:44 dholland Exp $"); #include #include @@ -199,6 +199,7 @@ const struct vnodeopv_entry_desc kernfs_ { &vop_fcntl_desc, kernfs_fcntl }, /* fcntl */ { &vop_ioctl_desc, kernfs_ioctl }, /* ioctl */ { &vop_poll_desc, kernfs_poll }, /* poll */ + { &vop_kqfilter_desc, genfs_kqfilter }, /* kqfilter */ { &vop_revoke_desc, kernfs_revoke }, /* revoke */ { &vop_fsync_desc, kernfs_fsync }, /* fsync */ { &vop_seek_desc, kernfs_seek }, /* seek */ @@ -249,6 +250,7 @@ const struct vnodeopv_entry_desc kernfs_ { &vop_fcntl_desc, spec_fcntl }, /* fcntl */ { &vop_ioctl_desc, spec_ioctl }, /* ioctl */ { &vop_poll_desc, spec_poll }, /* poll */ + { &vop_kqfilter_desc, genfs_kqfilter }, /* kqfilter */ { &vop_revoke_desc, spec_revoke }, /* revoke */ { &vop_fsync_desc, spec_fsync }, /* fsync */ { &vop_seek_desc, spec_seek }, /* seek */
CVS commit: src/sys/miscfs/kernfs
Module Name:src Committed By: dholland Date: Tue Jul 6 03:23:03 UTC 2021 Modified Files: src/sys/miscfs/kernfs: kernfs_vnops.c Log Message: Fix perms on /kern/{r,}rootdev. To generate a diff of this commit: cvs rdiff -u -r1.169 -r1.170 src/sys/miscfs/kernfs/kernfs_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/miscfs/kernfs/kernfs_vnops.c diff -u src/sys/miscfs/kernfs/kernfs_vnops.c:1.169 src/sys/miscfs/kernfs/kernfs_vnops.c:1.170 --- src/sys/miscfs/kernfs/kernfs_vnops.c:1.169 Tue Jul 6 03:22:44 2021 +++ src/sys/miscfs/kernfs/kernfs_vnops.c Tue Jul 6 03:23:03 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: kernfs_vnops.c,v 1.169 2021/07/06 03:22:44 dholland Exp $ */ +/* $NetBSD: kernfs_vnops.c,v 1.170 2021/07/06 03:23:03 dholland Exp $ */ /* * Copyright (c) 1992, 1993 @@ -39,7 +39,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kernfs_vnops.c,v 1.169 2021/07/06 03:22:44 dholland Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kernfs_vnops.c,v 1.170 2021/07/06 03:23:03 dholland Exp $"); #include #include @@ -91,8 +91,8 @@ const struct kern_target kern_targets[] #if 0 { DT_DIR, N("root"), 0,KFSnull,VDIR, DIR_MODE }, #endif - { DT_BLK, N("rootdev"), &rootdev, KFSdevice, VBLK, READ_MODE }, - { DT_CHR, N("rrootdev"), &rrootdev,KFSdevice, VCHR, READ_MODE }, + { DT_BLK, N("rootdev"), &rootdev, KFSdevice, VBLK, UREAD_MODE }, + { DT_CHR, N("rrootdev"), &rrootdev,KFSdevice, VCHR, UREAD_MODE }, { DT_REG, N("time"), 0,KFStime,VREG, READ_MODE }, /* XXXUNCONST */ { DT_REG, N("version"), __UNCONST(version),
CVS commit: src/sys/miscfs/kernfs
Module Name:src Committed By: dholland Date: Mon Jul 19 01:33:53 UTC 2021 Modified Files: src/sys/miscfs/kernfs: kernfs_vnops.c Log Message: Abolish all the silly indirection macros for initializing vnode ops tables. These are things of the form #define foofs_op genfs_op, or #define foofs_op genfs_eopnotsupp, or similar. They serve no purpose besides obfuscation, and have gotten cutpasted all over everywhere. Part 3; cvs randomly didn't commit all the files the first time, still hunting down the files it skipped. To generate a diff of this commit: cvs rdiff -u -r1.171 -r1.172 src/sys/miscfs/kernfs/kernfs_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/miscfs/kernfs/kernfs_vnops.c diff -u src/sys/miscfs/kernfs/kernfs_vnops.c:1.171 src/sys/miscfs/kernfs/kernfs_vnops.c:1.172 --- src/sys/miscfs/kernfs/kernfs_vnops.c:1.171 Sun Jul 18 23:56:13 2021 +++ src/sys/miscfs/kernfs/kernfs_vnops.c Mon Jul 19 01:33:53 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: kernfs_vnops.c,v 1.171 2021/07/18 23:56:13 dholland Exp $ */ +/* $NetBSD: kernfs_vnops.c,v 1.172 2021/07/19 01:33:53 dholland Exp $ */ /* * Copyright (c) 1992, 1993 @@ -39,7 +39,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kernfs_vnops.c,v 1.171 2021/07/18 23:56:13 dholland Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kernfs_vnops.c,v 1.172 2021/07/19 01:33:53 dholland Exp $"); #include #include @@ -137,8 +137,6 @@ const struct kernfs_fileop kernfs_defaul }; int kernfs_lookup(void *); -#define kernfs_create genfs_eopnotsupp -#define kernfs_mknod genfs_eopnotsupp int kernfs_open(void *); int kernfs_close(void *); int kernfs_access(void *); @@ -146,34 +144,15 @@ int kernfs_getattr(void *); int kernfs_setattr(void *); int kernfs_read(void *); int kernfs_write(void *); -#define kernfs_fcntl genfs_fcntl int kernfs_ioctl(void *); -#define kernfs_poll genfs_poll -#define kernfs_revoke genfs_revoke -#define kernfs_fsync genfs_nullop -#define kernfs_seek genfs_nullop -#define kernfs_remove genfs_eopnotsupp int kernfs_link(void *); -#define kernfs_rename genfs_eopnotsupp -#define kernfs_mkdir genfs_eopnotsupp -#define kernfs_rmdir genfs_eopnotsupp int kernfs_symlink(void *); int kernfs_readdir(void *); -#define kernfs_readlink genfs_eopnotsupp -#define kernfs_abortop genfs_abortop int kernfs_inactive(void *); int kernfs_reclaim(void *); -#define kernfs_lock genfs_lock -#define kernfs_unlock genfs_unlock -#define kernfs_bmap genfs_badop -#define kernfs_strategy genfs_eopnotsupp int kernfs_print(void *); -#define kernfs_islocked genfs_islocked int kernfs_pathconf(void *); -#define kernfs_advlock genfs_einval -#define kernfs_bwrite genfs_eopnotsupp int kernfs_getpages(void *); -#define kernfs_putpages genfs_putpages static int kernfs_xread(struct kernfs_node *, int, char **, size_t, size_t *); @@ -184,8 +163,8 @@ const struct vnodeopv_entry_desc kernfs_ { &vop_default_desc, vn_default_error }, { &vop_parsepath_desc, genfs_parsepath }, /* parsepath */ { &vop_lookup_desc, kernfs_lookup }, /* lookup */ - { &vop_create_desc, kernfs_create }, /* create */ - { &vop_mknod_desc, kernfs_mknod }, /* mknod */ + { &vop_create_desc, genfs_eopnotsupp }, /* create */ + { &vop_mknod_desc, genfs_eopnotsupp }, /* mknod */ { &vop_open_desc, kernfs_open }, /* open */ { &vop_close_desc, kernfs_close }, /* close */ { &vop_access_desc, kernfs_access }, /* access */ @@ -196,35 +175,35 @@ const struct vnodeopv_entry_desc kernfs_ { &vop_write_desc, kernfs_write }, /* write */ { &vop_fallocate_desc, genfs_eopnotsupp }, /* fallocate */ { &vop_fdiscard_desc, genfs_eopnotsupp }, /* fdiscard */ - { &vop_fcntl_desc, kernfs_fcntl }, /* fcntl */ + { &vop_fcntl_desc, genfs_fcntl }, /* fcntl */ { &vop_ioctl_desc, kernfs_ioctl }, /* ioctl */ - { &vop_poll_desc, kernfs_poll }, /* poll */ + { &vop_poll_desc, genfs_poll }, /* poll */ { &vop_kqfilter_desc, genfs_kqfilter }, /* kqfilter */ - { &vop_revoke_desc, kernfs_revoke }, /* revoke */ - { &vop_fsync_desc, kernfs_fsync }, /* fsync */ - { &vop_seek_desc, kernfs_seek }, /* seek */ - { &vop_remove_desc, kernfs_remove }, /* remove */ + { &vop_revoke_desc, genfs_revoke }, /* revoke */ + { &vop_fsync_desc, genfs_nullop }, /* fsync */ + { &vop_seek_desc, genfs_nullop }, /* seek */ + { &vop_remove_desc, genfs_eopnotsupp }, /* remove */ { &vop_link_desc, kernfs_link }, /* link */ - { &vop_rename_desc, kernfs_rename }, /* rename */ - { &vop_mkdir_desc, kernfs_mkdir }, /* mkdir */ - { &vop_rmdir_desc, kernfs_rmdir }, /* rmdir */ + { &vop_rename_desc, genfs_eopnotsupp }, /* rename */ + { &vop_mkdir_desc, genfs_eopnotsupp }, /* mkdir */ + { &vop_rmdir_desc, genfs_eopnotsupp }, /* rmdir */ { &vop_symlink_desc, kernfs_symlink }, /* symlink */ { &vop_readdir_desc, kernfs_readdir }, /* readdir */ - { &vop_readlink_desc, kernfs_readlink }, /* readlink */ - { &vo
CVS commit: src/sys/miscfs/kernfs
Module Name:src Committed By: christos Date: Tue Sep 27 01:23:05 UTC 2011 Modified Files: src/sys/miscfs/kernfs: kernfs.h kernfs_vfsops.c Log Message: define KERNFS_MAXNAMLEN and use it.` To generate a diff of this commit: cvs rdiff -u -r1.35 -r1.36 src/sys/miscfs/kernfs/kernfs.h cvs rdiff -u -r1.90 -r1.91 src/sys/miscfs/kernfs/kernfs_vfsops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/miscfs/kernfs/kernfs.h diff -u src/sys/miscfs/kernfs/kernfs.h:1.35 src/sys/miscfs/kernfs/kernfs.h:1.36 --- src/sys/miscfs/kernfs/kernfs.h:1.35 Sat Jan 10 21:45:53 2009 +++ src/sys/miscfs/kernfs/kernfs.h Mon Sep 26 21:23:05 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: kernfs.h,v 1.35 2009/01/11 02:45:53 christos Exp $ */ +/* $NetBSD: kernfs.h,v 1.36 2011/09/27 01:23:05 christos Exp $ */ /* * Copyright (c) 1992, 1993 @@ -119,6 +119,8 @@ struct kernfs_mount { #define VTOKERN(vp) ((struct kernfs_node *)(vp)->v_data) #define KERNFSTOV(kfs) ((kfs)->kfs_vnode) +#define KERNFS_MAXNAMLEN 255 + extern const struct kern_target kern_targets[]; extern int nkern_targets; extern const int static_nkern_targets; Index: src/sys/miscfs/kernfs/kernfs_vfsops.c diff -u src/sys/miscfs/kernfs/kernfs_vfsops.c:1.90 src/sys/miscfs/kernfs/kernfs_vfsops.c:1.91 --- src/sys/miscfs/kernfs/kernfs_vfsops.c:1.90 Mon Nov 30 05:59:20 2009 +++ src/sys/miscfs/kernfs/kernfs_vfsops.c Mon Sep 26 21:23:05 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: kernfs_vfsops.c,v 1.90 2009/11/30 10:59:20 pooka Exp $ */ +/* $NetBSD: kernfs_vfsops.c,v 1.91 2011/09/27 01:23:05 christos Exp $ */ /* * Copyright (c) 1992, 1993, 1995 @@ -39,7 +39,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kernfs_vfsops.c,v 1.90 2009/11/30 10:59:20 pooka Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kernfs_vfsops.c,v 1.91 2011/09/27 01:23:05 christos Exp $"); #ifdef _KERNEL_OPT #include "opt_compat_netbsd.h" @@ -145,7 +145,7 @@ kernfs_mount(struct mount *mp, const cha fmp = malloc(sizeof(struct kernfs_mount), M_KERNFSMNT, M_WAITOK|M_ZERO); TAILQ_INIT(&fmp->nodelist); - mp->mnt_stat.f_namemax = MAXNAMLEN; + mp->mnt_stat.f_namemax = KERNFS_MAXNAMLEN; mp->mnt_flag |= MNT_LOCAL; mp->mnt_data = fmp; vfs_getnewfsid(mp);
CVS commit: src/sys/miscfs/kernfs
Module Name:src Committed By: njoly Date: Fri Jan 22 22:46:01 UTC 2010 Modified Files: src/sys/miscfs/kernfs: kernfs_vnops.c Log Message: Remove unneeded strlen() call in KFShostname case. To generate a diff of this commit: cvs rdiff -u -r1.139 -r1.140 src/sys/miscfs/kernfs/kernfs_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/miscfs/kernfs/kernfs_vnops.c diff -u src/sys/miscfs/kernfs/kernfs_vnops.c:1.139 src/sys/miscfs/kernfs/kernfs_vnops.c:1.140 --- src/sys/miscfs/kernfs/kernfs_vnops.c:1.139 Fri Jan 8 11:35:11 2010 +++ src/sys/miscfs/kernfs/kernfs_vnops.c Fri Jan 22 22:46:00 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: kernfs_vnops.c,v 1.139 2010/01/08 11:35:11 pooka Exp $ */ +/* $NetBSD: kernfs_vnops.c,v 1.140 2010/01/22 22:46:00 njoly Exp $ */ /* * Copyright (c) 1992, 1993 @@ -39,7 +39,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kernfs_vnops.c,v 1.139 2010/01/08 11:35:11 pooka Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kernfs_vnops.c,v 1.140 2010/01/22 22:46:00 njoly Exp $"); #ifdef _KERNEL_OPT #include "opt_ipsec.h" @@ -458,7 +458,6 @@ memcpy(*bufp, cp, xlen); (*bufp)[xlen] = '\n'; (*bufp)[xlen+1] = '\0'; - len = strlen(*bufp); break; }
CVS commit: src/sys/miscfs/kernfs
Module Name:src Committed By: pooka Date: Wed Mar 31 01:27:05 UTC 2010 Modified Files: src/sys/miscfs/kernfs: kernfs_vnops.c Log Message: If msgbuf is not enabled, do not report the node in readdir. That way ls -l won't report funny errors because getattr for a readdir result fails. XXX: lookup for msgbuf still succeeds even if not enabled To generate a diff of this commit: cvs rdiff -u -r1.140 -r1.141 src/sys/miscfs/kernfs/kernfs_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/miscfs/kernfs/kernfs_vnops.c diff -u src/sys/miscfs/kernfs/kernfs_vnops.c:1.140 src/sys/miscfs/kernfs/kernfs_vnops.c:1.141 --- src/sys/miscfs/kernfs/kernfs_vnops.c:1.140 Fri Jan 22 22:46:00 2010 +++ src/sys/miscfs/kernfs/kernfs_vnops.c Wed Mar 31 01:27:05 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: kernfs_vnops.c,v 1.140 2010/01/22 22:46:00 njoly Exp $ */ +/* $NetBSD: kernfs_vnops.c,v 1.141 2010/03/31 01:27:05 pooka Exp $ */ /* * Copyright (c) 1992, 1993 @@ -39,7 +39,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kernfs_vnops.c,v 1.140 2010/01/22 22:46:00 njoly Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kernfs_vnops.c,v 1.141 2010/03/31 01:27:05 pooka Exp $"); #ifdef _KERNEL_OPT #include "opt_ipsec.h" @@ -1169,6 +1169,12 @@ !vfinddev(*dp, kt->kt_vtype, &fvp)) continue; } + if (kt->kt_tag == KFSmsgbuf) { +if (!msgbufenabled +|| msgbufp->msg_magic != MSG_MAGIC) { + continue; +} + } d.d_namlen = kt->kt_namlen; if ((error = kernfs_setdirentfileno(&d, i, kfs, &kern_targets[0], kt, ap)) != 0)
CVS commit: src/sys/miscfs/kernfs
Module Name:src Committed By: christos Date: Tue Apr 8 17:56:10 UTC 2014 Modified Files: src/sys/miscfs/kernfs: kernfs_subr.c kernfs_vnops.c Log Message: >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. To generate a diff of this commit: cvs rdiff -u -r1.26 -r1.27 src/sys/miscfs/kernfs/kernfs_subr.c cvs rdiff -u -r1.150 -r1.151 src/sys/miscfs/kernfs/kernfs_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/miscfs/kernfs/kernfs_subr.c diff -u src/sys/miscfs/kernfs/kernfs_subr.c:1.26 src/sys/miscfs/kernfs/kernfs_subr.c:1.27 --- src/sys/miscfs/kernfs/kernfs_subr.c:1.26 Thu Feb 27 11:51:38 2014 +++ src/sys/miscfs/kernfs/kernfs_subr.c Tue Apr 8 13:56:10 2014 @@ -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 -__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 #include @@ -88,6 +88,7 @@ __KERNEL_RCSID(0, "$NetBSD: kernfs_subr. #include #include +#include void kernfs_hashins(struct kernfs_node *); void kernfs_hashrem(struct kernfs_node *); @@ -147,32 +148,6 @@ kernfs_allocvp(struct mount *mp, struct 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 @@ again: 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); Index: src/sys/miscfs/kernfs/kernfs_vnops.c diff -u src/sys/miscfs/kernfs/kernfs_vnops.c:1.150 src/sys/miscfs/kernfs/kernfs_vnops.c:1.151 --- src/sys/miscfs/kernfs/kernfs_vnops.c:1.150 Fri Feb 7 10:29:22 2014 +++ src/sys/miscfs/kernfs/kernfs_vnops.c Tue Apr 8 13:56:10 2014 @@ -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 -__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 #include @@ -59,6 +59,7 @@ __KERNEL_RCSID(0, "$NetBSD: kernfs_vnops #include #include +#include #include @@ -653,6 +654,11 @@ kernfs_getattr(void *v) 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 @@ kernfs_getattr(void *v) case KFSstring: case KFShostname: case KFSavenrun: - case KFSdevice: case KFSmsgbuf: vap->va_nlink = 1; total = 0; @@ -832,18 +837,8 @@ kernfs_setdirentfileno_kt(struct dirent 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; }
CVS commit: src/sys/miscfs/kernfs
Module Name:src Committed By: hannken Date: Thu Jul 17 08:21:34 UTC 2014 Modified Files: src/sys/miscfs/kernfs: kernfs.h kernfs_subr.c kernfs_vfsops.c kernfs_vnops.c Log Message: Finish KAME IPSEC removal: - Remove field kfs_value, it is always zero. Compute the hash from kt_tag. - Remove stray definitions kernfs_revoke_sa and kernfs_revoke_sp. While here, remove kfs_type from allocvp(), it is always kt->kt_tag. To generate a diff of this commit: cvs rdiff -u -r1.37 -r1.38 src/sys/miscfs/kernfs/kernfs.h cvs rdiff -u -r1.27 -r1.28 src/sys/miscfs/kernfs/kernfs_subr.c cvs rdiff -u -r1.93 -r1.94 src/sys/miscfs/kernfs/kernfs_vfsops.c cvs rdiff -u -r1.151 -r1.152 src/sys/miscfs/kernfs/kernfs_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/miscfs/kernfs/kernfs.h diff -u src/sys/miscfs/kernfs/kernfs.h:1.37 src/sys/miscfs/kernfs/kernfs.h:1.38 --- src/sys/miscfs/kernfs/kernfs.h:1.37 Thu Mar 22 20:34:38 2012 +++ src/sys/miscfs/kernfs/kernfs.h Thu Jul 17 08:21:34 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: kernfs.h,v 1.37 2012/03/22 20:34:38 drochner Exp $ */ +/* $NetBSD: kernfs.h,v 1.38 2014/07/17 08:21:34 hannken Exp $ */ /* * Copyright (c) 1992, 1993 @@ -91,9 +91,8 @@ struct kernfs_node { kfstype kfs_type; /* type of kernfs node */ mode_t kfs_mode; /* mode bits for stat() */ long kfs_fileno; /* unique file id */ - u_int32_t kfs_value; /* SA id or SP id (KFSint) */ const struct kern_target *kfs_kt; - void *kfs_v; /* pointer to secasvar/secpolicy/mbuf */ + void *kfs_v; /* dynamic node private data */ long kfs_cookie; /* fileno cookie */ }; @@ -133,11 +132,7 @@ void kernfs_hashinit(void); void kernfs_hashreinit(void); void kernfs_hashdone(void); int kernfs_freevp(struct vnode *); -int kernfs_allocvp(struct mount *, struct vnode **, kfstype, - const struct kern_target *, u_int32_t); - -void kernfs_revoke_sa(struct secasvar *); -void kernfs_revoke_sp(struct secpolicy *); +int kernfs_allocvp(struct mount *, struct vnode **, const struct kern_target *); /* * Data types for the kernfs file operations. Index: src/sys/miscfs/kernfs/kernfs_subr.c diff -u src/sys/miscfs/kernfs/kernfs_subr.c:1.27 src/sys/miscfs/kernfs/kernfs_subr.c:1.28 --- src/sys/miscfs/kernfs/kernfs_subr.c:1.27 Tue Apr 8 17:56:10 2014 +++ src/sys/miscfs/kernfs/kernfs_subr.c Thu Jul 17 08:21:34 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: kernfs_subr.c,v 1.27 2014/04/08 17:56:10 christos Exp $ */ +/* $NetBSD: kernfs_subr.c,v 1.28 2014/07/17 08:21:34 hannken Exp $ */ /* * Copyright (c) 1993 @@ -73,7 +73,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kernfs_subr.c,v 1.27 2014/04/08 17:56:10 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kernfs_subr.c,v 1.28 2014/07/17 08:21:34 hannken Exp $"); #include #include @@ -93,11 +93,11 @@ __KERNEL_RCSID(0, "$NetBSD: kernfs_subr. void kernfs_hashins(struct kernfs_node *); void kernfs_hashrem(struct kernfs_node *); struct vnode *kernfs_hashget(kfstype, struct mount *, -const struct kern_target *, u_int32_t); +const struct kern_target *); static LIST_HEAD(kfs_hashhead, kernfs_node) *kfs_hashtbl; static u_long kfs_ihash; /* size of hash table - 1 */ -#define KFSVALUEHASH(v) ((v) & kfs_ihash) +#define KFSHASH(v) ((v) & kfs_ihash) static kmutex_t kfs_hashlock; static kmutex_t kfs_ihash_lock; @@ -108,7 +108,7 @@ static kmutex_t kfs_ihash_lock; * allocate a kfsnode/vnode pair. the vnode is * referenced, and locked. * - * the kfs_type, kfs_value and mount point uniquely + * the kfs_type and mount point uniquely * identify a kfsnode. the mount point is needed * because someone might mount this filesystem * twice. @@ -131,19 +131,19 @@ static kmutex_t kfs_ihash_lock; * the vnode free list. */ int -kernfs_allocvp(struct mount *mp, struct vnode **vpp, kfstype kfs_type, -const struct kern_target *kt, u_int32_t value) +kernfs_allocvp(struct mount *mp, struct vnode **vpp, +const struct kern_target *kt) { struct kernfs_node *kfs = NULL, *kfsp; struct vnode *vp = NULL; int error; long *cookie; - if ((*vpp = kernfs_hashget(kfs_type, mp, kt, value)) != NULL) + if ((*vpp = kernfs_hashget(kt->kt_tag, mp, kt)) != NULL) return (0); mutex_enter(&kfs_hashlock); - if ((*vpp = kernfs_hashget(kfs_type, mp, kt, value)) != NULL) { + if ((*vpp = kernfs_hashget(kt->kt_tag, mp, kt)) != NULL) { mutex_exit(&kfs_hashlock); return (0); } @@ -184,18 +184,17 @@ again: else TAILQ_INSERT_TAIL(&VFSTOKERNFS(mp)->nodelist, kfs, kfs_list); - kfs->kfs_type = kfs_type; + kfs->kfs_type = kt->kt_tag; kfs->kfs_vnode = vp; - kfs->kfs_fileno = KERNFS_FILENO(kt, kfs_type, kfs->kfs_cookie); - kfs->kfs_value = value; + kfs->kfs_fileno = KERNFS_FILENO(kt, kt->kt_tag, kfs->kfs_cookie); kfs->kfs_kt = kt; kfs->kfs_mode = kt->kt_mode; vp->v_type = kt->kt_vtype; - if (kfs_type == KFSkern) + if (kt->kt_tag == KFSkern)
CVS commit: src/sys/miscfs/kernfs
Module Name:src Committed By: hannken Date: Sun Jul 20 13:17:37 UTC 2014 Modified Files: src/sys/miscfs/kernfs: kernfs.h Log Message: Remove another KAME IPSEC residue, "struct secasvar" and "struct secpolicy". To generate a diff of this commit: cvs rdiff -u -r1.38 -r1.39 src/sys/miscfs/kernfs/kernfs.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/miscfs/kernfs/kernfs.h diff -u src/sys/miscfs/kernfs/kernfs.h:1.38 src/sys/miscfs/kernfs/kernfs.h:1.39 --- src/sys/miscfs/kernfs/kernfs.h:1.38 Thu Jul 17 08:21:34 2014 +++ src/sys/miscfs/kernfs/kernfs.h Sun Jul 20 13:17:37 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: kernfs.h,v 1.38 2014/07/17 08:21:34 hannken Exp $ */ +/* $NetBSD: kernfs.h,v 1.39 2014/07/20 13:17:37 hannken Exp $ */ /* * Copyright (c) 1992, 1993 @@ -123,9 +123,6 @@ extern int (**kernfs_vnodeop_p)(void *); extern struct vfsops kernfs_vfsops; extern dev_t rrootdev; -struct secasvar; -struct secpolicy; - int kernfs_root(struct mount *, struct vnode **); void kernfs_hashinit(void);