From owner-p4-projects@FreeBSD.ORG Mon Aug 28 17:44:08 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 61DD116A4E7; Mon, 28 Aug 2006 17:44:08 +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 064CE16A4E5 for ; Mon, 28 Aug 2006 17:44:08 +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 8974D43DB3 for ; Mon, 28 Aug 2006 17:42:42 +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 k7SHgWDm046618 for ; Mon, 28 Aug 2006 17:42:32 GMT (envelope-from adamartin@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.6/8.13.4/Submit) id k7SHgWeB046615 for perforce@freebsd.org; Mon, 28 Aug 2006 17:42:32 GMT (envelope-from adamartin@FreeBSD.org) Date: Mon, 28 Aug 2006 17:42:32 GMT Message-Id: <200608281742.k7SHgWeB046615@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 105229 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: Mon, 28 Aug 2006 17:44:08 -0000 http://perforce.freebsd.org/chv.cgi?CH=105229 Change 105229 by adamartin@adamartin_hobbes on 2006/08/28 17:42:22 Final changes for Google Summer of Code. I do plan to continue working on this, in the coming months. Pseudofs files need to be patched into /usr/src/sys/fs/pseudofs, to compile -- I had to add a hook for lookup() operations on pseudofs Affected files ... .. //depot/projects/soc2006/adamartin_autofs/autofs/autofs.c#4 edit .. //depot/projects/soc2006/adamartin_autofs/autofs/autofs.h#4 edit .. //depot/projects/soc2006/adamartin_autofs/autofs/autofs_ctl.c#3 edit .. //depot/projects/soc2006/adamartin_autofs/autofs/autofs_ctl.h#1 add .. //depot/projects/soc2006/adamartin_autofs/autofs/autofs_dev.c#2 edit .. //depot/projects/soc2006/adamartin_autofs/autofs/autofs_dev.h#1 add .. //depot/projects/soc2006/adamartin_autofs/autofs/autofs_pfsops.c#2 edit .. //depot/projects/soc2006/adamartin_autofs/autofs/autofs_vfsops.c#4 edit .. //depot/projects/soc2006/adamartin_autofs/autofs/autofs_vnops.c#3 edit .. //depot/projects/soc2006/adamartin_autofs/autofs/cleanup.h#4 edit .. //depot/projects/soc2006/adamartin_autofs/autofs/protocol.c#3 edit .. //depot/projects/soc2006/adamartin_autofs/autofs/protocol.h#3 edit .. //depot/projects/soc2006/adamartin_autofs/pseudofs/pseudofs.c#1 add .. //depot/projects/soc2006/adamartin_autofs/pseudofs/pseudofs.h#1 add .. //depot/projects/soc2006/adamartin_autofs/pseudofs/pseudofs_fileno.c#1 add .. //depot/projects/soc2006/adamartin_autofs/pseudofs/pseudofs_internal.h#1 add .. //depot/projects/soc2006/adamartin_autofs/pseudofs/pseudofs_vncache.c#1 add .. //depot/projects/soc2006/adamartin_autofs/pseudofs/pseudofs_vnops.c#1 add Differences ... ==== //depot/projects/soc2006/adamartin_autofs/autofs/autofs.c#4 (text+ko) ==== @@ -75,10 +75,8 @@ 0600, 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); + autofs_ctl_init(); + DEBUG KPRINTF("."); KPRINTF("AutoFS module successfully loaded.\n"); break; @@ -88,21 +86,22 @@ * Find out what we should do for QUIESCE option? * */ + KPRINTF("AutoFS quiesced.\n"); return 0; case MOD_UNLOAD: - destroy_dev( autofs_ctl_dev ); - free(autofs_ctl_state, M_AUTOFS_CTL_NODES); - KPRINTF( "AutoFS unloaded.\n" ); + destroy_dev(autofs_ctl_dev); + //free(autofs_ctl_state, M_AUTOFS_CTL_NODES); + KPRINTF("AutoFS unloaded.\n"); break; default: err= EINVAL; - KPRINTF( "Error -- action %d not supported!\n", - action ); - KPRINTF( "MOD_LOAD= %d, MOD_UNLOAD= %d\n", - MOD_LOAD, MOD_UNLOAD ); + KPRINTF("Error -- action %d not supported!\n", + action); + KPRINTF("MOD_LOAD= %d, MOD_UNLOAD= %d\n", + MOD_LOAD, MOD_UNLOAD); break; } ==== //depot/projects/soc2006/adamartin_autofs/autofs/autofs.h#4 (text+ko) ==== @@ -33,6 +33,8 @@ #define AUTOFS_VERSION ( 1 ) +//#define MIN( a, b ) ( ( a ) < ( b ) ? ( a ) : ( b ) ) +//#define MAX( a, b ) ( ( a ) > ( b ) ? ( a ) : ( b ) ) //#define USE_SETJMP_CLEANUP //#define NO_USE_SETJMP_INCLUDE ==== //depot/projects/soc2006/adamartin_autofs/autofs/autofs_ctl.c#3 (text+ko) ==== @@ -46,6 +46,7 @@ #include "cleanup.h" struct cdev *autofs_ctl_dev; +struct autofs_ctl_state autofs_ctl_state; static d_ioctl_t autofs_ctl_ioctl; @@ -59,9 +60,12 @@ .d_ioctl= autofs_ctl_ioctl, }; +int +autofs_ctl_init() +{ + DEBUG KPRINTF("Initializing " -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, @@ -81,6 +85,11 @@ int error= 0; int *arg= (int *) arg_c; + error= EOPNOTSUPP; + arg= NULL; + $return EOPNOTSUPP; + + #if 0 switch( cmd ) { case AFSIOCREATDEV: @@ -105,4 +114,5 @@ */ error= EIO; + #endif } ==== //depot/projects/soc2006/adamartin_autofs/autofs/autofs_dev.c#2 (text+ko) ==== @@ -41,8 +41,25 @@ #include #include "cleanup.h" +#include "autofs_dev.h" +struct uio *in_buffer, *out_buffer; +#define IOV_BUF_COUNT (16) +int +write_buffer(struct uio *buf, void *data, int len) +{ + int error; + error = 0; + if (buf->uio_iovcnt < IOV_BUF_COUNT) { + buf->uio_iov[ buf->uio_iovcnt ].iov_base= data; + buf->uio_iov[ buf->uio_iovcnt ].iov_len= len; + buf->uio_iovcnt++; + } else + error = ENOMEM; + + return error; +} ==== //depot/projects/soc2006/adamartin_autofs/autofs/autofs_pfsops.c#2 (text+ko) ==== @@ -55,12 +55,60 @@ #include +#include "protocol.h" + MALLOC_DEFINE(M_AUTOFS_MOUNTBUF, "AutoFS mntbuf", "AutoFS mountpoint data, to simulate filesystem contents."); +struct pfs_node *foo; + +static int +autofs_vis(PFS_VIS_ARGS) +{ + KPRINTF( "autofs visibility called\n" ); + return 0; +} + +static int +autofs_attr(PFS_ATTR_ARGS) +{ + KPRINTF( "autofs attr called\n" ); + return 0; +} + +static int +autofs_lookup(PFS_LOOKUP_ARGS) +{ + struct componentname c= *cnp; + struct message_header msg; + struct mount_request mr; + + KPRINTF( "autofs lookup called\n" ); + + DEBUG KPRINTF( "cn_nameptr= %s, cn_pnbuf= %s\n", c.cn_nameptr, + c.cn_pnbuf ); + DEBUG KPRINTF( "cn_namelen= %ld, cn_consume= %ld\n", c.cn_namelen, + c.cn_consume ); + + msg.flags= 0; + msg.transaction_id= 0; + msg.message_type= COMMAND_MOUNT_REQUEST; + msg.message_data= (char *) &mr; + + mr.action= ACTION_MOUNT; + mr.mountpoint_len= c.cn_namelen; + strlcpy( mr.mountpoint, c.cn_nameptr, c.cn_namelen ); + + send_mount_request( &msg ); + + return 1; +} + static int autofs_init(struct pfs_info *pi, struct vfsconf *vfc) { + foo= pfs_create_dir( pi->pi_root, "foo", autofs_attr, autofs_vis, 0 ); + foo->pn_lookup= autofs_lookup; return 0; } ==== //depot/projects/soc2006/adamartin_autofs/autofs/autofs_vfsops.c#4 (text+ko) ==== ==== //depot/projects/soc2006/adamartin_autofs/autofs/autofs_vnops.c#3 (text+ko) ==== ==== //depot/projects/soc2006/adamartin_autofs/autofs/cleanup.h#4 (text+ko) ==== ==== //depot/projects/soc2006/adamartin_autofs/autofs/protocol.c#3 (text+ko) ==== @@ -27,4 +27,29 @@ * */ +#include +#include + #include "protocol.h" +#include "autofs.h" +#include "autofs_dev.h" + + + + +int +send_mount_request(struct message_header *req) +{ + struct mount_request *mb= (struct mount_request *) req->message_data; + + write_buffer( out_buffer, (void *) req, + sizeof( struct message_header ) ); + write_buffer( out_buffer, (void *) mb, + sizeof( struct mount_request ) ); + write_buffer( out_buffer, (void *) mb->mountpoint, + MIN( strlen( mb->mountpoint ), mb->mountpoint_len ) ); + + + return 0; +} + ==== //depot/projects/soc2006/adamartin_autofs/autofs/protocol.h#3 (text+ko) ==== @@ -49,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 */ - char message_data[]; /* The rest of the message data, as an + void *message_data; /* The rest of the message data, as an indeterminate length. */ }; @@ -221,4 +221,7 @@ status of action */ }; + +int send_mount_request(struct message_header *req); + #endif /*** AUTOFS_PROTOCOL_HEADER ***/