Andreas, libdiskmgt is what SVM and ZFS use to determnine whether a device is already in use. I'm not sure if these C interfaces would help your perl script but Sarah has a good blog at
http://blogs.sun.com/sarahsblog/entry/zfs_zpool_device_in_use -tony Andreas Koppenhoefer wrote: > Hello folks, > > currently I'm working on a little perl script for creating filesystem upon a > given disk. In the script I want to validate user input. > And here is the problem: > How can I test a given disk name like c2t0d0s2 if it's being used somewhere > How can I make sure it's free for use? > > The long way is to check files or command output of: > - /etc/mnttab > - metastat > - swap -l > - vxprint > - zfs > - lsof /dev/dsk/c2t0d0s* /dev/rdsk/c2t0d0s* > > The latter is for checking if some application is using the disk directly > (e.g. Oracle). > > That's all too complicated and not failsafe. > Maybe this would work on most of our productive servers. But imagine there > are few servers with some third party software or device driver which is > using disks without opening raw or block device. My script would not be able > to catch this! > > Guess there is a simple way of asking the disk if it's currently in use. > Any ideas? > Something like opening device file and trying to set a lock (fcntl(), lock()) > on it? > > Maybe this is a little bit off topic in this group. But I think you are the > right experts to ask for. > > > This message posted from opensolaris.org > _______________________________________________ > lvm-discuss mailing list > lvm-discuss at opensolaris.org >