* Copyright (c) 1999 Stelias Computing, Inc.
* (authors {pschwan,braam}@stelias.com)
* Copyright (C) 1999 Seagate Technology, Inc.
+ * Copyright (C) 2001 Cluster File Systems, Inc.
*
*
*/
#include <linux/kmod.h> /* for request_module() */
#include <linux/sched.h>
#include <linux/lp.h>
-#include <linux/malloc.h>
+#include <linux/slab.h>
#include <linux/ioport.h>
#include <linux/fcntl.h>
#include <linux/delay.h>
return 0;
}
-/* support function */
-static struct obd_type *obd_nm_to_type(char *nm)
+/*
+ * support functions: we could use inter-module communication, but this
+ * is more portable to other OS's
+ */
+static struct obd_type *obd_search_type(char *nm)
{
struct list_head *tmp;
struct obd_type *type;
return type;
}
}
- return NULL;
+ return NULL;
+}
+
+static struct obd_type *obd_nm_to_type(char *nm)
+{
+ struct obd_type *type = obd_search_type(nm);
+
+#ifdef CONFIG_KMOD
+ if ( !type ) {
+ if ( !request_module(nm) ) {
+ CDEBUG(D_PSDEV, "Loaded module '%s'\n", nm);
+ type = obd_search_type(nm);
+ } else {
+ CDEBUG(D_PSDEV, "Can't load module '%s'\n", nm);
+ }
+ }
+#endif
+ return type;
}
static int obd_devicename_from_path(obd_devicename* whoami,
- char* user_string)
+ uint32_t klen,
+ char* kname, char *user_path)
{
- struct nameidata nd;
- int err;
-
- err = user_path_walk(user_string, &nd);
- if (!err) {
- whoami->dentry = nd.dentry;
- path_release(&nd);
- }
- return err;
+ int err;
+ struct nameidata nd;
+ whoami->len = klen;
+ whoami->name = kname;
+
+#if (LINUX_VERSION_CODE <= 0x20403)
+
+ err = user_path_walk(user_path, &nd);
+ if (!err) {
+ CDEBUG(D_INFO, "found dentry for %s\n", kname);
+ whoami->dentry = nd.dentry;
+ path_release(&nd);
+ }
+ return err;
+#endif
+ return 0;
}
+
+
/* to control /dev/obdNNN */
static int obd_class_ioctl (struct inode * inode, struct file * filp,
unsigned int cmd, unsigned long arg)
/* find the type */
nm = input->att_type;
type = obd_nm_to_type(nm);
-#ifdef CONFIG_KMOD
- if ( !type ) {
- if ( !request_module(nm) ) {
- CDEBUG(D_PSDEV, "Loaded module '%s'\n", nm);
- type = obd_nm_to_type(nm);
- } else {
- CDEBUG(D_PSDEV, "Can't load module '%s'\n", nm);
- }
- }
-#endif
OBD_FREE(input->att_type, input->att_typelen + 1);
if ( !type ) {
case OBD_IOC_SETUP: {
struct ioc_setup {
int setup_datalen;
- char *setup_data;
+ void *setup_data;
} *setup;
+ char *user_path;
setup = tmp_buf;
EXIT;
return err;
}
-
+ user_path = setup->setup_data;
+
+ /* get the attach data */
+ err = getdata(setup->setup_datalen, &setup->setup_data);
+ if ( err ) {
+ EXIT;
+ return err;
+ }
+
err = obd_devicename_from_path(&(obddev->obd_fsname),
- (char*) setup->setup_data);
+ setup->setup_datalen,
+ (char*) setup->setup_data,
+ user_path);
if (err) {
memset(&(obddev->obd_fsname), 0, sizeof(obd_devicename));
EXIT;