[prev in list] [next in list] [prev in thread] [next in thread] 

List:       lustre-cvs
Subject:    [Lustre-cvs] CVS: obd/llight Makefile.am,NONE,1.1 request.c,NONE,1.1
From:       "Peter J. Braam" <braam () users ! sourceforge ! net>
Date:       2001-12-30 6:43:08
[Download RAW message or body]

Update of /cvsroot/lustre/obd/llight
In directory usw-pr-cvs1:/tmp/cvs-serv13240/llight

Added Files:
	Makefile.am request.c 
Log Message:
Lustre light client request module


--- NEW FILE ---
# Copyright (C) 2001  Cluster File Systems, Inc.
#
# This code is issued under the GNU General Public License.
# See the file COPYING in this distribution

MODULE = llight
modulefs_DATA = llight.o
EXTRA_PROGRAMS = llight


llight_SOURCES =  mds_pack.c request.c # super.c rw.c file.c dir.c sysctl.c super.c namei.c symlink.c

mds_pack.c: 
	ln -s ../lib/mds_pack.c .


include $(top_srcdir)/Rules

--- NEW FILE ---
/*
 * Copryright (C) 2001 Cluster File Systems, Inc.
 *
 */

#define EXPORT_SYMTAB

#include <linux/config.h>
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/mm.h>
#include <linux/string.h>
#include <linux/stat.h>
#include <linux/errno.h>
#include <linux/locks.h>
#include <linux/unistd.h>

#include <asm/system.h>
#include <asm/uaccess.h>

#include <linux/fs.h>
#include <linux/stat.h>
#include <asm/uaccess.h>
#include <linux/vmalloc.h>
#include <asm/segment.h>
#include <linux/miscdevice.h>

#include <linux/obd_support.h>
#include <linux/lustre_lib.h>
#include <linux/lustre_idl.h>
#include <linux/lustre_mds.h>

#define REQUEST_MINOR 244
extern int mds_queue_req(struct mds_request *);

int llight_getattr(ino_t ino, struct  mds_rep  *rep)
{
	struct mds_request *request;
	int rc; 

	request = (struct mds_request *)kmalloc(sizeof(*request), 
						GFP_KERNEL); 
	if (!request) { 
		printk("llight request: out of memory\n");
		return -ENOMEM;
	}

	rc = mds_pack_req(NULL, 0, NULL, 0, 
			  &request->rq_reqhdr, &request->rq_req, 
			  &request->rq_reqlen, &request->rq_reqbuf);
	if (rc) { 
		printk("llight request: cannot pack request %d\n", rc); 
		return rc;
	}
	request->rq_req->fid1.id = ino;

	request->rq_reqhdr->opc = MDS_GETATTR;
	
	rc = mds_queue_req(request);
	if (rc) { 
		printk("llight request: error in handling %d\n", rc); 
		return rc;
	}

	printk("mode: %o\n", request->rq_rep->mode); 
	if (rep) { 
		memcpy(rep, request->rq_repbuf, sizeof(*rep));
	}
	kfree(request->rq_repbuf);
	kfree(request);
	return 0;
}


static int request_ioctl(struct inode *inode, struct file *file, 
		       unsigned int cmd, unsigned long arg)
{
	int err;

	ENTRY;

	if (MINOR(inode->i_rdev) != REQUEST_MINOR) {
		EXIT;
		return -EINVAL;
	}

	if ( _IOC_TYPE(cmd) != IOC_REQUEST_TYPE || 
             _IOC_NR(cmd) < IOC_REQUEST_MIN_NR  || 
             _IOC_NR(cmd) > IOC_REQUEST_MAX_NR ) {
                CDEBUG(D_IOCTL, "invalid ioctl ( type %d, nr %d, size %d )\n",
                                _IOC_TYPE(cmd), _IOC_NR(cmd), _IOC_SIZE(cmd));
                EXIT;
                return -EINVAL;
        }

	
	switch (cmd) {
	case IOC_REQUEST_GETATTR: { 
		printk("-- getting attr for ino 2\n"); 
		err = llight_getattr(2, NULL);
		printk("-- done err %d\n", err);
		break;
	}
	default:		
		err = -EINVAL;
		EXIT;
		break;
	}
	EXIT;
	return err;
}


static struct file_operations requestdev_fops = {
	ioctl: request_ioctl,
};


static struct miscdevice request_dev = {
	REQUEST_MINOR,
	"request",
	&requestdev_fops
};


int init_request_module(void)
{
	misc_register( &request_dev );
        return 0 ;
}

#ifdef MODULE
MODULE_AUTHOR("Peter J. Braam <braam@clusterfs.com>");
MODULE_DESCRIPTION("Lustre MDS Request Tester v1.0");

#include <linux/module.h>

int init_module(void)
{
        return init_request_module();
}

void cleanup_module(void)
{
	misc_deregister(&request_dev);
	return;
}

#endif


_______________________________________________
Lustre-cvs mailing list
Lustre-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/lustre-cvs
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic