PERFORCE change 105229 for review
Adam Martin
adamartin at FreeBSD.org
Mon Aug 28 17:44:08 UTC 2006
http://perforce.freebsd.org/chv.cgi?CH=105229
Change 105229 by adamartin at 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 <machine/setjmp.h>
#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 <fs/pseudofs/pseudofs.h>
+#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 <sys/param.h>
+#include <sys/libkern.h>
+
#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 ***/
More information about the p4-projects
mailing list