From 00fff2c71ae42930e386234f26c514a89b458e91 Mon Sep 17 00:00:00 2001 From: "Tim J. Robbins" Date: Sat, 3 Jan 2004 00:36:46 +0000 Subject: [PATCH] Pass ACL, extended attribute and MAC vnode ops down the vnode stack. --- sys/fs/unionfs/union_vnops.c | 239 +++++++++++++++++++++++++++++++++++ 1 file changed, 239 insertions(+) diff --git a/sys/fs/unionfs/union_vnops.c b/sys/fs/unionfs/union_vnops.c index e9449ad85c31..be7b28c8eee4 100644 --- a/sys/fs/unionfs/union_vnops.c +++ b/sys/fs/unionfs/union_vnops.c @@ -51,6 +51,11 @@ #include #include #include +#include +#include +#include +#include +#include #include #include @@ -68,18 +73,24 @@ SYSCTL_INT(_vfs, OID_AUTO, uniondebug, CTLFLAG_RD, &uniondebug, 0, ""); #endif static int union_access(struct vop_access_args *ap); +static int union_aclcheck(struct vop_aclcheck_args *ap); static int union_advlock(struct vop_advlock_args *ap); static int union_close(struct vop_close_args *ap); +static int union_closeextattr(struct vop_closeextattr_args *ap); static int union_create(struct vop_create_args *ap); static int union_createvobject(struct vop_createvobject_args *ap); +static int union_deleteextattr(struct vop_deleteextattr_args *ap); static int union_destroyvobject(struct vop_destroyvobject_args *ap); static int union_fsync(struct vop_fsync_args *ap); +static int union_getacl(struct vop_getacl_args *ap); static int union_getattr(struct vop_getattr_args *ap); +static int union_getextattr(struct vop_getextattr_args *ap); static int union_getvobject(struct vop_getvobject_args *ap); static int union_inactive(struct vop_inactive_args *ap); static int union_ioctl(struct vop_ioctl_args *ap); static int union_lease(struct vop_lease_args *ap); static int union_link(struct vop_link_args *ap); +static int union_listextattr(struct vop_listextattr_args *ap); static int union_lookup(struct vop_lookup_args *ap); static int union_lookup1(struct vnode *udvp, struct vnode **dvp, struct vnode **vpp, @@ -87,6 +98,7 @@ static int union_lookup1(struct vnode *udvp, struct vnode **dvp, static int union_mkdir(struct vop_mkdir_args *ap); static int union_mknod(struct vop_mknod_args *ap); static int union_open(struct vop_open_args *ap); +static int union_openextattr(struct vop_openextattr_args *ap); static int union_pathconf(struct vop_pathconf_args *ap); static int union_print(struct vop_print_args *ap); static int union_read(struct vop_read_args *ap); @@ -99,7 +111,10 @@ static int union_rename(struct vop_rename_args *ap); static int union_revoke(struct vop_revoke_args *ap); static int union_rmdir(struct vop_rmdir_args *ap); static int union_poll(struct vop_poll_args *ap); +static int union_setacl(struct vop_setacl_args *ap); static int union_setattr(struct vop_setattr_args *ap); +static int union_setlabel(struct vop_setlabel_args *ap); +static int union_setextattr(struct vop_setextattr_args *ap); static int union_strategy(struct vop_strategy_args *ap); static int union_symlink(struct vop_symlink_args *ap); static int union_whiteout(struct vop_whiteout_args *ap); @@ -1836,6 +1851,220 @@ union_strategy(ap) return (VOP_STRATEGY(othervp, bp)); } +static int +union_getacl(ap) + struct vop_getacl_args /* { + struct vnode *a_vp; + acl_type_t a_type; + struct acl *a_aclp; + struct ucred *a_cred; + struct thread *a_td; + } */ *ap; +{ + int error; + struct union_node *un = VTOUNION(ap->a_vp); + struct vnode *vp; + + vp = union_lock_other(un, ap->a_td); + ap->a_vp = vp; + error = VCALL(vp, VOFFSET(vop_getacl), ap); + union_unlock_other(vp, ap->a_td); + + return (error); +} + +static int +union_setacl(ap) + struct vop_setacl_args /* { + struct vnode *a_vp; + acl_type_t a_type; + struct acl *a_aclp; + struct ucred *a_cred; + struct thread *a_td; + } */ *ap; +{ + int error; + struct union_node *un = VTOUNION(ap->a_vp); + struct vnode *vp; + + vp = union_lock_other(un, ap->a_td); + ap->a_vp = vp; + error = VCALL(vp, VOFFSET(vop_setacl), ap); + union_unlock_other(vp, ap->a_td); + + return (error); +} + +static int +union_aclcheck(ap) + struct vop_aclcheck_args /* { + struct vnode *a_vp; + acl_type_t a_type; + struct acl *a_aclp; + struct ucred *a_cred; + struct thread *a_td; + } */ *ap; +{ + struct vnode *ovp = OTHERVP(ap->a_vp); + + ap->a_vp = ovp; + return (VCALL(ovp, VOFFSET(vop_aclcheck), ap)); +} + +static int +union_closeextattr(ap) + struct vop_closeextattr_args /* { + struct vnode *a_vp; + int a_commit; + struct ucred *a_cred; + struct thread *a_td; + } */ *ap; +{ + int error; + struct union_node *un = VTOUNION(ap->a_vp); + struct vnode *vp; + + vp = union_lock_other(un, ap->a_td); + ap->a_vp = vp; + error = VCALL(vp, VOFFSET(vop_closeextattr), ap); + union_unlock_other(vp, ap->a_td); + + return (error); +} + +static int +union_getextattr(ap) + struct vop_getextattr_args /* { + struct vnode *a_vp; + int a_attrnamespace; + const char *a_name; + struct uio *a_uio; + size_t *a_size; + struct ucred *a_cred; + struct thread *a_td; + } */ *ap; +{ + int error; + struct union_node *un = VTOUNION(ap->a_vp); + struct vnode *vp; + + vp = union_lock_other(un, ap->a_td); + ap->a_vp = vp; + error = VCALL(vp, VOFFSET(vop_getextattr), ap); + union_unlock_other(vp, ap->a_td); + + return (error); +} + +static int +union_listextattr(ap) + struct vop_listextattr_args /* { + struct vnode *a_vp; + int a_attrnamespace; + struct uio *a_uio; + size_t *a_size; + struct ucred *a_cred; + struct thread *a_td; + } */ *ap; +{ + int error; + struct union_node *un = VTOUNION(ap->a_vp); + struct vnode *vp; + + vp = union_lock_other(un, ap->a_td); + ap->a_vp = vp; + error = VCALL(vp, VOFFSET(vop_listextattr), ap); + union_unlock_other(vp, ap->a_td); + + return (error); +} + +static int +union_openextattr(ap) + struct vop_openextattr_args /* { + struct vnode *a_vp; + struct ucred *a_cred; + struct thread *a_td; + } */ *ap; +{ + int error; + struct union_node *un = VTOUNION(ap->a_vp); + struct vnode *vp; + + vp = union_lock_other(un, ap->a_td); + ap->a_vp = vp; + error = VCALL(vp, VOFFSET(vop_openextattr), ap); + union_unlock_other(vp, ap->a_td); + + return (error); +} + +static int +union_deleteextattr(ap) + struct vop_deleteextattr_args /* { + struct vnode *a_vp; + int a_attrnamespace; + const char *a_name; + struct ucred *a_cred; + struct thread *a_td; + } */ *ap; +{ + int error; + struct union_node *un = VTOUNION(ap->a_vp); + struct vnode *vp; + + vp = union_lock_other(un, ap->a_td); + ap->a_vp = vp; + error = VCALL(vp, VOFFSET(vop_deleteextattr), ap); + union_unlock_other(vp, ap->a_td); + + return (error); +} + +static int +union_setextattr(ap) + struct vop_setextattr_args /* { + struct vnode *a_vp; + int a_attrnamespace; + const char *a_name; + struct uio *a_uio; + struct ucred *a_cred; + struct thread *a_td; + } */ *ap; +{ + int error; + struct union_node *un = VTOUNION(ap->a_vp); + struct vnode *vp; + + vp = union_lock_other(un, ap->a_td); + ap->a_vp = vp; + error = VCALL(vp, VOFFSET(vop_setextattr), ap); + union_unlock_other(vp, ap->a_td); + + return (error); +} + +static int +union_setlabel(ap) + struct vop_setlabel_args /* { + struct vnode *a_vp; + struct label *a_label; + struct ucred *a_cred; + struct thread *a_td; + } */ *ap; +{ + int error; + struct union_node *un = VTOUNION(ap->a_vp); + struct vnode *vp; + + vp = union_lock_other(un, ap->a_td); + ap->a_vp = vp; + error = VCALL(vp, VOFFSET(vop_setlabel), ap); + union_unlock_other(vp, ap->a_td); + + return (error); +} + /* * Global vfs data structures */ @@ -1843,23 +2072,30 @@ vop_t **union_vnodeop_p; static struct vnodeopv_entry_desc union_vnodeop_entries[] = { { &vop_default_desc, (vop_t *) vop_defaultop }, { &vop_access_desc, (vop_t *) union_access }, + { &vop_aclcheck_desc, (vop_t *) union_aclcheck }, { &vop_advlock_desc, (vop_t *) union_advlock }, { &vop_bmap_desc, (vop_t *) vop_eopnotsupp }, { &vop_close_desc, (vop_t *) union_close }, + { &vop_closeextattr_desc, (vop_t *) union_closeextattr }, { &vop_create_desc, (vop_t *) union_create }, { &vop_createvobject_desc, (vop_t *) union_createvobject }, + { &vop_deleteextattr_desc, (vop_t *) union_deleteextattr }, { &vop_destroyvobject_desc, (vop_t *) union_destroyvobject }, { &vop_fsync_desc, (vop_t *) union_fsync }, { &vop_getattr_desc, (vop_t *) union_getattr }, + { &vop_getacl_desc, (vop_t *) union_getacl }, + { &vop_getextattr_desc, (vop_t *) union_getextattr }, { &vop_getvobject_desc, (vop_t *) union_getvobject }, { &vop_inactive_desc, (vop_t *) union_inactive }, { &vop_ioctl_desc, (vop_t *) union_ioctl }, { &vop_lease_desc, (vop_t *) union_lease }, { &vop_link_desc, (vop_t *) union_link }, + { &vop_listextattr_desc, (vop_t *) union_listextattr }, { &vop_lookup_desc, (vop_t *) union_lookup }, { &vop_mkdir_desc, (vop_t *) union_mkdir }, { &vop_mknod_desc, (vop_t *) union_mknod }, { &vop_open_desc, (vop_t *) union_open }, + { &vop_openextattr_desc, (vop_t *) union_openextattr }, { &vop_pathconf_desc, (vop_t *) union_pathconf }, { &vop_poll_desc, (vop_t *) union_poll }, { &vop_print_desc, (vop_t *) union_print }, @@ -1872,7 +2108,10 @@ static struct vnodeopv_entry_desc union_vnodeop_entries[] = { { &vop_rename_desc, (vop_t *) union_rename }, { &vop_revoke_desc, (vop_t *) union_revoke }, { &vop_rmdir_desc, (vop_t *) union_rmdir }, + { &vop_setacl_desc, (vop_t *) union_setacl }, { &vop_setattr_desc, (vop_t *) union_setattr }, + { &vop_setextattr_desc, (vop_t *) union_setextattr }, + { &vop_setlabel_desc, (vop_t *) union_setlabel }, { &vop_strategy_desc, (vop_t *) union_strategy }, { &vop_symlink_desc, (vop_t *) union_symlink }, { &vop_whiteout_desc, (vop_t *) union_whiteout },