lovely ... looks like Darwin fails at life when it comes to respecting
POSIX and open() with O_TRUNC and a 0 byte file ... in particular,
this statement:
http://www.opengroup.org/onlinepubs/009695399/functions/open.html
If O_TRUNC is set and the file did previously exist, upon successful
completion, open() shall mark for update the st_ctime and st_mtime
fields of the file.
on OS X, if the file is 0 bytes and the file is opened with O_TRUNC,
it only updates st_ctime ... if the file is more than 0 bytes, then it
will correctly updated st_ctime and st_mtime ... ive attached my test
case if anyone is interested
the machine i'm testing on:
$ uname -a
Darwin Blackfin-Linux-Mac-Mini.local 8.9.0 Darwin Kernel Version
8.9.0: Thu Feb 22 20:54:07 PST 2007; root:xnu-792.17.14~1/RELEASE_PPC
Power Macintosh powerpc
the filesystem is default OS X HFS+ with case sensitivity enabled
i hate to ask this, but would you consider adding an unlink() or a
write() to conf_split_config() in scripts/kconfig/confdata.c ? if you
want to tell me to blow it out my ass, that's OK :)
Signed-off-by: Mike Frysinger <[EMAIL PROTECTED]>
---
--- a/scripts/kconfig/confdata.c
+++ b/scripts/kconfig/confdata.c
@@ -607,6 +607,7 @@ int conf_split_config(void)
strcpy(d, ".h");
/* Assume directory path already exists. */
+ unlink(path); /* hack for non-POSIX compliant systems (Darwin)
*/
fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, 0644);
if (fd == -1) {
if (errno != ENOENT) {
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <assert.h>
void timestest(size_t num_bytes)
{
const char *tempfile = "MOO_MOO";
struct stat st1, st2;
int fd, ret;
/* punt the file and then create a 0 byte file and get its times */
printf("getting first times ...\n");
unlink(tempfile);
fd = open(tempfile, O_WRONLY | O_CREAT | O_TRUNC, 0644);
assert(fd >= 0);
if (num_bytes)
write(fd, tempfile, num_bytes);
close(fd);
ret = stat(tempfile, &st1);
assert(ret == 0);
/* sleep a little to make there is a difference in the times */
printf("sleeping for three seconds ...\n");
sleep(3);
/* open the file again and grab the new file times */
printf("getting second times ...\n");
fd = open(tempfile, O_WRONLY | O_CREAT | O_TRUNC, 0644);
assert(fd >= 0);
close(fd);
ret = stat(tempfile, &st2);
assert(ret == 0);
unlink(tempfile);
/* each of these should be different (except for atime if you
* mount your filesystem with atime turned off)
*/
#define comp(member) (st1.member == st2.member ? "same" : "diff")
printf("the following times should all be different\n(atime can be the same if you have filesystem mounted noatime)\n");
printf("atime: %lu vs %lu (%s)\n"
"mtime: %lu vs %lu (%s)\n"
"ctime: %lu vs %lu (%s)\n",
st1.st_atime, st2.st_atime, comp(st_atime),
st1.st_mtime, st2.st_mtime, comp(st_mtime),
st1.st_ctime, st2.st_ctime, comp(st_ctime));
printf("\n");
}
int main(int argc, char *argv[])
{
printf("testing truncation with a 0 byte file\n");
timestest(0);
printf("testing truncation with a 4 byte file\n");
timestest(4);
return 0;
}
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
kbuild-devel mailing list
kbuild-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kbuild-devel