[PATCH] Execution bit detection fixes for VFAT on Linux
Rafael Villar Burke
pachi at rvburke.com
Thu Oct 4 23:53:48 UTC 2007
# HG changeset patch
# User Rafael Villar Burke <pachi at rvburke.com>
# Date 1191541973 -7200
# Node ID 8cef14344feb4f91139750527a9be0b298e56d40
# Parent 61462e7d62ed154074f155fd6e75d2a3d1844814
Execution bit detection fixes for VFAT on Linux
On Linux VFAT execution mode can be modified, but changes don't persist
a filesy
stem remount. The current test can be trickled by this. We can help with
the det
ection of VFAT checking whether new files get created with the execution
bits on
(as usually these partitions are mounted with the exec option, for
convenience)
.
diff -r 61462e7d62ed -r 8cef14344feb mercurial/util.py
--- a/mercurial/util.py Wed Oct 03 17:17:28 2007 -0500
+++ b/mercurial/util.py Fri Oct 05 01:52:53 2007 +0200
@@ -851,16 +851,20 @@ def checkexec(path):
Requires a directory (like /foo/.hg)
"""
try:
+ EXECFLAGS = stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH
fh, fn = tempfile.mkstemp("", "", path)
os.close(fh)
m = os.stat(fn).st_mode
- os.chmod(fn, m ^ 0111)
- r = (os.stat(fn).st_mode != m)
+ # VFAT on Linux can flip mode but it doesn't persist a FS remount.
+ # frequently we can detect it if files are created with exec
bit on.
+ new_file_has_exec = m & EXECFLAGS
+ os.chmod(fn, m ^ EXECFLAGS)
+ exec_flags_cannot_flip = (os.stat(fn).st_mode == m)
os.unlink(fn)
except (IOError,OSError):
# we don't care, the user probably won't be able to commit anyway
return False
- return r
+ return not (new_file_has_exec or exec_flags_cannot_flip)
def execfunc(path, fallback):
'''return an is_exec() function with default to fallback'''
More information about the Mercurial-devel
mailing list