Doron Shoham schrieb: > Bastian Blank wrote: >> On Thu, Sep 04, 2008 at 04:39:24PM +0300, Doron Shoham wrote: >>> deny allocation of a device which >>> which mounted on the same device as rootfs. >>> also deny the allocation of swap devices. >>> add --allow-mounted flag for overriding this. >> Neither /etc/mtab nor /dev/mounts provides a proper view on the mounted >> filesystems. To check the used state you need to try to open it >> exclusive. >> >> Bastian >> > > Can you please explain how to do it? > What do you mean by "try to open it exclusive"? This is what I found out. DRBD[1] uses kernel's bd_claim to see if the device is already claimed. bd_claim is located in kernel's fs/block_dev.c: int bd_claim(struct block_device *bdev, void *holder) { int res; spin_lock(&bdev_lock); /* first decide result */ if (bdev->bd_holder == holder) res = 0; /* already a holder */ else if (bdev->bd_holder != NULL) res = -EBUSY; /* held by someone else */ else if (bdev->bd_contains == bdev) res = 0; /* is a whole device which isn't held */ else if (bdev->bd_contains->bd_holder == bd_claim) res = 0; /* is a partition of a device that is being partitioned */ else if (bdev->bd_contains->bd_holder != NULL) res = -EBUSY; /* is a partition of a held device */ else res = 0; /* is a partition of an un-held device */ How to use it from user-space? Any kernel hackers out there? ;) [1] http://www.drbd.org -- Tomasz Chmielewski http://wpkg.org -- To unsubscribe from this list: send the line "unsubscribe stgt" in the body of a message to majordomo at vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html |