The BSD automounter in 'am-utils' has hand-crafted its own code for mounting file systems & updating /etc/mtab. In this code it uses flock() to take out an exclusive lock on /etc/mtab. The Linux native automounter (AutoFS4) merely invokes /bin/mount to perform actuall mount & update /etc/mtab. The /bin/mount program uses fcntl() to take out an exclusive lock on /etc/mtab. The result of this is that if you run both AMD and AutoFS4 on the same machine, then if you happen to be unlucky enough to have a mount point created / expired in AMD & AutoFS4 managaged locations at the same time, your /etc/mtab will become corrupted. Patches below fix this issue.
Created attachment 108723 [details] am-utils-mtab-lock.patch Patch by Daniel Berrange <berrange>: I'm attaching a patch which adds a new mtab handling code specifically for Linux. This is taken from the /bin/mount source code so is 100% in sync with the locking scheme used there. As an added benefit it also fixes am-utils handling of symlinks on /etc/mtab (ie it'll not try updating mtab, if it is a symlink). In terms of impl, the conf/mtab/mtab_linux.c file basically started off as a copy of conf/mtab/mtab_file.c, and then I merely replaced any code relating to locking, so the actual updating code didn't change.
Created attachment 108724 [details] am-utils-mtab-lock-symlink.patch Patch by Daniel Berrange <berrange> again: The first patch had a bug whereby it was still take out an exclusive lock on /etc/mtab~ when it was a symlink, even though it would never update it. The attached patch augments the first, preventing it from doing any locking at all when symlinks are involved.
Created attachment 111384 [details] Bring the am-utils patches inline with the patch for mount This patch should be applied after the am-utils-mtab-lock & am-utils-mtab-lock-symlink patches. The endd result is to bring am-utils inline with the locking scheme for /etc/fstab implemented in the patch 111141 for util-linux
Created attachment 111386 [details] The am-utils source RPM with all patches applied
Created attachment 111387 [details] The correspondingly patched util-linux RPM that i tested
Uhm, pvrabec fell out of the CC list, apparently. @pvrabec: i suggest you read the (back)log for the bug and apply the patches where appropriate, as kzak suggested.
*** Bug 154108 has been marked as a duplicate of this bug. ***
Created attachment 117871 [details] Modified berrange testcase. I can acknowledge the testcase works.
An advisory has been issued which should help the problem described in this bug report. This report is therefore being closed with a resolution of ERRATA. For more information on the solution and/or where to find the updated files, please follow the link below. You may reopen this bug report if the solution does not work for you. http://rhn.redhat.com/errata/RHBA-2005-626.html
An advisory has been issued which should help the problem described in this bug report. This report is therefore being closed with a resolution of ERRATA. For more information on the solution and/or where to find the updated files, please follow the link below. You may reopen this bug report if the solution does not work for you. http://rhn.redhat.com/errata/RHBA-2005-341.html
An advisory has been issued which should help the problem described in this bug report. This report is therefore being closed with a resolution of ERRATA. For more information on the solution and/or where to find the updated files, please follow the link below. You may reopen this bug report if the solution does not work for you. http://rhn.redhat.com/errata/RHBA-2005-669.html