X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=drivers%2Fblock%2Fvroot.c;fp=drivers%2Fblock%2Fvroot.c;h=9ef8302c9f9116633c224730d98b83f07893f521;hb=43bc926fffd92024b46cafaf7350d669ba9ca884;hp=4587cbf9a2973c23f2b5acbf4f5c29a71c16788a;hpb=cee37fe97739d85991964371c1f3a745c00dd236;p=linux-2.6.git diff --git a/drivers/block/vroot.c b/drivers/block/vroot.c index 4587cbf9a..9ef8302c9 100644 --- a/drivers/block/vroot.c +++ b/drivers/block/vroot.c @@ -12,7 +12,6 @@ * */ -#include #include #include #include @@ -21,6 +20,7 @@ #include #include +#include static int max_vroot = 8; @@ -60,9 +60,9 @@ static int vroot_set_dev( } else goto out_fput; - printk(KERN_INFO "vroot[%d]_set_dev: dev=%p[%d,%d]\n", - vr->vr_number, real_bdev, - imajor(real_bdev->bd_inode), iminor(real_bdev->bd_inode)); + vxdprintk(VXD_CBIT(misc, 0), + "vroot[%d]_set_dev: dev=" VXF_DEV, + vr->vr_number, VXD_DEV(real_bdev)); vr->vr_state = Vr_bound; error = 0; @@ -87,9 +87,9 @@ static int vroot_clr_dev( real_bdev = vr->vr_device; - printk(KERN_INFO "vroot[%d]_clr_dev: dev=%p[%d,%d]\n", - vr->vr_number, real_bdev, - imajor(real_bdev->bd_inode), iminor(real_bdev->bd_inode)); + vxdprintk(VXD_CBIT(misc, 0), + "vroot[%d]_clr_dev: dev=" VXF_DEV, + vr->vr_number, VXD_DEV(real_bdev)); bdput(real_bdev); vr->vr_state = Vr_unbound; @@ -147,7 +147,7 @@ static struct block_device_operations vr_fops = { .ioctl = vr_ioctl, }; -struct block_device *vroot_get_real_bdev(struct block_device *bdev) +struct block_device *__vroot_get_real_bdev(struct block_device *bdev) { struct inode *inode = bdev->bd_inode; struct vroot_device *vr; @@ -157,9 +157,9 @@ struct block_device *vroot_get_real_bdev(struct block_device *bdev) vr = &vroot_dev[minor]; real_bdev = vr->vr_device; - printk(KERN_INFO "vroot[%d]_get_real_bdev: dev=%p[%p,%d,%d]\n", - vr->vr_number, real_bdev, real_bdev->bd_inode, - imajor(real_bdev->bd_inode), iminor(real_bdev->bd_inode)); + vxdprintk(VXD_CBIT(misc, 0), + "vroot[%d]_get_real_bdev: dev=" VXF_DEV, + vr->vr_number, VXD_DEV(real_bdev)); if (vr->vr_state != Vr_bound) return ERR_PTR(-ENXIO); @@ -184,7 +184,7 @@ MODULE_DESCRIPTION ("Virtual Root Device Mapper"); int __init vroot_init(void) { - int i; + int err, i; if (max_vroot < 1 || max_vroot > 256) { max_vroot = MAX_VROOT_DEFAULT; @@ -196,6 +196,7 @@ int __init vroot_init(void) if (register_blkdev(VROOT_MAJOR, "vroot")) return -EIO; + err = -ENOMEM; vroot_dev = kmalloc(max_vroot * sizeof(struct vroot_device), GFP_KERNEL); if (!vroot_dev) goto out_mem1; @@ -228,11 +229,17 @@ int __init vroot_init(void) disk->private_data = vr; } + err = register_vroot_grb(&__vroot_get_real_bdev); + if (err) + goto out_reg; + for (i = 0; i < max_vroot; i++) add_disk(disks[i]); printk(KERN_INFO "vroot: loaded (max %d devices)\n", max_vroot); return 0; +out_reg: + devfs_remove("vroot"); out_mem3: while (i--) put_disk(disks[i]); @@ -242,13 +249,16 @@ out_mem2: out_mem1: unregister_blkdev(VROOT_MAJOR, "vroot"); printk(KERN_ERR "vroot: ran out of memory\n"); - return -ENOMEM; + return err; } void vroot_exit(void) { int i; + if (unregister_vroot_grb(&__vroot_get_real_bdev)) + printk(KERN_WARNING "vroot: cannot unregister grb\n"); + for (i = 0; i < max_vroot; i++) { del_gendisk(disks[i]); put_disk(disks[i]); @@ -264,3 +274,15 @@ void vroot_exit(void) module_init(vroot_init); module_exit(vroot_exit); +#ifndef MODULE + +static int __init max_vroot_setup(char *str) +{ + max_vroot = simple_strtol(str, NULL, 0); + return 1; +} + +__setup("max_vroot=", max_vroot_setup); + +#endif +