PERFORCE change 109903 for review
Adam Martin
adamartin at FreeBSD.org
Tue Nov 14 04:33:20 UTC 2006
http://perforce.freebsd.org/chv.cgi?CH=109903
Change 109903 by adamartin at adamartin_hobbes on 2006/11/14 04:32:27
Autofs filesystem (on top of pseudofs) now can access the device it
is mounted from, and will pick up the message buffers for user-kernel
IO. Lookup operation converted to use mbufs for queue control, not
UIOVEC.
Affected files ...
.. //depot/projects/soc2006/adamartin_autofs/autofs/Makefile#5 edit
.. //depot/projects/soc2006/adamartin_autofs/autofs/autofs.c#6 edit
.. //depot/projects/soc2006/adamartin_autofs/autofs/autofs.h#6 edit
.. //depot/projects/soc2006/adamartin_autofs/autofs/autofs_ctl.c#5 edit
.. //depot/projects/soc2006/adamartin_autofs/autofs/autofs_ctl.h#4 edit
.. //depot/projects/soc2006/adamartin_autofs/autofs/autofs_dev.c#5 edit
.. //depot/projects/soc2006/adamartin_autofs/autofs/autofs_dev.h#3 edit
.. //depot/projects/soc2006/adamartin_autofs/autofs/autofs_pfsops.c#5 edit
.. //depot/projects/soc2006/adamartin_autofs/autofs/autofs_subr.c#2 edit
.. //depot/projects/soc2006/adamartin_autofs/autofs/autofs_subr.h#2 edit
.. //depot/projects/soc2006/adamartin_autofs/autofs/cleanup.h#6 edit
.. //depot/projects/soc2006/adamartin_autofs/autofs/debug.h#1 add
.. //depot/projects/soc2006/adamartin_autofs/autofs/protocol.c#5 edit
.. //depot/projects/soc2006/adamartin_autofs/autofs/protocol.h#5 edit
.. //depot/projects/soc2006/adamartin_autofs/pseudofs/pseudofs.h#3 edit
Differences ...
==== //depot/projects/soc2006/adamartin_autofs/autofs/Makefile#5 (text+ko) ====
@@ -28,9 +28,9 @@
AUTOFS_DEV_SOURCE=autofs_ctl.c autofs_dev.c
AUTOFS_FS_SOURCE=autofs_pfsops.c vnode_if.h
-AUTOFS_CORE_SOURCE=autofs.c protocol.c
+AUTOFS_CORE_SOURCE=autofs.c protocol.c autofs_subr.c
SRCS=$(AUTOFS_CORE_SOURCE) $(AUTOFS_FS_SOURCE) $(AUTOFS_DEV_SOURCE)
-HEADERS=autofs.h cleanup.h protocol.h
+HEADERS=autofs.h cleanup.h protocol.h autofs_subr.h autofs_ctl.h autofs_dev.h debug.h
KMOD=autofs
autofs.c: $(HEADERS)
==== //depot/projects/soc2006/adamartin_autofs/autofs/autofs.c#6 (text+ko) ====
@@ -40,8 +40,8 @@
#include <sys/uio.h>
#include <sys/malloc.h>
-#include <machine/setjmp.h>
-#include "cleanup.h"
+//#include <machine/setjmp.h>
+//#include "cleanup.h"
#include <sys/param.h>
#include <sys/vnode.h>
==== //depot/projects/soc2006/adamartin_autofs/autofs/autofs.h#6 (text+ko) ====
@@ -30,10 +30,14 @@
#ifndef __AUTOFS_MAIN_HEADER__
#define __AUTOFS_MAIN_HEADER__
+#define FREEBSD_SYS
+#if 0
#define USE_SETJMP_CLEANUP
#define NO_USE_SETJMP_INCLUDE
#define NO_CLEANUP_WARNING
-#define FREEBSD_SYS
+#include <machine/setjmp.h>
+#endif
+
#include "cleanup.h"
==== //depot/projects/soc2006/adamartin_autofs/autofs/autofs_ctl.c#5 (text+ko) ====
@@ -40,17 +40,21 @@
#include <sys/lock.h>
#include <sys/mutex.h>
+//#include <machine/setjmp.h>
+//#include "cleanup.h">
#include "autofs.h"
#include "autofs_ctl.h"
-#include "cleanup.h"
+#include "autofs_dev.h"
+#include "autofs_subr.h"
+#include "debug.h"
struct cdev *autofs_ctl_dev;
struct autofs_ctl_state autofs_ctl_state;
static d_ioctl_t autofs_ctl_ioctl;
-static struct cdevsw autofs_ctl_devops = {
+struct cdevsw autofs_ctl_devops = {
.d_version= D_VERSION,
.d_open= NULL,
.d_close= NULL,
@@ -63,7 +67,9 @@
int
autofs_ctl_init()
{
- DEBUG KPRINTF( "Initializing " )
+ DEBUG KPRINTF( "Initializing " );
+
+ return 0;
}
MALLOC_DECLARE( M_AUTOFS_DEV );
@@ -77,14 +83,16 @@
int error;
struct cdevsw *autofs_cdevsw;
struct cdev *autofs_cdev;
- struct autofs_dev_data *autofs_dev_data;
+ struct autofs_dev_bufs *autofs_dev_data;
+
+ error= 0;
autofs_cdevsw= malloc( sizeof( struct cdevsw ), M_AUTOFS_DEV, M_WAITOK );
- autofs_dev_data= malloc( sizeof( struct autofs_dev_data ), M_AUTOFS_DEV_BUFFERS,
+ autofs_dev_data= malloc( sizeof( struct autofs_dev_bufs ), M_AUTOFS_DEV_BUFFERS,
M_WAITOK );
- autofs_dev_data.input= malloc( IOV_BUF_COUNT * sizeof( struct iovec * ), M_AUTOFS_DEV_BUFFERS, M_WAITOK );
- autofs_dev_data.output= malloc( IOV_BUF_COUNT * sizeof( struct iovec * ), M_AUTOFS_DEV_BUFFERS, M_WAITOK );
+ autofs_dev_data->input= autofs_queue_init();
+ autofs_dev_data->output= autofs_queue_init();
autofs_cdevsw->d_open= autofs_dev_open;
autofs_cdevsw->d_close= autofs_dev_close;
@@ -101,7 +109,7 @@
}
autofs_cdev->si_priv= (struct cdev_priv *) autofs_dev_data;
- return 0;
+ return error;
}
@@ -123,14 +131,17 @@
{
$cleanup_init_size( 8 );
int error= 0;
- int *arg= (int *) arg_c;
+ int *argp= (int *) arg_c;
+ int arg;
+
+ argp= NULL;
error= EOPNOTSUPP;
- arg= NULL;
- $return EOPNOTSUPP;
+ //$return EOPNOTSUPP;
#if 1
- switch( cmd ) {
+ switch( cmd )
+ {
case AFSIOCREATDEV:
/* mtx_lock(&autofs_ctl_state.lock);
@@ -153,6 +164,7 @@
* a bad IOCTL code...
*/
error= EIO;
+ }
#endif
return error;
==== //depot/projects/soc2006/adamartin_autofs/autofs/autofs_ctl.h#4 (text+ko) ====
@@ -31,6 +31,7 @@
#define __AUTOFS_CTL_H__
#include "autofs.h"
+#include "autofs_subr.h"
#include <sys/types.h>
#include <sys/module.h>
#include <sys/systm.h> /* uprintf */
@@ -66,6 +67,7 @@
extern struct autofs_ctl_state autofs_ctl_state;
extern int autofs_ctl_init( void );
+int create_autofs_node( int num );
#define MAX_NODE_COUNT ( 32 )
@@ -74,9 +76,9 @@
-struct autofs_dev_data {
- struct uio input;
- struct uio output
+struct autofs_dev_bufs {
+ queue *input;
+ queue *output;
};
@@ -85,4 +87,10 @@
#define AFSIOCREATDEV _IOR('a', 1, _int_p) /* 1 - create autofs node */
+#define AUTOFS_GET_BUFFERS( p_info )\
+ ( (struct autofs_dev_bufs *) ( AUTOFS_GET_DEV( ( p_info ) )->si_priv ) )
+
+#define AUTOFS_GET_DEV( p_info )\
+ ( (struct cdev *) ( ( p_info )->pi_priv ) )
+
#endif /** __AUTOFS_CTL_H__ **/
==== //depot/projects/soc2006/adamartin_autofs/autofs/autofs_dev.c#5 (text+ko) ====
@@ -48,24 +48,15 @@
struct uio *in_buffer, *out_buffer;
int
-write_buffer( struct uio *buf, void *data, int len )
+write_buffer( queue *q, void *data, int len )
{
$cleanup_init_size( 8 );
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++;
- parse_messages();
- }
- else
- {
- error= ENOMEM;
- }
+ autofs_queue_write( q, data, len );
+ //parse_user_message();
$return error;
}
@@ -75,4 +66,8 @@
{
int error;
int i;
+ error= 0;
+ i= minor( dev );
+
+ return error;
}
==== //depot/projects/soc2006/adamartin_autofs/autofs/autofs_dev.h#3 (text+ko) ====
@@ -4,9 +4,9 @@
#define IOV_BUF_COUNT ( 16 )
-extern struct uio *in_buffer, *out_buffer;
+//extern struct uio *in_buffer, *out_buffer;
-int write_buffer( struct uio *buf, void *data, int len );
+int write_buffer( queue *q, void *data, int len );
int autofs_dev_open( struct cdev *dev, int oflags, int devtype, struct thread *td );
==== //depot/projects/soc2006/adamartin_autofs/autofs/autofs_pfsops.c#5 (text+ko) ====
@@ -38,6 +38,7 @@
#include <sys/namei.h>
#include <sys/proc.h>
#include <sys/kernel.h>
+#include <sys/pcpu.h>
#include <sys/vnode.h>
#include <sys/mount.h>
#include <sys/bio.h>
@@ -57,6 +58,7 @@
#include "protocol.h"
#include "debug.h"
+#include "autofs_ctl.h"
MALLOC_DEFINE(M_AUTOFS_MOUNTBUF, "AutoFS mntbuf", "AutoFS mountpoint data, to simulate filesystem contents.");
@@ -83,12 +85,15 @@
struct componentname c= *cnp;
struct message_header msg;
struct mount_request mr;
+ struct pfs_info *pi;
+
- KPRINTF( "autofs lookup called\n" );
-
- DEBUG KPRINTF( "cn_nameptr= %s, cn_pnbuf= %s\n", c.cn_nameptr,
+ pi= pn->pn_info;
+
+ DEBUG1 KPRINTF( "autofs lookup called\n" );
+ DEBUG7 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,
+ DEBUG7 KPRINTF( "cn_namelen= %ld, cn_consume= %ld\n", c.cn_namelen,
c.cn_consume );
/* Prepare a mount message */
@@ -103,10 +108,10 @@
/* Take a lock and if it's not taken yet fire off the request. */
- if( take_autofs_lock( instance, node ) )
- {
- send_mount_request( &msg );
- }
+ //if( take_autofs_lock( instance, node ) )
+ //{
+ send_mount_request( &msg, AUTOFS_GET_BUFFERS( pi )->output );
+ //}
return 1;
}
@@ -114,6 +119,41 @@
static int
autofs_init(struct pfs_info *pi, struct vfsconf *vfc)
{
+ struct vnode *devvp;
+ struct cdev *dev;
+ struct nameidata nd, *ndp= &nd;
+ struct thread *td;
+ int error;
+
+ td= curthread;
+
+
+ /** Get the fake device vnode from name **/
+
+ NDINIT( ndp, LOOKUP, FOLLOW | LOCKLEAF, UIO_SYSSPACE, pi->pi_name, td );
+ if( ( error= namei( ndp ) ) != 0 )
+ {
+ return error;
+ }
+ NDFREE( ndp, NDF_ONLY_PNBUF );
+ devvp= ndp->ni_vp;
+
+ /** Verify that the vnode is a device **/
+ if( devvp->v_type != VCHR )
+ {
+ panic( "Can't mount from non-char device for Autofs!\n" );
+ }
+
+ /* Get out the cdev object, and store in the private field for the
+ pfs_info object (I think we need to release the vnode too!)*/
+
+ dev= devvp->v_rdev;
+ pi->pi_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;
return 0;
==== //depot/projects/soc2006/adamartin_autofs/autofs/autofs_subr.c#2 (text+ko) ====
==== //depot/projects/soc2006/adamartin_autofs/autofs/autofs_subr.h#2 (text+ko) ====
@@ -1,4 +1,9 @@
+#ifndef _AUTOFS_SUBR_H_
+#define _AUTOFS_SUBR_H_
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/mbuf.h>
typedef struct mbuf queue;
@@ -8,8 +13,9 @@
int autofs_queue_write( queue *q, void *buf, int len );
-int autofs_queue_read( queue *q, void *q, int len ); /* Removes from head */
+int autofs_queue_read( queue *q, void *buf, int len ); /* Removes from head */
+#endif /*** _AUTOFS_SUBR_H_ ***/
==== //depot/projects/soc2006/adamartin_autofs/autofs/cleanup.h#6 (text+ko) ====
@@ -86,11 +86,12 @@
#define __CLEANUP_STACK_MAX__ ( 64 )
+typedef void *___generic___;
+
#if defined( __GNUC__ ) && !defined( USE_SETJMP_CLEANUP )
typedef void (*__cleanup_ptr)( void );
-typedef void *___generic___;
#define __VOLATILE_IMPLEMENTATION__ /** No volatile for nested functions **/
==== //depot/projects/soc2006/adamartin_autofs/autofs/protocol.c#5 (text+ko) ====
@@ -32,13 +32,15 @@
#include "protocol.h"
#include "autofs.h"
+#include "autofs_ctl.h"
+#include "autofs_subr.h"
#include "autofs_dev.h"
int
-send_mount_request(struct message_header *req)
+send_mount_request( struct message_header *req, queue *out_buffer )
{
struct mount_request *mb= (struct mount_request *) req->message_data;
@@ -47,7 +49,7 @@
write_buffer( out_buffer, (void *) mb,
sizeof( struct mount_request ) );
write_buffer( out_buffer, (void *) mb->mountpoint,
- MIN( strlen( mb->mountpoint ), mb->mountpoint_len ) );
+ mb->mountpoint_len );
return 0;
==== //depot/projects/soc2006/adamartin_autofs/autofs/protocol.h#5 (text+ko) ====
@@ -222,8 +222,10 @@
};
-int send_mount_request(struct message_header *req);
+#include "autofs_subr.h"
+
+int send_mount_request( struct message_header *req, queue *q );
-int parse_user_message();
+int parse_user_message( void );
#endif /*** AUTOFS_PROTOCOL_HEADER ***/
==== //depot/projects/soc2006/adamartin_autofs/pseudofs/pseudofs.h#3 (text+ko) ====
@@ -176,6 +176,7 @@
/* currently, the mutex is only used to protect the bitmap */
struct mtx pi_mutex;
struct unrhdr *pi_unrhdr;
+ void *pi_priv;
};
/*
More information about the p4-projects
mailing list