Domanda

This may sound like a silly question but up until recently if you tried to unmount a volume that was in use the Finder reported that it was in use, but not by whom. This is simple Unix functionality, if a file is open on a mount point, do not allow it to eject. But now they seem to have added functionality that lets the user know what programs are currently using a mounted system, and I have been looking through man pages of fopen,stat, etc. for Unix like operating systems(distros of linux) and I can't seem to find similar functionality.

Is this functionality specialized, or am I just looking in the wrong place?

È stato utile?

Soluzione

There are BSD-level calls (mainly lsof, whose source is at http://www.opensource.apple.com/source/lsof/) that let you examine the list of files open in a process. Activity Monitor, for example, uses them.

Using lsof as a starting point, you can iterate through processes and see if any of them are using a file under the mount point you're examining. There may be more efficient ways to do it though, of which I'm not aware. :)

Altri suggerimenti

It's somewhat specialized. Check out the lsof utility.

Check the man page for fuser, and run fuser -c /mountpoint

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top