Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

noire anqa

macrumors regular
Original poster
Aug 20, 2010
137
0
Hi, anyone know how i get a list of programs that are currently accessing a volume?

Backstory: I'm using an encrypted sparsebundle to store sensitive documents, and backing up using time machine. Time machine will back up a sparsebundle, even if it's mounted - this corrupts the backup and leaves the backup of the encrypted image unmountable. (Which i imagine is why filevault won't backup when logged in).


To remedy this i'll programatically change the timemachine backup list:

If nothing is using the sparsebundle i want it to unmount the sparsebundle before initiating a backup, and reattach it when it's done.

If im using a file on the sparsebundle i want it to backup everything but the sparsebundle.

However, if i'm using a file in the bundle, but i havent been at the computer for more than an hour, i want to know what programs are blocking the bundle from ejecting, send them applescript "save your work and quit" commands, and backup the sparsebundle.

For this i'll need a list of the programs accessing files on the sparsebundle! diskutil only says the device is busy without elaborating on what programs are using it. Finder however knows exactly what's using it, how does it do it?

Thanks
 
Last edited:
Note that on Mac OS X 10.6 at least, you can ditch grep and just call it as.

Code:
lsof [I]/Path_to_mounted_Volume[/I]


If a name is the mounted-on directory of a file system or the device of the file system, lsof will list all the files open on the file system. To be considered a file system, the name must match a mounted-on directory name in mount(8) output, or match the name of a block device associated with a mounted-on directory name. The +|-f option may be used to force lsof to consider a name a file system identifier (+f) or a simple file (-f).
B
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.