Search code examples
clinuxmount

Non-blocking mount in Linux


I use Linux's mount(2) function in a single-threaded process. But mounting of devices devices like CD-ROM may take a while (worst I've seen is 40 seconds!), as it will ponder a little, spin up the disk, and only then will mount the filesystem. This may block the process from processing other events for considerable time.

I cannot seem to find a way to mount a filesystem in a non-blocking way. Is there a way to mount a filesystem asynchronously without multi-threading or forking?

Knowing whether the action is complete is not an issue for me as I already read kernel uevents in the same thread.


Solution

  • No. Without firing up another thread or fork()ing, you have to wait for mount() to return.