Locking a block device

C. Scott Ananian (phil.burr@usa.net)
Wed, 04 Mar 1998 14:03:03

This may not be the place to ask but...

Is there a way to lock a block device so that a process has exclusive access to it? I have tried POSIX locks with little success.

For example, say I want a program to have exclusive access to /dev/hda3. I want the major/minor to be locked so that no other program can access it, mount it or do anything with it until I release the lock. A reason for the lock would be if I wanted to manipulate fs structures within a partition. I wouldn't want the state of the fs to change on me unawares while I change the FS myself. Granted, while it is likely that it won't happen, I would like to able to guarantee that it won't.

If there is a way to do this, please let me know. If not, maybe this should be an enhancement to the kernel (?).

Any comments would be appreciated.

Phillip Burr

Get free e-mail and a permanent address at http://www.netaddress.com

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu