[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: touch
From: |
Eric Blake |
Subject: |
Re: touch |
Date: |
Tue, 29 Dec 2009 13:12:20 -0700 |
User-agent: |
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.23) Gecko/20090812 Thunderbird/2.0.0.23 Mnenhy/0.7.6.666 |
-----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 attached
Thanks. 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 address@hidden
-----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-----