racy updates of /etc/mtab
Rob Landley
rob at landley.net
Thu Sep 14 18:24:30 UTC 2006
On Thursday 14 September 2006 12:32 pm, Denis Vlasenko wrote:
> I think we should not modify /etc/mtab in place, as we do today,
> but create /etc/mtab.new, write new contents into it and
> then rename it. With exception: if /etc/mtab is a symlink,
> we probably shouldn't touch it (it is most likely link to /proc).
>
> This approach will be race-free. Do you agree with such a plan?
Why will it be race-free? If two updates happen at the same time, both read
the old file to create their new files, both rename their new files back to
the old name. The second rename deletes the first, so an update gets
dropped.
I'm trusting addmntent() and such to handle these details for us. If the
library isn't doing the appropriate locking for legacy mtab support, fix the
library.
Rob
--
Never bet against the cheap plastic solution.
More information about the busybox
mailing list