From 68aace4054430105ceaf52ce8e316f3ae01e7dc8 Mon Sep 17 00:00:00 2001 From: Rod Widdowson Date: Thu, 28 Oct 2010 18:34:41 +0100 Subject: [PATCH] Windows: fix built in touch Recent versions of windows add a whole bunch of attributes above A_ARCH. (FILE_ATTRIBUTE_NOT_CONTENT_INDEXED was what bit be but encryption of compression would do it). This makes ~_A_ARCH not a good choice for testing nonwritability of a file - so files with these new attributes just get silently ignored. Using an explicit mask is much better. So do that. Change-Id: Ie176ffae1995dd50c70319e196c0d30420733ccf Reviewed-on: http://gerrit.openafs.org/3182 Reviewed-by: Derrick Brashear Tested-by: Derrick Brashear --- src/config/touch.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/config/touch.c b/src/config/touch.c index e6e20cd..6644105 100644 --- a/src/config/touch.c +++ b/src/config/touch.c @@ -25,6 +25,14 @@ usage() exit(1); } +/* + * Construct the mask explicitly. Later versions of windows start filling + * in higher bits and that doesn't affect the operation + */ + +#define ATTRIBUTE_MASK (_A_RDONLY | _A_HIDDEN | _A_SYSTEM | _A_SUBDIR) + + int main(int argc, char *argv[]) { @@ -40,7 +48,7 @@ main(int argc, char *argv[]) return 0; do { - if ((finfo.attrib & ~_A_ARCH) != _A_NORMAL) + if ((finfo.attrib & ATTRIBUTE_MASK) != _A_NORMAL) continue; fh = _open(finfo.name, _S_IWRITE | _O_BINARY | _S_IREAD | _O_RDWR); pos = _lseek(fh, 0L, SEEK_END); -- 1.9.4