Detection of case senstive filenames

From: John Ulvr
Date: Fri May 29 2015 - 14:55:14 EST


There are several files in Linux whose names only differ by capitalization. This has caused us some support issues due to third party filesystems/revision control systems, which overwrite the wrong file, causing non-obvious compilation errors. I recently added a more obvious compile time failure to some of these files to reduce the number of support calls we get on the subject. I thought I'd bring it up in case someone thinks it might be a good idea to move this to the mainstream kernel. The code is:

/* if your compiler generates an error here, it is likely due to a filename-capitalization error, caused by a case-insensitive filesystem or revision control system */
#define __CHECK_FILENAME(filename) \
static int __checkfname __attribute__((unused)) = (1/((__builtin_strcmp((__FILE__ + __builtin_strlen(__FILE__) - __builtin_strlen(filename)), filename))?0:1))
__CHECK_FILENAME("xt_dscp.c");

(This would appear at the bottom of xt_DSCP.c, xt_dscp.c, etc. in global scope). While not overly pretty, it does point out what the actual error is, and doesn't have any side-effects. If there's interest, let me know and I can try to push it upstream.


John

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/