From owner-p4-projects@FreeBSD.ORG Fri Aug 18 00:12:56 2006 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id A7C3416A4E6; Fri, 18 Aug 2006 00:12:56 +0000 (UTC) X-Original-To: perforce@FreeBSD.org Delivered-To: perforce@FreeBSD.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 6E0C816A4DE for ; Fri, 18 Aug 2006 00:12:56 +0000 (UTC) (envelope-from adamartin@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 2382343D46 for ; Fri, 18 Aug 2006 00:12:56 +0000 (GMT) (envelope-from adamartin@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.6/8.13.6) with ESMTP id k7I0CuSu012057 for ; Fri, 18 Aug 2006 00:12:56 GMT (envelope-from adamartin@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.6/8.13.4/Submit) id k7I0Ctkn012054 for perforce@freebsd.org; Fri, 18 Aug 2006 00:12:55 GMT (envelope-from adamartin@FreeBSD.org) Date: Fri, 18 Aug 2006 00:12:55 GMT Message-Id: <200608180012.k7I0Ctkn012054@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to adamartin@FreeBSD.org using -f From: Adam Martin To: Perforce Change Reviews Cc: Subject: PERFORCE change 104455 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Aug 2006 00:12:56 -0000 http://perforce.freebsd.org/chv.cgi?CH=104455 Change 104455 by adamartin@adamartin_hobbes on 2006/08/18 00:12:18 Moved to Pseudofs for basis of autofs core. Autofs_ctl device has ioctl implemented partially for creation of new autofs devices. Affected files ... .. //depot/projects/soc2006/adamartin_autofs/autofs/Makefile#3 edit .. //depot/projects/soc2006/adamartin_autofs/autofs/autofs.c#3 edit .. //depot/projects/soc2006/adamartin_autofs/autofs/autofs.h#3 edit .. //depot/projects/soc2006/adamartin_autofs/autofs/autofs_ctl.c#2 edit .. //depot/projects/soc2006/adamartin_autofs/autofs/autofs_pfsops.c#1 add .. //depot/projects/soc2006/adamartin_autofs/autofs/autofs_vfsops.c#3 edit .. //depot/projects/soc2006/adamartin_autofs/autofs/cleanup.h#3 edit .. //depot/projects/soc2006/adamartin_autofs/autofs/protocol.c#2 edit .. //depot/projects/soc2006/adamartin_autofs/autofs/protocol.h#2 edit Differences ... ==== //depot/projects/soc2006/adamartin_autofs/autofs/Makefile#3 (text+ko) ==== @@ -27,7 +27,7 @@ AUTOFS_DEV_SOURCE=autofs_ctl.c autofs_dev.c -AUTOFS_FS_SOURCE=autofs_vnops.c autofs_vfsops.c vnode_if.h +AUTOFS_FS_SOURCE=autofs_pfsops.c vnode_if.h AUTOFS_CORE_SOURCE=autofs.c protocol.c SRCS=$(AUTOFS_CORE_SOURCE) $(AUTOFS_FS_SOURCE) $(AUTOFS_DEV_SOURCE) HEADERS=autofs.h cleanup.h protocol.h ==== //depot/projects/soc2006/adamartin_autofs/autofs/autofs.c#3 (text+ko) ==== @@ -29,7 +29,6 @@ -#include #include #include @@ -48,23 +47,17 @@ #include -#define AUTOFS_CTL_DEV_NAME "autofs_ctl" +#include "autofs.h" +#include "autofs_ctl.h" + + -static struct cdevsw autofs_ctl_devops = { - .d_version= D_VERSION, - .d_open= NULL, - .d_close= NULL, - .d_read= NULL, - .d_write= NULL, - .d_name= AUTOFS_CTL_DEV_NAME, -}; /** There's no more block devices, so all are cdevs, as c represents char in cdev **/ -static struct cdev *autofs_ctl_dev; @@ -72,17 +65,21 @@ autofs_handle_loader( struct module *mod, int action, void *args ) { int err= 0; - switch( action ) - { + switch (action) { case MOD_LOAD: - KPRINTF( "Now loading AutoFS module: \n" ); - autofs_ctl_dev= make_dev( &autofs_ctl_devops, + KPRINTF("Now loading AutoFS module: \n"); + autofs_ctl_dev = make_dev(&autofs_ctl_devops, 00, UID_ROOT, GID_WHEEL, 0600, - AUTOFS_CTL_DEV_NAME ); - KPRINTF( "AutoFS module successfully loaded.\n" ); + AUTOFS_CTL_DEV_NAME); + DEBUG KPRINTF("."); + autofs_ctl_state = (struct autofs_ctl_state) + malloc( + sizeof(struct autofs_ctl_state), + M_AUTOFS_CTL_NODES, M_WAITOK); + KPRINTF("AutoFS module successfully loaded.\n"); break; case MOD_QUIESCE: @@ -96,6 +93,7 @@ case MOD_UNLOAD: destroy_dev( autofs_ctl_dev ); + free(autofs_ctl_state, M_AUTOFS_CTL_NODES); KPRINTF( "AutoFS unloaded.\n" ); break; @@ -112,6 +110,9 @@ } + +int vn_iscdev(struct vnode *vp, int *errp); + int vn_iscdev(struct vnode *vp, int *errp) { ==== //depot/projects/soc2006/adamartin_autofs/autofs/autofs.h#3 (text+ko) ==== @@ -31,6 +31,9 @@ #define __AUTOFS_MAIN_HEADER__ +#define AUTOFS_VERSION ( 1 ) + + //#define USE_SETJMP_CLEANUP //#define NO_USE_SETJMP_INCLUDE //#define NO_CLEANUP_WARNING @@ -50,7 +53,7 @@ #define DEBUG_L( level ) if( DEBUG_LEVEL >= level ) -#define DEBUG DEBUG8 +#define DEBUG DEBUG5 #define DEBUG1 DEBUG_L( 1 ) #define DEBUG2 DEBUG_L( 2 ) @@ -63,38 +66,16 @@ -#define STOR_NAME_MAX 64 - #define MNT_TARGET ( "fspath" ) #define MNT_DEVICE ( "from" ) -typedef struct _autofs_storage_unit { - char name [ STOR_NAME_MAX ]; - struct _autofs_storage_unit *next; -} autofs_storage_unit; - - -struct autofs_mount { - struct autofs_ctrl *ctrl; - autofs_storage_unit contents; - struct vnode *afsm_devvp; - struct cdev *ctrl_dev; -}; - #define entity( member, value )\ .member = value -#define VFSTOAUTOFS(mp) ((struct autofs_mount *)((mp)->mnt_data)) - - -int vn_iscdev( struct vnode *vp, int *errp ); - -//extern struct vop_vector autofs_vnodeops; - #endif /*** __AUTOFS_MAIN_HEADER__ ***/ ==== //depot/projects/soc2006/adamartin_autofs/autofs/autofs_ctl.c#2 (text+ko) ==== @@ -27,4 +27,82 @@ * */ +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + + +#include "autofs.h" +#include "autofs_ctl.h" +#include "cleanup.h" + +struct cdev *autofs_ctl_dev; + +static d_ioctl_t autofs_ctl_ioctl; + +struct cdevsw autofs_ctl_devops = { + .d_version= D_VERSION, + .d_open= NULL, + .d_close= NULL, + .d_read= NULL, + .d_write= NULL, + .d_name= AUTOFS_CTL_DEV_NAME, + .d_ioctl= autofs_ctl_ioctl, +}; + + + +struct autofs_ctl_state autofs_ctl_state; +/* + * We only handle the IOCTLS for create and destroy autofs_dev instances. + * Autofs devs are addressed by number. Creation always assigns a new, + * per-mount unique number. (This number can be recycled, if it's freed + * by delete.) + * + * Autofs_ctl will return the assigned number, via the ioctl arg 1 + * value, unless an error occurs. + */ + + +static int +autofs_ctl_ioctl(struct cdev *i_dev, u_long cmd, caddr_t arg_c, int mode, + struct thread *td) +{ + $cleanup_init_size( 8 ); + int error= 0; + int *arg= (int *) arg_c; + + switch( cmd ) { + case AFSIOCREATDEV: + mtx_lock(&autofs_ctl_state.lock); + $cleanup( + mtx_unlock(&autofs_ctl_state.lock); + ) + + arg= autofs_ctl_state.next_assignable_node++; + error= create_autofs_node(arg); + + $do_cleanup; + + break; + + default: + /* NOTREACHED */ + + /* + * In theory, but could be reached when someone sends + * a bad IOCTL code... + */ + error= EIO; + +} ==== //depot/projects/soc2006/adamartin_autofs/autofs/autofs_vfsops.c#3 (text+ko) ==== @@ -54,7 +54,15 @@ #include "cleanup.h" +static vfs_mount_t autofs_mount; +static vfs_root_t autofs_root; +static vfs_unmount_t autofs_unmount; +static struct vfsops autofs_vfsops = { + entity(vfs_mount, autofs_mount), + entity(vfs_unmount, autofs_unmount), + entity(vfs_root, autofs_root), +}; MALLOC_DEFINE(M_AUTOFS_MOUNTBUF, "AutoFS mntbuf", "AutoFS mountpoint data, to simulate filesystem contents."); @@ -68,6 +76,8 @@ struct vnode *devvp; struct autofs_mount *a_mnt; + struct vnode *root_vp; + struct nameidata ndp; /* Mount point path and length */ @@ -139,12 +149,17 @@ vfs_mountedfrom(mp, "autofs"); DEBUG KPRINTF("Done\n"); + DEBUG KPRINTF("Setting up root vnode pointer..."); + error = autofs_allocvp( + //DEBUG $return (EOPNOTSUPP); $cleanup( DEBUG KPRINTF("Mount done -- error = %d...\n", error); ); + + DEBUG KPRINTF("Leaving mount, invoking cleanups -- error = %d...\n", error); $return (error); @@ -170,9 +185,16 @@ $return (error); } -static struct vfsops autofs_vfsops = { - entity(vfs_mount, autofs_mount), - entity(vfs_unmount, autofs_unmount), -}; +static int +autofs_root(struct mount *mp, int flags, struct vnode **vpp, struct thread *td) +{ + struct vnode *vp; + vp= VFSTOAUTOFS(mp)->root_vnode; + VREF(vp); + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); + + *vpp= vp; + return 0; +} VFS_SET(autofs_vfsops, autofs, 0); ==== //depot/projects/soc2006/adamartin_autofs/autofs/cleanup.h#3 (text+ko) ==== @@ -198,6 +198,8 @@ #define $cleanup_init_size( a ) CLEANUP_STACK_SIZE( a ) #define $cleanup( a ) REGISTER_ACTION( a ) +#define $do_cleanup CLEANUP_RESOURCES + #define $return leave #define $cleanup_local GET_LOCAL() ==== //depot/projects/soc2006/adamartin_autofs/autofs/protocol.c#2 (text+ko) ==== @@ -26,3 +26,5 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ + +#include "protocol.h" ==== //depot/projects/soc2006/adamartin_autofs/autofs/protocol.h#2 (text+ko) ==== @@ -25,9 +25,13 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - */#ifndef AUTOFS_PROTOCOL_HEADER + */ + +#ifndef AUTOFS_PROTOCOL_HEADER #define AUTOFS_PROTOCOL_HEADER +#include + /* * The protocol between AutoFS and Automounter consists of these data types, * strung together, as explained below. @@ -45,7 +49,7 @@ the message pertains to. */ uint32_t message_type; /* Used to identify which command is issued in this packet. COMMAND_* constants are used to fill these */ - void message_data[]; /* The rest of the message data, as an + char message_data[]; /* The rest of the message data, as an indeterminate length. */ }; @@ -213,7 +217,7 @@ struct modify_mounts_acknowledge { uint32_t n_mounts; /* Number of entries that are in response */ - struct managed_mounts mounts[]; /* The mount entries, and correspondant + struct managed_mount mounts[]; /* The mount entries, and correspondant status of action */ };