Private temporary mountpoints
I'm looking for a way for a program to create a temporary private mount point, which would be automatically unmounted (and ideally deleted) as soon as the program is killed. The program would have to have full access to the files in the mount including browsing directories and opening new files.
This would be analogous to how temporary files are often used after unlinking them.
I'm prepared to use SUID executables and Linux kernel calls but I'd still like the method to be general enough to be portable to other unixes (preferably without hacking the kernel [smile]).
If you are going to use SUID binaries then just try man 2 mount and use these functions to mount and unmount your device. You could possibly use umount with MNT_DETACH after you have opened some files at the mount point. MNT_DETACH does not unmount the device immediately but it waits until the mount point ceases to be busy. And use atexit() to hook some cleanup function to be called at normal exit and hook the cleanup also for signals (with signal()) implying abnormal exit (such as kill).
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement