Re: How to find disk is in use?
- From: "adar" <adar_ji@xxxxxxxxx>
- Date: 20 Oct 2006 14:13:31 -0700
phil-news-nospam@xxxxxxxx wrote:
I don't know of a specific feature that would let the kernel tell you this
directly. So I suspect what you will need to do is codify into your program
what the relationship between /dev/sda3 and /dev/sda is. In other words,
for a test of a full device, the program needs to know _all_ the possible
partition device names and run the test against them all to see if any of
them is busy. I also suggest that you do NOT read the partition table to
get a shortcut of a subset of partitions to test if this is an application
that you may be distributing to others (maybe there are conditions under
which it could be used where the on-disk partition table does not reflect
that actual set of busy partitions known to the active kernel). You can
get what the kernel thinks are "the partitions" in /proc/partitions.
If you are at a kernel level and have the "sysfs" feature active, you canNo I have not discoverd this, of course, I am looking for better way. I
derive a set of common names for the whole-to-partition device relationship
within /sys/block for each respective device.
Since I can write over a partition table even with a partition on that
disk mounted, I can say that attempting to open the whole device for
writing is not going to be prevented by a busy partition. Maybe you have
already discovered this and thus seek a better way.
have not started writing code for this feature yet, just preparing.
However I am thinking in the same angle. For example:
1) Do what ever "# fdisk -l /dev/sdc" command would do, basically
reading the partition table
Or this can be done through sys/block also... what is the better
method...???
2) Do what ever # umount /dev/sdc[1-..N] , if some process is running
on that parition.
3) Do what ever lsof and fuser does
By the way I keeping distance from /proc filesystem as it can get
obsloute any time
.
- References:
- How to find disk is in use?
- From: adar
- Re: How to find disk is in use?
- From: phil-news-nospam
- How to find disk is in use?
- Prev by Date: Re: How to find disk is in use?
- Next by Date: Re: boot loader that can read from partition?
- Previous by thread: Re: How to find disk is in use?
- Next by thread: virtual serial port driver.....
- Index(es):
Relevant Pages
|