[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: ``struct stat'' issue
From: |
Samuel Thibault |
Subject: |
Re: ``struct stat'' issue |
Date: |
Mon, 11 Jun 2007 02:35:14 +0200 |
User-agent: |
Mutt/1.5.12-2006-07-14 |
Hi,
Thomas Schwinge, le Sun 10 Jun 2007 23:35:20 +0200, a écrit :
> What about the `st_?time_usec' symbols? Linux has these as `st_?timensec'.
I'd say we should stick to Linux. As was discussed, making a binary move
from usecs to nsecs shouldn't be a problem provided that we upgrade all
users of these together (i.e. hurd servers and glibc).
> Index: sysdeps/mach/hurd/xstatconv.c
> ===================================================================
> RCS file: /cvs/glibc/libc/sysdeps/mach/hurd/xstatconv.c,v
> retrieving revision 1.4
> diff -u -p -r1.4 xstatconv.c
> --- sysdeps/mach/hurd/xstatconv.c 11 Jun 2002 23:03:14 -0000 1.4
> +++ sysdeps/mach/hurd/xstatconv.c 13 Jun 2006 13:57:55 -0000
> @@ -42,12 +42,18 @@ xstat64_conv (struct stat *buf, const st
> buf->st_uid = buf64->st_uid;
> buf->st_gid = buf64->st_gid;
> buf->st_size = buf64->st_size;
> +#ifdef __USE_MISC /* TODO. Hm. */
This doesn't make sense indeed. __USE_MISC is for the application
headers to choose the right interface. In the implementation (glibc),
you just have to provide a binary interface that will work fine in all
situations.
Now, I don't know for sure which code between
> + buf->st_atim = buf64->st_atim;
> + buf->st_mtim = buf64->st_mtim;
> + buf->st_ctim = buf64->st_ctim;
> buf->st_atime = buf64->st_atime;
> buf->st_atime_usec = buf64->st_atime_usec;
> buf->st_mtime = buf64->st_mtime;
> buf->st_mtime_usec = buf64->st_mtime_usec;
> buf->st_ctime = buf64->st_ctime;
> buf->st_ctime_usec = buf64->st_ctime_usec;
actually compiles (i.e. whether the glibc compilation flags defines
_BSD_SOURCE or _SVID_SOURCE for making features.h define __USE_MISC),
but only the code that works should be kept (I bet for the first one).
> #v+
> Index: console/console.c
> ===================================================================
> RCS file: /cvsroot/hurd/hurd/console/console.c,v
> retrieving revision 1.23
> diff -u -p -r1.23 console.c
> --- console/console.c 23 Jan 2006 22:19:13 -0000 1.23
> +++ console/console.c 30 Mar 2007 15:52:56 -0000
> @@ -501,16 +501,24 @@ netfs_attempt_utimes (struct iouser *cre
> {
> if (mtime)
> {
> +#if __USE_MISC
> + node->nn_stat.st_mtim = *mtime;
> +#else
> node->nn_stat.st_mtime = mtime->tv_sec;
> node->nn_stat.st_mtime_usec = mtime->tv_nsec / 1000;
> +#endif
It's the dual problem here: we are in a application, we shouldn't
ever have a look at __USE_MISC. So either we keep using st_time
and st_mtime_usec (sorta GNU-ish extended interface), or we define
_BSD_SOURCE before including sys/stat.h and then we can use st_mtim
(BSD/SYSV-ish interface).
And last but not least, there's a bit of a mess with usec/nsec: the
code above for instance still puts usec in the second field, while we
want to move to nsecs... __USE_MISC is just for choosing a programming
interface, the underlying binary interface mustn't change.
Samuel