tech-userlevel archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: mount race prevention
>> 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.
Ah, got it. That's a clear desire and the use case you sketch makes
sense to me.
I don't think there is anything like this in mount(2), nor, therefore,
in mount(8). Certainly not in the versions I'm familiar with.
It sounds to me as though cooperative locking is suitable, in which
case you might want to use auxiliary lock files. I'd probably do this
as something like
exec 3>/root/backup/lockfile
flock -ex 3 3>&3
...
mount ... /root/backup/tmp-mountpoint
...
umount /root/backup/tmp-mountpoint
...
Unlock is automatic on script exit; flock -un 3 3>&3 if you want to
unlock before exiting
flock in the above is a command-line interface to flock(2), which has
the advantage over (for example) locking by creating directories in
that locks are cleaned up automatically by a reboot.
I imagine some people have built their own utility along these lines;
in case you're not one such, here's the one I use, as a base64ed
bzip2ed .c file:
QlpoOTFBWSZTWTMe7MkAAXRfgGgwe//yf37visT/7//+YAOcc77ltnTXQ3bHGTJo
xDE0wEDAmmCMExNNNABhBpMpkmaaU/SnpNoE9QxAYCGCZAA0ADIjU01GJqeUNDTQ
DQAADQAB6QeoEiJNSMKb1NR5J5JnqT1D1D1GhkND1GjE0D1BocZMmjEMTTAQMCaY
IwTE000AGEEkSaAJo1T8kxokeiBiNGgeoGgDEaHqWCQdqoFWG/ue+DsZMxLMvFMn
HWCUoSgFDWvimhQz4XruoGK9D/0OY2y/TCWMrFWNPAQWiBKUi1iE0nA2M2fK3Dta
cW+0uz8s6JDAFE3Iy5DZU28gOJAL+Aj0hK9UqeiuFOC9LFLlLPAo+hYgVbWd7RfP
cMuXGSZL2VJniC0hcedpNO1EGDns7EkWCpNkMOJSmwOiJ6qgDXLYcETF1UmhijOG
o2NHygVgJqDNAczJhVh/uvVl7zBFFyDrXMFO1o+d9CudBlR+4EM5ZBLLnj2RuVcX
A8m2+Rh63+/ZlOndrhvaprXKjmv0LHeceT3aLeVqjyMITzqRQbu3CcBq7ua+aSQq
KFhcEdZojogSFftITIlxl1bNBxQhhtrWfPYQEO2k9xbo36XAU22GD3bG83hYhFDw
K8dvc6d0cskilOUKUBjchnBen0ckolg+UINSGZOkOoJx9S+yXWqcI2zZ1h+JHBup
LsWtQRuCE1CX6T1JrQ8y2d8PEHJgpkWLo2OX/Nm8gdKnXpn6EbCgGREcpO3nRukt
SyphTqu27GFtgWcvBTGRaq/NgWmBDQ7LpFZFTSTEpoZrANQMnVqGs5Z6+rIEMg9D
jwKzoQxZI0bcNHwmOAMzMk+pTKg14DZJCXfYQtCM3aVklGv6tDNc4ROyrtr0tY66
4DofAJZngCMG14SriKuw3lSUYLlm4ErTeZ3urHaikkQyzcbKHCOhinOS5EMzBrOJ
zKoIgZMwWBQFEaANIkiPYBBagX7E96VTlE4E0idryrLsOK6yabUT1IpjYVM6ImiE
qI13NLvB1qRwuisqJ4KM6nklIgDpUNCAEyuHbGcUza7b75+yYDjuRyNgUVauBtO+
isvvdweCHchVjThVYG1EtE7mMJkUuFAW6WRJrHr03woBpAhLOt8gnxkEnFKwc+7L
JvWQq5kJd7hMRftZd2zQzH4ESGk40XRUqGhi5mqyEoeQ5AaMLAQFCPIcTfSFboSk
MhZXxI13E1FGc7lc8R4kjJKVlAuZVNeljErmVmBNzjHKzC6QgRSUqEk/8XckU4UJ
AzHuzJA=
/~\ The ASCII Mouse
\ / Ribbon Campaign
X Against HTML mouse%rodents-montreal.org@localhost
/ \ Email! 7D C8 61 52 5D E7 2D 39 4E F1 31 3E E8 B3 27 4B
Home |
Main Index |
Thread Index |
Old Index