Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys make it possible for UNION fs to be loaded via LKM - ins...
details: https://anonhg.NetBSD.org/src/rev/cd187ebe378b
branches: trunk
changeset: 544332:cd187ebe378b
user: jdolecek <jdolecek%NetBSD.org@localhost>
date: Mon Mar 17 09:11:29 2003 +0000
description:
make it possible for UNION fs to be loaded via LKM - instead of
having some #ifdef UNION code in vfs_vnops.c, introduce variable
'vn_union_readdir_hook' which is set to address of appropriate
vn_readdir() hook by union filesystem when it's loaded & mounted
diffstat:
sys/fs/union/union.h | 3 +-
sys/fs/union/union_subr.c | 50 +++++++++++++++++++++++++++++++++++++++--
sys/fs/union/union_vfsops.c | 9 +++++-
sys/kern/vfs_vnops.c | 53 +++++++++++---------------------------------
sys/sys/vnode.h | 7 +++++-
5 files changed, 76 insertions(+), 46 deletions(-)
diffs (227 lines):
diff -r 80f6a2c14d10 -r cd187ebe378b sys/fs/union/union.h
--- a/sys/fs/union/union.h Mon Mar 17 09:06:40 2003 +0000
+++ b/sys/fs/union/union.h Mon Mar 17 09:11:29 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: union.h,v 1.1 2003/03/16 08:26:51 jdolecek Exp $ */
+/* $NetBSD: union.h,v 1.2 2003/03/17 09:11:30 jdolecek Exp $ */
/*
* Copyright (c) 1994 The Regents of the University of California.
@@ -122,6 +122,7 @@
extern void union_newlower __P((struct union_node *, struct vnode *));
extern void union_newupper __P((struct union_node *, struct vnode *));
extern void union_newsize __P((struct vnode *, off_t, off_t));
+int union_readdirhook(struct vnode **, struct file *, struct proc *);
#define MOUNTTOUNIONMOUNT(mp) ((struct union_mount *)((mp)->mnt_data))
#define VTOUNION(vp) ((struct union_node *)(vp)->v_data)
diff -r 80f6a2c14d10 -r cd187ebe378b sys/fs/union/union_subr.c
--- a/sys/fs/union/union_subr.c Mon Mar 17 09:06:40 2003 +0000
+++ b/sys/fs/union/union_subr.c Mon Mar 17 09:11:29 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: union_subr.c,v 1.1 2003/03/16 08:26:52 jdolecek Exp $ */
+/* $NetBSD: union_subr.c,v 1.2 2003/03/17 09:11:30 jdolecek Exp $ */
/*
* Copyright (c) 1994 Jan-Simon Pendry
@@ -40,7 +40,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: union_subr.c,v 1.1 2003/03/16 08:26:52 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: union_subr.c,v 1.2 2003/03/17 09:11:30 jdolecek Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -100,7 +100,9 @@
void
union_done()
{
- /* Nothing */
+
+ /* Make sure to unset the readdir hook. */
+ vn_union_readdir_hook = NULL;
}
static int
@@ -1153,3 +1155,45 @@
un->un_dircache = 0;
}
}
+
+/*
+ * This hook is called from vn_readdir() to switch to lower directory
+ * entry after the upper directory is read.
+ */
+int
+union_readdirhook(struct vnode **vpp, struct file *fp, struct proc *p)
+{
+ struct vnode *vp = *vpp, *lvp;
+ struct vattr va;
+ int error;
+
+ if (vp->v_op != union_vnodeop_p)
+ return (0);
+
+ if ((lvp = union_dircache(vp, p)) == NULLVP)
+ return (0);
+
+ /*
+ * If the directory is opaque,
+ * then don't show lower entries
+ */
+ error = VOP_GETATTR(vp, &va, fp->f_cred, p);
+ if (error || (va.va_flags & OPAQUE)) {
+ vput(lvp);
+ return (error);
+ }
+
+ error = VOP_OPEN(lvp, FREAD, fp->f_cred, p);
+ if (error) {
+ vput(lvp);
+ return (error);
+ }
+ VOP_UNLOCK(lvp, 0);
+ fp->f_data = (caddr_t) lvp;
+ fp->f_offset = 0;
+ error = vn_close(vp, FREAD, fp->f_cred, p);
+ if (error)
+ return (error);
+ *vpp = lvp;
+ return (0);
+}
diff -r 80f6a2c14d10 -r cd187ebe378b sys/fs/union/union_vfsops.c
--- a/sys/fs/union/union_vfsops.c Mon Mar 17 09:06:40 2003 +0000
+++ b/sys/fs/union/union_vfsops.c Mon Mar 17 09:11:29 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: union_vfsops.c,v 1.1 2003/03/16 08:26:54 jdolecek Exp $ */
+/* $NetBSD: union_vfsops.c,v 1.2 2003/03/17 09:11:31 jdolecek Exp $ */
/*
* Copyright (c) 1994 The Regents of the University of California.
@@ -44,7 +44,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: union_vfsops.c,v 1.1 2003/03/16 08:26:54 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: union_vfsops.c,v 1.2 2003/03/17 09:11:31 jdolecek Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -259,6 +259,11 @@
printf("union_mount: from %s, on %s\n",
mp->mnt_stat.f_mntfromname, mp->mnt_stat.f_mntonname);
#endif
+
+ /* Setup the readdir hook if it's not set already */
+ if (!vn_union_readdir_hook)
+ vn_union_readdir_hook = union_readdirhook;
+
return (0);
bad:
diff -r 80f6a2c14d10 -r cd187ebe378b sys/kern/vfs_vnops.c
--- a/sys/kern/vfs_vnops.c Mon Mar 17 09:06:40 2003 +0000
+++ b/sys/kern/vfs_vnops.c Mon Mar 17 09:11:29 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vfs_vnops.c,v 1.65 2003/03/16 08:26:48 jdolecek Exp $ */
+/* $NetBSD: vfs_vnops.c,v 1.66 2003/03/17 09:11:30 jdolecek Exp $ */
/*
* Copyright (c) 1982, 1986, 1989, 1993
@@ -41,7 +41,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_vnops.c,v 1.65 2003/03/16 08:26:48 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_vnops.c,v 1.66 2003/03/17 09:11:30 jdolecek Exp $");
#include "fs_union.h"
@@ -65,6 +65,10 @@
#include <fs/union/union.h>
#endif
+#if defined(LKM) || defined(UNION)
+int (*vn_union_readdir_hook) (struct vnode **, struct file *, struct proc *);
+#endif
+
#ifdef VERIFIED_EXEC
#include <sys/verified_exec.h>
@@ -440,46 +444,17 @@
if (error)
return (error);
-#ifdef UNION
-{
- extern struct vnode *union_dircache __P((struct vnode *));
-
- if (count == auio.uio_resid && (vp->v_op == union_vnodeop_p)) {
- struct vnode *lvp;
-
- lvp = union_dircache(vp);
- if (lvp != NULLVP) {
- struct vattr va;
+#if defined(UNION) || defined(LKM)
+ if (count == auio.uio_resid && vn_union_readdir_hook) {
+ struct vnode *ovp = vp;
- /*
- * If the directory is opaque,
- * then don't show lower entries
- */
- error = VOP_GETATTR(vp, &va, fp->f_cred, p);
- if (va.va_flags & OPAQUE) {
- vput(lvp);
- lvp = NULL;
- }
- }
-
- if (lvp != NULLVP) {
- error = VOP_OPEN(lvp, FREAD, fp->f_cred, p);
- if (error) {
- vput(lvp);
- return (error);
- }
- VOP_UNLOCK(lvp, 0);
- fp->f_data = (caddr_t) lvp;
- fp->f_offset = 0;
- error = vn_close(vp, FREAD, fp->f_cred, p);
- if (error)
- return (error);
- vp = lvp;
+ error = (*vn_union_readdir_hook)(&vp, fp, p);
+ if (error)
+ return (error);
+ if (vp != ovp)
goto unionread;
- }
}
-}
-#endif /* UNION */
+#endif /* UNION || LKM */
if (count == auio.uio_resid && (vp->v_flag & VROOT) &&
(vp->v_mount->mnt_flag & MNT_UNION)) {
diff -r 80f6a2c14d10 -r cd187ebe378b sys/sys/vnode.h
--- a/sys/sys/vnode.h Mon Mar 17 09:06:40 2003 +0000
+++ b/sys/sys/vnode.h Mon Mar 17 09:11:29 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vnode.h,v 1.105 2003/03/17 09:06:40 jdolecek Exp $ */
+/* $NetBSD: vnode.h,v 1.106 2003/03/17 09:11:29 jdolecek Exp $ */
/*
* Copyright (c) 1989, 1993
@@ -441,6 +441,11 @@
extern struct simplelock mntvnode_slock;
/*
+ * Union filesystem hook for vn_readdir().
+ */
+extern int (*vn_union_readdir_hook) (struct vnode **, struct file *, struct proc *);
+
+/*
* This macro is very helpful in defining those offsets in the vdesc struct.
*
* This is stolen from X11R4. I ingored all the fancy stuff for
Home |
Main Index |
Thread Index |
Old Index