[PATCH] hurd: Define and pass UTIME_NOW and UTIME_OMIT to new file_utimens RPC
Hello, Roland, Flávio worked on adding a file_utimens RPC, which handles nanosecond-precision utimes, as well as implementing UTIME_NOW and UTIME_OMIT, here is first the RPC definition and documentation: diff --git a/hurd/fs.defs b/hurd/fs.defs index a4a48cc..171e43f 100644 --- a/hurd/fs.defs +++ b/hurd/fs.defs @@ -371,3 +371,13 @@ routine file_get_source ( file: file_t; RPT out source: string_t); + +/* Change access and modify times with nanosecond precision */ +/* If the nanoseconds value is UTIME_NOW then the time should be + set to the current time and the remainder of the time_value_t ignored. + If the nanoseconds value is UTIME_OMIT then the time is ignored. */ +routine file_utimens ( + utimes_file: file_t; + RPT + new_atime: timespec_t; + new_mtime: timespec_t); diff --git a/doc/hurd.texi b/doc/hurd.texi index 2f36bdc..26e51e1 100644 --- a/doc/hurd.texi +++ b/doc/hurd.texi @@ -2723,6 +2723,14 @@ the file. Making this call must cause the @var{ctime} to be updated as well, even if no actual change to either the @var{mtime} or the @var{atime} occurs. +@findex file_utimens +The @code{file_utimens} RPC changes the @var{atime} and @var{mtime} of +the file with nanosecond precision. Making this call must cause the +@var{ctime} to be updated as well, even if no actual change to either the +@var{mtime} or the @var{atime} occurs. The arguments @var{atime} and +@var{mtime} follow the POSIX standard and may use the flags +@code{UTIME_OMIT} and @code{UTIME_NOW}. + @findex file_set_size The @code{file_set_size} RPC is special; not only does it change the status word specifying the size of the file, but it also changes the Any objection to this? The entailed glibc changes are below. Samuel 2015-09-20 Flávio Cruz Define and pass UTIME_NOW and UTIME_OMIT to new file_utimens RPC. * sysdeps/mach/hurd/bits/stat.h (UTIME_NOW, UTIME_OMIT): New macros. * sysdeps/mach/hurd/futimens.c (__futimens): Convert `tsp' to struct timespec to try to use the file_utimens RPC, before rolling back to using file_utimes. * sysdeps/mach/hurd/futimes (__futimes): Likewise. * sysdeps/mach/hurd/lutimes (__lutimes): Likewise. * sysdeps/mach/hurd/utimes (__utimes): Likewise. diff --git a/sysdeps/mach/hurd/bits/stat.h b/sysdeps/mach/hurd/bits/stat.h index f60a58a..c2d0cc2 100644 --- a/sysdeps/mach/hurd/bits/stat.h +++ b/sysdeps/mach/hurd/bits/stat.h @@ -246,6 +246,10 @@ struct stat64 # define SF_NOUNLINK 0x0010 /* file may not be removed or renamed */ # define SF_SNAPSHOT 0x0020 /* snapshot inode */ +/* Time flags for futimens. */ +#define UTIME_NOW -1 /* corresponds to the current time */ +#define UTIME_OMIT -2 /* target time is omitted */ + __BEGIN_DECLS /* Set file flags for FILE to FLAGS. */ diff --git a/sysdeps/mach/hurd/futimens.c b/sysdeps/mach/hurd/futimens.c index 4f82f1e..3159cb0 100644 --- a/sysdeps/mach/hurd/futimens.c +++ b/sysdeps/mach/hurd/futimens.c @@ -27,24 +27,51 @@ int __futimens (int fd, const struct timespec tsp[2]) { - time_value_t atime, mtime; + struct timespec atime, mtime; error_t err; if (tsp == NULL) { - /* Setting the number of microseconds to `-1' tells the + /* Setting the number of nanoseconds to UTIME_NOW tells the underlying filesystems to use the current time. */ - atime.microseconds = mtime.microseconds = -1; + atime.tv_sec = 0; + atime.tv_nsec = UTIME_NOW; + mtime.tv_sec = 0; + mtime.tv_nsec = UTIME_NOW; } else { - atime.seconds = tsp[0].tv_sec; - atime.microseconds = tsp[0].tv_nsec / 1000; - mtime.seconds = tsp[1].tv_sec; - mtime.microseconds = tsp[1].tv_nsec / 1000; + atime = tsp[0]; + mtime = tsp[1]; } - err = HURD_DPORT_USE (fd, __file_utimes (port, atime, mtime)); + err = HURD_DPORT_USE (fd, __file_utimens (port, atime, mtime)); + + if (err == MIG_BAD_ID || err == EOPNOTSUPP) +{ + time_value_t atim, mtim; + + if (tsp == NULL) +/* Setting the number of microseconds to `-1' tells the + underlying filesystems to use the current time. */ +atim.microseconds = mtim.microseconds = -1; + else if (tsp[0].tv_nsec == UTIME_OMIT || tsp[1].tv_nsec == UTIME_OMIT) +return EOPNOTSUPP; + else +{ + if (tsp[0].tv_nsec == UTIME_NOW) +atim.microseconds = -1; + else +TIMESPEC_TO_TIME_VALUE (&atim, &(tsp[0])); + if (tsp[1].tv_nsec == UTIME_NOW) +mtim.microseconds = -1; + else +TIMESPEC_TO_TIME_VALUE (&mtim, &(tsp[1])); +} + + err = HURD_DPORT_USE (fd, __file_utimes (port, atim, mtim)); + } + return err ? __hurd_dfail (fd, err) : 0; } weak_alias (__futimens, futimens) diff --git a/sysdeps/mach/hurd/futimes.c b/sysdeps/mach/hurd/futimes.c index c325d44..dc8ae61 100644 --- a
Re: Rolling new releases
David Michael, le Mon 12 Oct 2015 17:16:47 -0400, a écrit : > On Thu, Oct 8, 2015 at 6:18 PM, Samuel Thibault > wrote: > > David Michael, le Thu 08 Oct 2015 12:55:13 -0400, a écrit : > >> Static linking libpthread doesn't work without it. > > > > Right. Perhaps libpthread shouldn't be defining __libc_getspecific > > actually. > > Thanks for applying all those. After cherry-picking that last commit > into libpthread's master-glibc branch, I was able to build Hurd's > glibc+libpthread directly from Git without having to manually patch > anything for the first time. Groovy! Thanks for the heads-up, Samuel
Re: Rolling new releases
On Thu, Oct 8, 2015 at 6:18 PM, Samuel Thibault wrote: > David Michael, le Thu 08 Oct 2015 12:55:13 -0400, a écrit : >> Static linking libpthread doesn't work without it. > > Right. Perhaps libpthread shouldn't be defining __libc_getspecific > actually. Thanks for applying all those. After cherry-picking that last commit into libpthread's master-glibc branch, I was able to build Hurd's glibc+libpthread directly from Git without having to manually patch anything for the first time. David
Re: RFC: [PATCH] trans/fakeroot.c
Svante Signell, le Mon 12 Oct 2015 15:16:19 +0200, a écrit : > On Mon, 2015-10-12 at 15:12 +0200, Samuel Thibault wrote: > > Svante Signell, le Mon 12 Oct 2015 15:04:40 +0200, a écrit : > > > OK I buy your explanation; though there seems to be remaining bugs. > > > > Which bugs? > > You wrote it not me: > > Subsequent writes to the file will then fail (and if they don't, > that's another bug to be fixed). "If they don't" I believe they will. But perhaps in your tests they didn't (but did your tests really try that?), in which case it'd mean there is a bug. But for now nothing said there was a bug there. Samuel
Re: RFC: [PATCH] trans/fakeroot.c
On Mon, 2015-10-12 at 15:12 +0200, Samuel Thibault wrote: > Svante Signell, le Mon 12 Oct 2015 15:04:40 +0200, a écrit : > > OK I buy your explanation; though there seems to be remaining bugs. > > Which bugs? You wrote it not me: > Subsequent writes to the file will then fail (and if they don't, that's another bug to be fixed).
Re: RFC: [PATCH] trans/fakeroot.c
Svante Signell, le Mon 12 Oct 2015 15:04:40 +0200, a écrit : > OK I buy your explanation; though there seems to be remaining bugs. Which bugs? Samuel
Re: RFC: [PATCH] trans/fakeroot.c
On Mon, 2015-10-12 at 14:49 +0200, Samuel Thibault wrote: > Svante Signell, le Mon 12 Oct 2015 14:45:09 +0200, a écrit : > > On Mon, 2015-10-12 at 02:08 +0200, Samuel Thibault wrote: > > > The commit I have just pushed, which does make sense, does fix gpsd at > > > least. > Please erase your build tree and restart the build from scratch. You > probably have a remaining non-writable gpsd.udev file. Yes, I had forgotten to remove it. Thanks! > > Since the packages I've built builds fine using the condition below: > > if (file != MACH_PORT_NULL && (nn->openmodes & newmodes)) > > please explain what is wrong with it and why it works while your does > > not? > > I have explained at length how the function is supposed to behave in > my previous mail. Your proposed change does not meet what I said. > Notably, in the nn->openmodes = O_READ and newmodes = O_WRITE case, > it'll be wrong: nn->openmodes & newmodes will be zero, and thus the > 'file' port will be used as such, but it will not have O_WRITE mode! > Subsequent writes to the file will then fail (and if they don't, that's > another bug to be fixed). OK I buy your explanation; though there seems to be remaining bugs.
Re: RFC: [PATCH] trans/fakeroot.c
Samuel Thibault, le Mon 12 Oct 2015 14:49:43 +0200, a écrit : > Your proposed change does not meet what I said. > Notably, in the nn->openmodes = O_READ and newmodes = O_WRITE case, > it'll be wrong: nn->openmodes & newmodes will be zero, and thus the > 'file' port will be used as such, but it will not have O_WRITE mode! > Subsequent writes to the file will then fail (and if they don't, that's > another bug to be fixed). Grmbl, I actually meant: in the nn->openmodes = O_WRITE and newmodes = O_READ case. Samuel
Re: RFC: [PATCH] trans/fakeroot.c
Svante Signell, le Mon 12 Oct 2015 14:45:09 +0200, a écrit : > On Mon, 2015-10-12 at 02:08 +0200, Samuel Thibault wrote: > > The commit I have just pushed, which does make sense, does fix gpsd at > > least. > > Building gpsd (3.15-1) with your patch applied: > cp /home/srs/DEBs/gpsd/gpsd-3.15/gpsd.rules > /home/srs/DEBs/gpsd/gpsd-3.15/debian/gpsd.udev > cp: cannot create regular file > ‘/home/srs/DEBs/gpsd/gpsd-3.15/debian/gpsd.udev’: Permission denied Please erase your build tree and restart the build from scratch. You probably have a remaining non-writable gpsd.udev file. > Since the packages I've built builds fine using the condition below: > if (file != MACH_PORT_NULL && (nn->openmodes & newmodes)) > please explain what is wrong with it and why it works while your does > not? I have explained at length how the function is supposed to behave in my previous mail. Your proposed change does not meet what I said. Notably, in the nn->openmodes = O_READ and newmodes = O_WRITE case, it'll be wrong: nn->openmodes & newmodes will be zero, and thus the 'file' port will be used as such, but it will not have O_WRITE mode! Subsequent writes to the file will then fail (and if they don't, that's another bug to be fixed). Samuel
Re: RFC: [PATCH] trans/fakeroot.c
On Mon, 2015-10-12 at 02:08 +0200, Samuel Thibault wrote: > The commit I have just pushed, which does make sense, does fix gpsd at > least. Building gpsd (3.15-1) with your patch applied: cp /home/srs/DEBs/gpsd/gpsd-3.15/gpsd.rules /home/srs/DEBs/gpsd/gpsd-3.15/debian/gpsd.udev cp: cannot create regular file ‘/home/srs/DEBs/gpsd/gpsd-3.15/debian/gpsd.udev’: Permission denied Since the packages I've built builds fine using the condition below: if (file != MACH_PORT_NULL && (nn->openmodes & newmodes)) please explain what is wrong with it and why it works while your does not?
Re: A small change to gnumach.texi
Hello, Joshua Branson, le Fri 02 Oct 2015 13:20:12 -0400, a écrit : > I've copied the history section of mach from the wiki > (https://www.gnu.org/software/hurd/microkernel/mach/history.html) into the > gnumach/doc/mach.texi). Thanks for the idea, I'm just wondering about the copyright and/or licence. We need to make sure that it is compatible with the GFDL used by the gnumach documentation. Samuel
Re: [PATCH] hurd: align -p and -pg behavior on Linux
Hi Samuel! On Sat, 19 Sep 2015 14:00:23 +0200, Samuel Thibault wrote: > On Linux, -p and -pg do not make gcc link against libc_p.a, only > -profile does (as documented in r11246), and thus people expect -p > and -pg to work without libc_p.a installed (it is actually even not > available any more in Debian). We should thus rather make the Hurd port > do the same to avoid build failures. ACK. Thanks, I'll take care of your patch. > * gcc/config/gnu.h (LIB_SPEC) [-p|-pg]: Link with -lc instead of -lc_p. > * gcc/config/i386/gnu.h (STARTFILE_SPEC) [-p|-pg]: Use gcrt1.o > instead of gcrt0.o. > > --- gcc/config/gnu.h.orig 2015-09-16 00:43:09.785570853 +0200 > +++ gcc/config/gnu.h 2015-09-16 00:43:12.513550418 +0200 > @@ -25,7 +25,7 @@ > > /* Default C library spec. */ > #undef LIB_SPEC > -#define LIB_SPEC "%{pthread:-lpthread} %{pg|p|profile:-lc_p;:-lc}" > +#define LIB_SPEC "%{pthread:-lpthread} %{profile:-lc_p;:-lc}" > > #undef GNU_USER_TARGET_OS_CPP_BUILTINS > #define GNU_USER_TARGET_OS_CPP_BUILTINS()\ > --- gcc/config/i386/gnu.h.orig2015-09-17 21:41:13.0 + > +++ gcc/config/i386/gnu.h 2015-09-17 23:03:57.0 + > @@ -27,11 +27,11 @@ > #undef STARTFILE_SPEC > #if defined HAVE_LD_PIE > #define STARTFILE_SPEC \ > - "%{!shared: > %{pg|p|profile:gcrt0.o%s;pie:Scrt1.o%s;static:crt0.o%s;:crt1.o%s}} \ > + "%{!shared: > %{pg|p:gcrt1.o%s;profile:gcrt0.o%s;pie:Scrt1.o%s;static:crt0.o%s;:crt1.o%s}} \ > crti.o%s %{static:crtbeginT.o%s;shared|pie:crtbeginS.o%s;:crtbegin.o%s}" > #else > #define STARTFILE_SPEC \ > - "%{!shared: %{pg|p|profile:gcrt0.o%s;static:crt0.o%s;:crt1.o%s}} \ > + "%{!shared: %{pg|p:gcrt1.o%s;profile:gcrt0.o%s;static:crt0.o%s;:crt1.o%s}} > \ > crti.o%s %{static:crtbeginT.o%s;shared|pie:crtbeginS.o%s;:crtbegin.o%s}" > #endif Grüße, Thomas signature.asc Description: PGP signature