Re: Off-Topic Question: Check if filesystem is in use

2013-03-29 Thread Sedat Dilek
Hi, ...guess this is a Linux-Filesystem specific question... Why not ask also on linux-fsdevel linux-fsde...@vger.kernel.org? Regards, - Sedat - On Fri, Mar 29, 2013 at 6:45 AM, Harald Becker ra...@gmx.de wrote: Hi, as here are several experts, and not so much traffic at the moment, I throw

Re: Off-Topic Question: Check if filesystem is in use

2013-03-29 Thread Laurent Bercot
In a shell script I like to check if a mounted filesystem is still in use by any other process in the system. If there is no more process using the filesystem some cleanup actions has to be done and afterwards the filesystem is unmounted. As the filesystem is only a temporary filesystem it's

Re: Off-Topic Question: Check if filesystem is in use

2013-03-29 Thread Alexander Kriegisch
Maybe you will find lsof helpful, e.g. lsof +D /my/mountpoint Regards Alexander Kriegisch Am 29.03.2013 um 06:45 schrieb Harald Becker ra...@gmx.de: Hi, as here are several experts, and not so much traffic at the moment, I throw in an off-topic question (which may still be of interest

Re: Off-Topic Question: Check if filesystem is in use

2013-03-29 Thread Laurent Bercot
Maybe you will find lsof helpful, e.g. lsof +D /my/mountpoint lsof, as fuser, are /proc-scanning tools. Scanning /proc to then grep the output is inefficient, and also non-atomic. I think Harald was looking for an operation that did not involve scanning. -- Laurent

Re: Off-Topic Question: Check if filesystem is in use

2013-03-29 Thread Alexander Kriegisch
Laurent is right. BTW, I was not suggesting lsof was efficient. I just trew it into the discusssion because sometimes it helped me on my home router. Am 29.03.2013 um 14:32 schrieb Laurent Bercot ska-dietl...@skarnet.org: Maybe you will find lsof helpful, e.g. lsof +D /my/mountpoint

Re: Off-Topic Question: Check if filesystem is in use

2013-03-29 Thread Grant Edwards
On 2013-03-29, Harald Becker ra...@gmx.de wrote: Hi, as here are several experts, and not so much traffic at the moment, I throw in an off-topic question (which may still be of interest for other system managers): In a shell script I like to check if a mounted filesystem is still in use by

Re: Off-Topic Question: Check if filesystem is in use

2013-03-29 Thread Grant Edwards
On 2013-03-29, Laurent Bercot ska-dietl...@skarnet.org wrote: Maybe you will find lsof helpful, e.g. lsof +D /my/mountpoint lsof, as fuser, are /proc-scanning tools. Scanning /proc to then grep the output is inefficient, and also non-atomic. If you want something that's atomic, then I

Re: Off-Topic Question: Check if filesystem is in use

2013-03-29 Thread Harald Becker
Hi Laurent ! Sounds strange that you need to perform some cleanup on contents that will disappear after the unmount anyway ^^ :) Cleanup means deleting some unwanted stuff, then packing contents of temporary filesystem in an archive to store that away for later usage. If required a new

Re: Off-Topic Question: Check if filesystem is in use

2013-03-29 Thread Harald Becker
Hi Grant ! How are you going to prevent a race condition? 1) you check to see if the filesystem is in use and find that it isn't. 2) another process opens/creates a file in the filesystem. 3) you do your cleanup. 4) you do a umount and it fails. You are absolutely right. This race

Re: Off-Topic Question: Check if filesystem is in use

2013-03-29 Thread Harald Becker
Hi Grant ! If you want something that's atomic, then I think 'umount' is your only option. If it fails, the fielsystem was busy. If it succeeds, then it wasn't busy and is now unmounted. Sure, I previously did that umount check on physical patitions, but my current problem was, that the

Off-Topic Question: Check if filesystem is in use

2013-03-28 Thread Harald Becker
Hi, as here are several experts, and not so much traffic at the moment, I throw in an off-topic question (which may still be of interest for other system managers): In a shell script I like to check if a mounted filesystem is still in use by any other process in the system. If there is no more