Hello Al, hello Jan
Al Viro <viro@xxxxxxxxxxxxxxxxxx> wrote:
i_minor(inode) is equal to MINOR(inode->i_bdev->bd_dev), so if ->open()
used to use the former, you can replace it with MINOR(bdev->bd_dev)
in new variant; same for i_major (use MAJOR(...)). Most of the places
using those actually used them to locate
inode->i_bdev->bd_disk->private_data,
and could be completely eliminated in either version. Faster and cleaner
that way...
Sorry for the late answer, but I'm littel busy at present so I
couldn't spend some time for testing. Thank you for your hints, I now
see anything more clear.
As soon as I can look at the code again, I will try to transform the
objects and functions to the new kernel code.
The corresponding code that happens in cvfs is (linuxif_fsctl.c):
---
static int cvfsctl_major;
extern int cvfsctl_ioctl(struct inode *f_inode, struct file *f_file,
unsigned int f_cmd, unsigned long f_argbuf);
static
int cvfsctl_open(
struct inode *f_inode,
struct file *f_file)
{
return 0;
}
extern int cvfsctl_ioctl(
struct inode *f_inode,
struct file *f_file,
unsigned int f_cmd,
unsigned long f_argbuf);
static struct block_device_operations cvfsctl_fops = {
owner: THIS_MODULE,
/* ### here are the objects loaded ### */
open: cvfsctl_open,
ioctl: cvfsctl_ioctl,
};
#define MAXDISKS 1024
static struct gendisk *disks[MAXDISKS];
static struct kobject *cvfsctl_probe(dev_t dev, int *part, void *data)
{
static DECLARE_MUTEX(disks_sem);
struct gendisk *disk;
int unit = MINOR(dev);
down (&disks_sem);
if (disks[unit]) {
up(&disks_sem);
return NULL;
}
disk = alloc_disk(1);
if (!disk) {
up(&disks_sem);
return NULL;
disk->major = MAJOR(dev);
disk->first_minor = unit;
sprintf(disk->disk_name, "cvfsctl%d", unit);
/* ### and this here will fail ### */
disk->fops = &cvfsctl_fops;
add_disk(disk);
disks[unit] = disk;
up(&disks_sem);
return NULL;
}
---
Regards
Ralf
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html