mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
o fs_add and fs_remove actually create/remove the device now
This commit is contained in:
parent
4a6a800fd8
commit
016cf45775
@ -129,6 +129,19 @@ int dm_fs_add(struct mapped_device *md)
|
|||||||
md->pde->write_proc = _line_splitter;
|
md->pde->write_proc = _line_splitter;
|
||||||
md->pde->data = pfd;
|
md->pde->data = pfd;
|
||||||
|
|
||||||
|
md->devfs_entry =
|
||||||
|
devfs_register(_dev_dir, md->name, DEVFS_FL_DEFAULT,
|
||||||
|
MAJOR(md->dev), MINOR(md->dev),
|
||||||
|
S_IFBLK | S_IRUSR | S_IWUSR | S_IRGRP,
|
||||||
|
&dm_blk_dops, NULL);
|
||||||
|
|
||||||
|
if (!md->devfs_entry) {
|
||||||
|
kfree(pfd);
|
||||||
|
remove_proc_entry(md->name, _proc_dir);
|
||||||
|
md->pde = 0;
|
||||||
|
return -ENOMEM; /* FIXME: better error ? */
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -137,7 +150,11 @@ int dm_fs_remove(struct mapped_device *md)
|
|||||||
if (md->pde) {
|
if (md->pde) {
|
||||||
kfree(md->pde->data);
|
kfree(md->pde->data);
|
||||||
remove_proc_entry(md->name, _proc_dir);
|
remove_proc_entry(md->name, _proc_dir);
|
||||||
|
md->pde = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
devfs_unregister(md->devfs_entry);
|
||||||
|
md->devfs_entry = 0;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -137,7 +137,7 @@ static int _blk_close(struct inode *inode, struct file *file);
|
|||||||
static int _blk_ioctl(struct inode *inode, struct file *file,
|
static int _blk_ioctl(struct inode *inode, struct file *file,
|
||||||
uint command, ulong a);
|
uint command, ulong a);
|
||||||
|
|
||||||
static struct block_device_operations _blk_dops = {
|
struct block_device_operations dm_blk_dops = {
|
||||||
open: _blk_open,
|
open: _blk_open,
|
||||||
release: _blk_close,
|
release: _blk_close,
|
||||||
ioctl: _blk_ioctl
|
ioctl: _blk_ioctl
|
||||||
@ -166,7 +166,7 @@ static int _init(void)
|
|||||||
blksize_size[MAJOR_NR] = _blksize_size;
|
blksize_size[MAJOR_NR] = _blksize_size;
|
||||||
hardsect_size[MAJOR_NR] = _hardsect_size;
|
hardsect_size[MAJOR_NR] = _hardsect_size;
|
||||||
|
|
||||||
if (devfs_register_blkdev(MAJOR_NR, _name, &_blk_dops) < 0) {
|
if (devfs_register_blkdev(MAJOR_NR, _name, &dm_blk_dops) < 0) {
|
||||||
printk(KERN_ERR "%s -- register_blkdev failed\n", _name);
|
printk(KERN_ERR "%s -- register_blkdev failed\n", _name);
|
||||||
return -EIO;
|
return -EIO;
|
||||||
}
|
}
|
||||||
@ -383,17 +383,6 @@ static struct mapped_device *_alloc_dev(int minor)
|
|||||||
return md;
|
return md;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _free_dev(struct mapped_device *md)
|
|
||||||
{
|
|
||||||
int minor = MINOR(md->dev);
|
|
||||||
|
|
||||||
wl;
|
|
||||||
_devs[minor] = 0;
|
|
||||||
wu;
|
|
||||||
|
|
||||||
kfree(md);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline struct mapped_device *__find_name(const char *name)
|
static inline struct mapped_device *__find_name(const char *name)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
@ -462,8 +451,8 @@ int dm_create(const char *name, int minor)
|
|||||||
wl;
|
wl;
|
||||||
if (__find_name(name)) {
|
if (__find_name(name)) {
|
||||||
WARN("device with that name already exists");
|
WARN("device with that name already exists");
|
||||||
|
kfree(md);
|
||||||
wu;
|
wu;
|
||||||
_free_dev(md);
|
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -503,7 +492,7 @@ int dm_remove(const char *name)
|
|||||||
}
|
}
|
||||||
|
|
||||||
minor = MINOR(md->dev);
|
minor = MINOR(md->dev);
|
||||||
_free_dev(md);
|
kfree(md);
|
||||||
_devs[minor] = 0;
|
_devs[minor] = 0;
|
||||||
wu;
|
wu;
|
||||||
|
|
||||||
|
@ -95,6 +95,7 @@ struct target {
|
|||||||
struct target *next;
|
struct target *next;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
extern struct block_device_operations dm_blk_dops;
|
||||||
|
|
||||||
/* dm-target.c */
|
/* dm-target.c */
|
||||||
struct target *dm_get_target(const char *name);
|
struct target *dm_get_target(const char *name);
|
||||||
|
Loading…
Reference in New Issue
Block a user