2007-02-12 07:27:10

by Jeff Chua

[permalink] [raw]
Subject: [QUESTION] file access time in millisecond?

Is it possible to get file access time in millisecond resolution?

stat() returns time in seconds, but gettimeofday() can returns microseconds.


Thanks,
Jeff.


2007-02-12 08:01:05

by Arjan van de Ven

[permalink] [raw]
Subject: Re: [QUESTION] file access time in millisecond?

On Mon, 2007-02-12 at 15:27 +0800, Jeff Chua wrote:
> Is it possible to get file access time in millisecond resolution?
>
> stat() returns time in seconds, but gettimeofday() can returns microseconds.

see the "utimes()" function


2007-02-12 08:02:15

by Andi Kleen

[permalink] [raw]
Subject: Re: [QUESTION] file access time in millisecond?

"Jeff Chua" <[email protected]> writes:

> Is it possible to get file access time in millisecond resolution?
>
> stat() returns time in seconds,

Not correct (at least for glibc stat). It supports nanoseconds these days,
although not all file systems (including ext3) do yet.

Some of the old stat compat emulations do not.

-Andi

2007-02-12 09:24:48

by Jeff Chua

[permalink] [raw]
Subject: Re: [QUESTION] file access time in millisecond?

On 2/12/07, Arjan van de Ven <[email protected]> wrote:

> see the "utimes()" function

Arjan,

I checked the man page, and it says ...

utime, utimes - change access and/or modification times of an inode

I just want to "read" the access time, and not changing it.

Thanks,

Jeff.

2007-02-12 09:52:09

by Jeff Chua

[permalink] [raw]
Subject: Re: [QUESTION] file access time in millisecond?

On 12 Feb 2007 10:02:28 +0100, Andi Kleen <[email protected]> wrote:

> > stat() returns time in seconds,
>
> Not correct (at least for glibc stat). It supports nanoseconds these days,
> although not all file systems (including ext3) do yet.

I'm using gcc-3.4.5, and glibc-2.3.6. Don't think 2.3.6 stat() support
that ... at least the man page doesn't indicate so.

Does that mean it's time to upgrade to glibc-2.5? or what's version
should I use?

I'm worry it'll break oracle, cups, mozilla or something else.

Thanks,
Jeff.

2007-02-12 09:56:10

by Andi Kleen

[permalink] [raw]
Subject: Re: [QUESTION] file access time in millisecond?

On Monday 12 February 2007 10:52, Jeff Chua wrote:
> On 12 Feb 2007 10:02:28 +0100, Andi Kleen <[email protected]> wrote:
>
> > > stat() returns time in seconds,
> >
> > Not correct (at least for glibc stat). It supports nanoseconds these days,
> > although not all file systems (including ext3) do yet.
>
> I'm using gcc-3.4.5, and glibc-2.3.6. Don't think 2.3.6 stat() support
> that ...

It should be always available in padding, even on older glibc. Given a sufficiently
new kernel. The bigger problem is getting a file system that supports it.

> at least the man page doesn't indicate so.

Manpages are often outdated.

-Andi

2007-02-12 10:15:06

by Miquel van Smoorenburg

[permalink] [raw]
Subject: Re: [QUESTION] file access time in millisecond?

In article <[email protected]>,
Jeff Chua <[email protected]> wrote:
>On 12 Feb 2007 10:02:28 +0100, Andi Kleen <[email protected]> wrote:
>
>> > stat() returns time in seconds,
>>
>> Not correct (at least for glibc stat). It supports nanoseconds these days,
>> although not all file systems (including ext3) do yet.
>
>I'm using gcc-3.4.5, and glibc-2.3.6. Don't think 2.3.6 stat() support
>that ... at least the man page doesn't indicate so.

Check out /usr/include/bits/stat.h

My glibc-2.3.2 (debian stable) has the nanoseconds stuff right there,
even though it isn't mentioned in the stat.2 manpage or the info pages.

Mike.

2007-02-12 18:55:43

by Jeff Chua

[permalink] [raw]
Subject: Re: [QUESTION] file access time in millisecond?

On 2/12/07, Andi Kleen <[email protected]> wrote:

> It should be always available in padding, even on older glibc. Given a sufficiently
> new kernel. The bigger problem is getting a file system that supports it.
> Manpages are often outdated.

Andi,

Ok, found it. Thanks. You're right. ext2, reiserfs doesn't support it.
I was trying to get down to find out which file got generated first
and thought stat() would do the job, but didn't realize that it's not
so simply. Oh well.

Thanks,
Jeff.

2007-02-12 18:58:21

by Jeff Chua

[permalink] [raw]
Subject: Re: [QUESTION] file access time in millisecond?

On 12 Feb 2007 10:01:24 GMT, Miquel van Smoorenburg <[email protected]>

> Check out /usr/include/bits/stat.h

Mike,

Thanks for the pointer. Got it. But as I mentioned to Andi, it doesn't
work with my filesystems (ext2, reiserfs). But at least it save me
from upgrading my glibc!


Thanks,
Jeff.