#include <linux/errno.h>
#include <linux/kernel.h>
#include <linux/major.h>
+#include <linux/kmod.h> /* for request_module() */
#include <linux/sched.h>
#include <linux/lp.h>
#include <linux/malloc.h>
static int obd_init_magic;
int obd_print_entry = 1;
-int obd_debug_level = 4095;
+int obd_debug_level = 0;
struct obd_device obd_dev[MAX_OBD_DEVICES];
struct list_head obd_types;
case OBD_IOC_ATTACH: {
struct obd_type *type;
struct oic_generic *input = tmp_buf;
+ char *nm;
ENTRY;
/* have we attached a type to this device */
}
/* find the type */
- type = obd_nm_to_type(input->att_type);
+ nm = input->att_type;
+ type = obd_nm_to_type(nm);
+#ifdef CONFIG_KMOD
+ if ( !type ) {
+ if ( !request_module(nm) ) {
+ CDEBUG(D_IOCTL, "Loaded module '%s'\n", nm);
+ type = obd_nm_to_type(nm);
+ } else {
+ CDEBUG(D_IOCTL, "Can't load module '%s'\n", nm);
+ }
+ }
+#endif
+
OBD_FREE(input->att_type, input->att_typelen + 1);
if ( !type ) {
printk(__FUNCTION__ ": unknown obd type dev %d\n",
default: {
struct obd_type *type;
struct oic_generic input;
+ char *nm;
void *karg;
/* get data structures */
}
/* find the type */
- type = obd_nm_to_type(input.att_type);
+ nm = input.att_type;
+ type = obd_nm_to_type(nm);
+#ifdef CONFIG_KMOD
+ if ( !type ) {
+ if ( !request_module(nm) ) {
+ CDEBUG(D_IOCTL, "Loaded module '%s'\n", nm);
+ type = obd_nm_to_type(nm);
+ } else {
+ CDEBUG(D_IOCTL, "Can't load module '%s'\n", nm);
+ }
+ }
+#endif
OBD_FREE(input.att_type, input.att_typelen + 1);
if ( !type ) {
printk(__FUNCTION__ ": unknown obd type dev %d\n", dev);
obd_class_release, /* release */
NULL, /* fsync */
NULL, /* fasync */
- NULL, /* check_media_change */
- NULL, /* revalidate */
NULL /* lock */
};
my %commands =
('device' => {func => "Device", doc => "device <dev>: open another OBD device"},
'create' => {func => "Create", doc => "create [<num> [<mode> [quiet]]]: create new object(s) (files, unless mode is given)"},
- 'attach' => {func => "Attach", doc => "attach { ext2_obd | snap_obd snapdev snapidx tableno | scsi_obd adapter bus tid lun }: attach this minor device to the specified driver" },
+ 'attach' => {func => "Attach", doc => "attach { obdext2 | obdsnap snapdev snapidx tableno | obdscsi adapter bus tid lun }: attach this minor device to the specified driver" },
'detach' => {func => "Detach", doc => "detach this minor device"},
'testext2iterator' => {func => "TestExt2Iterator", doc => "test ext2 iterator function"},
'snapset' => {func => "SnapSetTable", doc => "snapset <tableno> <file>: set the table (created with snaptable) as table #tableno" },
'migrate' => {func => "Migrate", doc => "migrate <srcid> <tgtid>: migrate data from one object to another"},
'partition' => {func => "Partition", doc => "partition <type> <adapter> <bus> <tid> <lun> <partition> <size>: create a partition"},
'format' => {func => "Format", doc => "format <type> <adapter> <bus> <tid> <lun> <size>: format a partition"},
- 'setup' => {func => "Setup", doc => "setup [type]: link this OBD device to the underlying device (default type ext2_obd)"},
+ 'setup' => {func => "Setup", doc => "setup [type]: link this OBD device to the underlying device (default type obdext2)"},
'connect' => {func => "Connect", doc => "connect: allocates client ID for this session"},
'disconnect' => {func => "Disconnect", doc => "disconnect [id]: frees client resources"},
'sync' => {func => "Sync", doc => "sync: flushes buffers to disk"},
if ( ! $type ) {
print "error: missing type\n";
usage:
- print "usage: attach {ext2_obd | snap_obd | scsi_obd}\n";
+ print "usage: attach {obdext2 | obdsnap | obdscsi}\n";
return;
}
- if ($type eq "scsi_obd" ) {
+ if ($type eq "obdscsi" ) {
my $adapter = shift;
my $bus = shift;
my $tid = shift;
$data = pack("iiii", $adapter, $bus, $tid, $lun);
$datalen = 4 * 4;
- } elsif ($type eq "snap_obd" ) {
+ } elsif ($type eq "obdsnap" ) {
my $snapdev = shift;
my $snapidx = shift;
my $tableno = shift;
$data = pack("iii", $snapdev, $snapidx, $tableno);
$datalen = 3 * 4;
- } elsif ($type eq "ext2_obd") {
+ } elsif ($type eq "obdext2") {
$data = pack("i", 4711); # bogus data
$datalen = 0;
} else {
}
my $err = 0;
- my $type = "ext2_obd";
+ my $type = "obdext2";
$data = pack("i", 4711); # bogus data
$datalen = 4;
}
my $err = 0;
- my $type = "snap_obd";
+ my $type = "obdsnap";
$data = pack("i", 4711); # bogus data
$datalen = 4;
# ready for the ioctl
my $err = 0;
- my $type = "snap_obd";
+ my $type = "obdsnap";
$data = pack("i", $currentindex); # slot of previous current snapshot
$datalen = 4;
sub SnapPrint {
my $err = 0;
- my $type = "snap_obd";
+ my $type = "obdsnap";
my $snaptableno = shift;
$data = pack("i", $snaptableno);
sub SnapSetTable {
my $err = 0;
- my $type = "snap_obd";
+ my $type = "obdsnap";
my $snaptableno = shift;
my $file = shift;
my $snapcount;