Off-Topic Question: Check if filesystem is in use

Harald Becker ralda at gmx.de
Fri Mar 29 15:10:45 UTC 2013


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 temporary filesystem is created and setup by
unpacking a default archive and the previously stored archive (merging
contents).

In case of interest:

I'm going to create a special Server installation for RaspPi. It may
serve several different users via remote ssh login, but not many
different users at the same time. So I'm planning to put the user home
directory on a small (~2MB) temporary file system in RAM. This home
directory is created when a user login via ssh. But nevertheless how
many times the user login at the same time, he gets his same home
directory. If the user logout completely. The temporary filesystem is
cleaned (unnecessary stuff removed) and it's contents is stored away on
the SD flash memory. When the user comes back the filesystem is
recreated and populated with some default contents, and then
overwritten by the stored archive contents.


> * mount --bind your original directory to somewhere else
> * umount your original directory
> * if it didn't work, your original directory is still in use,
>umount the copy
> * but if it worked, your original directory wasn't in use anymore,
>perform the cleanup on the copy then umount the copy.

Wow, great idea.

> If bind mount semantics have changed since 2.6.32, then I have no
>better idea than fuser -m.

And that hits!

if fuser -ms MOUNTPOINT
  then do cleanup
fi

... does the requested job.

In addition I'm going to use fuser for a quick check and your
mount/umount sequence for the cleanup process. That way an additional
locking is eliminated.

Many thx!

--
Harald


More information about the busybox mailing list