On Tue, Nov 18, 2025 at 07:36:11PM +0100, Edgar Fu wrote:
> > So, my first question would be, what precisely is it you're trying to
> > prevent?
> I want to prevent B to mount something on a temporary mount point already 
> in use by A. I.e., A sees the mount point is free, B sees it's free, 
> A mounts, B mounts, and A operates on the wrong thing.
> 
> I have scripts that operate on snapshots they take. I.e., when I backup 
> /export/home, I look for an unused fss device, take an ffs snapshot of 
> /dev/dk5 on it, mount it, backup it, unmount, fssconfig -u.
> The problem is I need a temporary mount point like /mnt which (highly 
> unlikely) could be in use by another (incarnation of the same) script.
> Yes, I guess I could be using temporary entries in /tmp.

In this case I would probably create a dedicated directory such as
/mnt_myscript, and for each invokation of the script have it always create a
unique random mount point under that directory, use it for the duration of
that particular run, then unlink it.

I.E. never use /mnt_myscript directly, but only as a place to create a
temporary mountpoint.

Assuming that there are no other file sharing or locking issues, that
potentially also allows multiple copies of the script to run simultaneously
instead of erroring out.

Reply via email to