Off-Topic Question: Check if filesystem is in use
Harald Becker
ralda at gmx.de
Fri Mar 29 15:20:04 UTC 2013
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 condition has to be prevented. I
considered a separate lock for this, as I'm able to control the initial
access to the filesystem (login) but can't control/lock what may be
forked off from there.
... but Laurent's mount --bind / umount sequence shall prevent (or at
least catch) that race condition. So I'm going to use fuser to do a
quick check to avoid unnecessary mount/umount calls and then catch a
failing umount and skip the cleanup (leaving filesystem in operational
state).
--
Harald
More information about the busybox
mailing list