lkml.org 
[lkml]   [2000]   [Sep]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH] devfs support for LVM
Hi Linus,
I've updated my devfs for lvm patch to 2.4.0-test8pre.
Here it is.

Christoph

--
Always remember that you are unique. Just like everyone else.


--- linux.orig/drivers/block/lvm.c Fri Jul 14 14:38:29 2000
+++ linux/drivers/block/lvm.c Sun Sep 3 13:54:00 2000
@@ -299,6 +299,11 @@

static spinlock_t lvm_lock = SPIN_LOCK_UNLOCKED;

+static devfs_handle_t lvm_devfs_handle;
+static devfs_handle_t vg_devfs_handle[MAX_VG];
+static devfs_handle_t ch_devfs_handle[MAX_VG];
+static devfs_handle_t lv_devfs_handle[MAX_LV];
+
static struct file_operations lvm_chr_fops =
{
owner: THIS_MODULE,
@@ -358,13 +363,18 @@
printk(KERN_ERR "%s -- register_chrdev failed\n", lvm_name);
return -EIO;
}
- if (register_blkdev(MAJOR_NR, lvm_name, &lvm_blk_dops) < 0)
- {
+ if (register_blkdev(MAJOR_NR, lvm_name, &lvm_blk_dops) < 0) {
printk("%s -- register_blkdev failed\n", lvm_name);
if (unregister_chrdev(LVM_CHAR_MAJOR, lvm_name) < 0)
printk(KERN_ERR "%s -- unregister_chrdev failed\n", lvm_name);
return -EIO;
}
+
+ lvm_devfs_handle = devfs_register(
+ 0 , "lvm", 0, 0, LVM_CHAR_MAJOR,
+ S_IFCHR | S_IRUSR | S_IWUSR | S_IRGRP,
+ &lvm_chr_fops, NULL);
+
#if defined CONFIG_LVM_PROC_FS && defined CONFIG_PROC_FS
create_proc_info_entry(LVM_NAME, S_IFREG | S_IRUGO,
&proc_root, lvm_proc_get_info_ptr);
@@ -422,6 +432,8 @@
{
struct gendisk *gendisk_ptr = NULL, *gendisk_ptr_prev = NULL;

+ devfs_unregister (lvm_devfs_handle);
+
if (unregister_chrdev(LVM_CHAR_MAJOR, lvm_name) < 0) {
printk(KERN_ERR "%s -- unregister_chrdev failed\n", lvm_name);
}
@@ -1625,6 +1637,14 @@
kfree(vg_ptr);
return -EFAULT;
}
+
+ vg_devfs_handle[vg_ptr->vg_number] = devfs_mk_dir(0, vg_ptr->vg_name, NULL);
+ ch_devfs_handle[vg_ptr->vg_number] = devfs_register(
+ vg_devfs_handle[vg_ptr->vg_number] , "group",
+ DEVFS_FL_DEFAULT, LVM_CHAR_MAJOR, vg_ptr->vg_number,
+ S_IFCHR | S_IRUSR | S_IWUSR | S_IRGRP,
+ &lvm_chr_fops, NULL);
+
/* we are not that active so far... */
vg_ptr->vg_status &= ~VG_ACTIVE;
vg[VG_CHR(minor)] = vg_ptr;
@@ -1852,6 +1872,9 @@
/* let's go inactive */
vg_ptr->vg_status &= ~VG_ACTIVE;

+ devfs_unregister (ch_devfs_handle[vg_ptr->vg_number]);
+ devfs_unregister (vg_devfs_handle[vg_ptr->vg_number]);
+
/* free LVs */
/* first free snapshot logical volumes */
for (i = 0; i < vg_ptr->lv_max; i++) {
@@ -1907,6 +1930,7 @@
{
int l, le, l_new, p, size;
ulong lv_status_save;
+ char *lv_tmp, *lv_buf;
lv_block_exception_t *lvbe = lv->lv_block_exception;
vg_t *vg_ptr = vg[VG_CHR(minor)];
lv_t *lv_ptr = NULL;
@@ -2062,6 +2086,17 @@
vg_ptr->lv_cur++;
lv_ptr->lv_status = lv_status_save;

+ strtok(lv->lv_name, "/"); /* /dev */
+
+ while((lv_tmp = strtok(NULL, "/")) != NULL)
+ lv_buf = lv_tmp;
+
+ lv_devfs_handle[lv->lv_number] = devfs_register(
+ vg_devfs_handle[vg_ptr->vg_number], lv_buf,
+ DEVFS_FL_DEFAULT, LVM_BLK_MAJOR, lv->lv_number,
+ S_IFBLK | S_IRUSR | S_IWUSR | S_IRGRP,
+ &lvm_blk_dops, NULL);
+
/* optionally add our new snapshot LV */
if (lv_ptr->lv_access & LV_SNAPSHOT) {
/* sync the original logical volume */
@@ -2153,6 +2188,8 @@
lv_ptr->lv_snapshot_org->lv_access &= ~LV_SNAPSHOT_ORG;
lvm_snapshot_release(lv_ptr);
}
+
+ devfs_unregister(lv_devfs_handle[lv_ptr->lv_number]);

#ifdef DEBUG_KFREE
printk(KERN_DEBUG "%s -- kfree %d\n", lvm_name, __LINE__);
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/
\
 
 \ /
  Last update: 2005-03-22 12:39    [W:0.071 / U:1.032 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site