Date: Thu, 11 Jan 2007 00:58:25 GMT From: Adam Martin <adamartin@FreeBSD.org> To: Perforce Change Reviews <perforce@FreeBSD.org> Subject: PERFORCE change 112747 for review Message-ID: <200701110058.l0B0wPVi009788@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=112747 Change 112747 by adamartin@adamartin_hobbes on 2007/01/11 00:57:34 Autofs working on templatefs now. Need to make templatefs non-static in creation time now. Affected files ... .. //depot/projects/soc2006/adamartin_autofs/autofs/Makefile#7 edit .. //depot/projects/soc2006/adamartin_autofs/autofs/autofs.c#9 edit .. //depot/projects/soc2006/adamartin_autofs/autofs/autofs_tfsops.c#2 edit .. //depot/projects/soc2006/adamartin_autofs/autofs/autofs_types.h#3 edit .. //depot/projects/soc2006/adamartin_autofs/templatefs/templatefs.c#2 edit Differences ... ==== //depot/projects/soc2006/adamartin_autofs/autofs/Makefile#7 (text+ko) ==== @@ -27,7 +27,7 @@ AUTOFS_DEV_SOURCE=autofs_ctl.c autofs_dev.c -AUTOFS_FS_SOURCE=autofs_pfsops.c vnode_if.h +AUTOFS_FS_SOURCE=autofs_tfsops.c vnode_if.h AUTOFS_CORE_SOURCE=autofs.c protocol.c AUTOFS_SUPPORT_SOURCE=autofs_subr.c SRCS=$(AUTOFS_CORE_SOURCE) $(AUTOFS_FS_SOURCE) $(AUTOFS_DEV_SOURCE) $(AUTOFS_SUPPORT_SOURCE) ==== //depot/projects/soc2006/adamartin_autofs/autofs/autofs.c#9 (text+ko) ==== @@ -111,7 +111,7 @@ -#if 0 +#if NEVER_DEFINED static int vn_iscdev( struct vnode *vp, int *errp ) { @@ -146,3 +146,4 @@ DEV_MODULE( AutoFS, autofs_handle_loader, NULL ); +MODULE_DEPEND( AutoFS, templatefs, 1, 1, 1 ); ==== //depot/projects/soc2006/adamartin_autofs/autofs/autofs_tfsops.c#2 (text+ko) ==== @@ -54,7 +54,7 @@ #include <machine/setjmp.h> #include "cleanup.h" -#include <fs/pseudofs/pseudofs.h> +#include "../templatefs/templatefs.h" #include <sys/time.h> @@ -67,17 +67,17 @@ MALLOC_DEFINE( M_AUTOFS_MOUNTBUF, "AutoFS mntbuf", "AutoFS mountpoint data, to simulate filesystem contents."); -struct pfs_node *foo; +struct tfs_node *foo; static int -autofs_vis(PFS_VIS_ARGS) +autofs_vis( TFS_VIS_ARGS ) { KPRINTF( "autofs visibility called\n" ); return 0; } static int -autofs_attr( PFS_ATTR_ARGS ) +autofs_attr( TFS_ATTR_ARGS ) { KPRINTF( "autofs attr called\n" ); return 0; @@ -100,18 +100,21 @@ static int -autofs_lookup( PFS_LOOKUP_ARGS ) +autofs_lookup( TFS_LOOKUP_ARGS ) { struct componentname c= *cnp; struct message_header msg; struct mount_request mr; - struct pfs_info *pi; - autofs_info_t *instance; + struct tfs_info *ti; + + autofs_instance_t *instance; + autofs_dev_bufs_t *buffers; - pi= pn->pn_info; + ti= tn->tn_info; - instance= AUTOFS_GET_PRIVATE( pi ); + instance= AUTOFS_GET_INSTANCE( NODE, tn ); + buffers= AUTOFS_GET_BUFFERS( NODE, tn ); DEBUG1 KPRINTF( "autofs lookup called\n" ); DEBUG7 KPRINTF( "cn_nameptr= %s, cn_pnbuf= %s\n", c.cn_nameptr, @@ -133,14 +136,60 @@ //if( take_autofs_lock( instance, node ) ) //{ - send_mount_request( &msg, instance->output ); + send_mount_request( &msg, buffers->output ); //} return 1; } + static int -autofs_init(struct pfs_info *pi, struct vfsconf *vfc) +autofs_mount_handler( TFS_MOUNT_HANDLER_ARGS ) +{ + struct vnode *devvp; + struct cdev *dev; + struct nameidata nd; + struct nameidata *ndp; + int error; + char *dev_name; + int dev_name_len; + struct vfsoptlist *opts; + + error= 0; + + ndp= &nd; + opts= mp->mnt_optnew; + + error= vfs_getopt( opts, MNT_DEVICE, (void **) &dev_name, + &dev_name_len ); + + if( !error && dev_name[ dev_name_len - 1 ] != '\0' ) + { + return ( EINVAL ); + } + + NDINIT( ndp, LOOKUP, FOLLOW | LOCKLEAF, UIO_SYSSPACE, dev_name, td ); + if( ( error= namei( ndp ) ) ) + { + return ( error ); + } + NDFREE( ndp, NDF_ONLY_PNBUF ); + devvp= ndp->ni_vp; + + /** Take the lock here, and get the struct cdev out of it, and use the + private data there, to assign the instance. **/ + + dev= devvp->v_rdev; + + /** Now we have the dev object. Work with it. **/ + + ti->ti_priv= (void *) AUTOFS_GET_INSTANCE( DEV, dev ); + + return error; +} + +static int +autofs_init(struct tfs_info *ti, struct vfsconf *vfc) { struct vnode *devvp; struct cdev *dev; @@ -153,7 +202,7 @@ /** Get the fake device vnode from name **/ - NDINIT( ndp, LOOKUP, FOLLOW | LOCKLEAF, UIO_SYSSPACE, pi->pi_name, td ); + NDINIT( ndp, LOOKUP, FOLLOW | LOCKLEAF, UIO_SYSSPACE, ti->ti_name, td ); if( ( error= namei( ndp ) ) != 0 ) { return error; @@ -171,23 +220,23 @@ pfs_info object (I think we need to release the vnode too!)*/ dev= devvp->v_rdev; - pi->pi_priv= (void *) dev; + ti->ti_priv= (void *) dev; VOP_UNLOCK( devvp, LK_RELEASE, td ); /** Make some fake files... **/ - foo= pfs_create_dir( pi->pi_root, "foo", autofs_attr, autofs_vis, 0 ); - foo->pn_lookup= autofs_lookup; + foo= tfs_create_dir( ti->ti_root, "foo", autofs_attr, autofs_vis, 0 ); + foo->tn_lookup= autofs_lookup; return 0; } static int -autofs_uninit(struct pfs_info *pi, struct vfsconf *vfc) +autofs_uninit(struct tfs_info *ti, struct vfsconf *vfc) { return 0; } -PSEUDOFS( autofs, AUTOFS_VERSION ); +TEMPLATEFS( autofs, AUTOFS_VERSION, autofs_mount_handler ); ==== //depot/projects/soc2006/adamartin_autofs/autofs/autofs_types.h#3 (text+ko) ==== @@ -8,7 +8,7 @@ /** Kernel forward definitions **/ struct vnode; -struct pfs_node; +struct tfs_node; struct proc; struct cdev; struct mbuf; @@ -111,9 +111,9 @@ DEV - the input/output device of the AutoFS system NODE - a node (mountpoint) within the AutoFS system INSTANCE - the instance descriptor of an AutoFS system - ROOT - the pfs_info (vfs_info) descriptor of the underlying pseudofs + ROOT - the tfs_info (vfs_info) descriptor of the underlying templatefs -E.G.: AUTOFS_GET_BUFFERS( ROOT, autofs_pfs_info ) +E.G.: AUTOFS_GET_BUFFERS( ROOT, autofs_tfs_info ) E.G.: AUTOFS_GET_TXNS( DEV, autofs_cdevsw ) one can get: @@ -142,10 +142,10 @@ ( ( dev )->si_priv ) #define AUTOFS_NODE_GET_INSTANCE( node )\ - ( ( node )->pn_priv ) + ( ( node )->tn_data ) -#define AUTOFS_ROOT_GET_INSTANCE( p_info )\ - ( ( p_info )->pi_priv ) +#define AUTOFS_ROOT_GET_INSTANCE( t_info )\ + ( ( t_info )->ti_priv ) #define AUTOFS_INSTANCE_GET_INSTANCE( instance )\ ( ( instance ) ) ==== //depot/projects/soc2006/adamartin_autofs/templatefs/templatefs.c#2 (text+ko) ==== @@ -360,6 +360,7 @@ /* * Initialize a (static) pseudofs instance + * ADAM -- if it's static, then this is bad... we need it at dynamic time. */ int tfs_init(struct tfs_info *ti, struct vfsconf *vfc) @@ -369,6 +370,7 @@ mtx_init(&ti->ti_mutex, "pseudofs", NULL, MTX_DEF); + /** TODO, should this be moved to mount? How much of it? **/ /* set up the root diretory */ MALLOC(root, struct tfs_node *, sizeof *root, M_TFSNODES, M_WAITOK|M_ZERO);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200701110058.l0B0wPVi009788>