On 12/29/2009 01:12 PM, Eric Blake wrote:
I couldn't find where UTIME_NOW etc. is defined, so I just pulled the values off the internet. (I am running 64 bit right now, but would assume int is still 32 bit and not ulong )-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 According to ctrn3e8 on 12/29/2009 11:58 AM:Re: touch --ref file1 -m file2 or touch -m file1 --ref file2 Does not work on ntfs-3g. See attachedThanks. That confirmed half of what I was worried about.valid/UTIME_NOW , make -k stuff I did not build coreutils from source. I have been using the Archlinux packages which are pre-built binaries. I can build and make install from source, but if I do that I probably prefer to set up a 'sandbox','make install' is further than you need. It is sufficient to do 'make' and 'make check' in-tree.It's probably a couple of hours to set up a sandbox, so if you really need it, just let me know and I will see what I can come up with.Nah, even that is overkill. All I really need is the output of this simpler program:Also would need how to get 'valid' ..I asumme coding something like utimensat(0, NULL, { {1262110412, 0},UTIME_OMIT}, 0) = 0 would work.Close, but not quite. UTIME_OMIT goes in the tv_nsec field, but as written, you would have put it in the tv_sec field. With that, here's the program I'd like you to run: #include <unistd.h> #include <stdio.h> #include <errno.h> #include <fcntl.h> int main (void) { int fd = creat ("tmp.txt", 0600); int i, j, k = 1000000000; int values[] = {0, UTIME_NOW, UTIME_OMIT}; struct stat st; fstat (fd, &st); printf ("%ld %ld %ld\n", st.st_atime, st.st_mtime, st.st_ctime); for (i = 0; i < 3; i++) for (j = 0; j < 3; j++) { struct timespec t[2] = { { k, values[i] }, { k, values[j] } }; sleep (1); futimens (fd, t); k++; fstat (fd, &st); printf (" %d %d\n", i, j); printf ("%ld %ld %ld\n", st.st_atime, st.st_mtime, st.st_ctime); } close (fd); remove ("tmp.txt"); return 0; } Here's the output on cygwin (where futimens obeys POSIX): $ ./foo 1262117237 1262117237 1262117237 0 0 1000000000 1000000000 1262117238 0 1 1000000001 1262117239 1262117239 0 2 1000000002 1262117239 1262117240 1 0 1262117241 1000000003 1262117241 1 1 1262117242 1262117242 1262117242 1 2 1262117243 1262117242 1262117243 2 0 1262117243 1000000006 1262117244 2 1 1262117243 1262117245 1262117245 2 2 1262117243 1262117245 1262117245 - -- Don't work too hard, make some time for fun as well! Eric Blake e...@byu.net -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (Cygwin) Comment: Public key at home.comcast.net/~ericblake/eblake.gpg Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAks6YqQACgkQ84KuGfSFAYDUGwCeMJ+J0U4wJqswpj2BmVW3crbw nBUAnAueZ+6/xcjDvLlUsFHgyhXjYHyl =qrn2 -----END PGP SIGNATURE----- Final modified source: #include <unistd.h> #include <stdio.h> #include <errno.h> #include <fcntl.h> #include "/usr/include/sys/stat.h" #define UTIME_NOW ((1l << 30) - 1l) #define UTIME_OMIT ((1l << 30) - 2l) main (void) { int fd = creat ("tmp.txt", 0600); int i, j, k = 1000000000; int values[] = {0, UTIME_NOW, UTIME_OMIT}; struct stat st; fstat (fd, &st); printf ("%ld %ld %ld\n", st.st_atime, st.st_mtime, st.st_ctime); for (i = 0; i < 3; i++) for (j = 0; j < 3; j++) { struct timespec t[2] = { { k, values[i] }, { k, values[j] } }; sleep (1); futimens (fd, t); k++; fstat (fd, &st); printf (" %d %d\n", i, j); printf ("%ld %ld %ld\n", st.st_atime, st.st_mtime, st.st_ctime); } close (fd); remove ("tmp.txt"); return 0; } ____________________________________________- Output on ext4: 1262151135 1262151135 1262151135 0 0 1000000000 1000000000 1262151136 0 1 1000000001 1262151137 1262151137 0 2 1000000002 1262151137 1262151138 1 0 1262151139 1000000003 1262151139 1 1 1262151140 1262151140 1262151140 1 2 1262151141 1262151140 1262151141 2 0 1262151141 1000000006 1262151142 2 1 1262151141 1262151143 1262151143 2 2 1262151141 1262151143 1262151143 __________________________________________________- Output on ntfs-3G 1262151223 1262151223 1262151223 0 0 1000000000 1000000000 1262151224 0 1 1000000001 1262151225 1262151225 0 2 1000000001 1262151225 1262151225 1 0 1262151227 1000000003 1262151227 1 1 1262151228 1262151228 1262151228 1 2 1262151228 1262151228 1262151228 2 0 1262151228 1262151228 1262151228 2 1 1262151228 1262151228 1262151228 2 2 1262151228 1262151228 1262151228 |