From: Clemens Buchacher Date: Sat, 12 Sep 2009 08:26:24 GMT Subject: Re: [PATCH] preserve mtime of local clone Message-ID: <20090912082624.GA9654@localhost> In-Reply-To: <7vmy50lpfr.fsf@alter.siamese.dyndns.org> On Fri, Sep 11, 2009 at 10:09:12PM -0700, Junio C Hamano wrote: > Clemens Buchacher writes: > > > +int copy_times(int ofd, int ifd) > > +{ > > + struct stat st; > > + struct timespec times[2]; > > + if (fstat(ifd, &st)) > > + return -1; > > + times[0].tv_nsec = UTIME_OMIT; > > + times[1].tv_sec = st.st_mtime; > > + times[1].tv_nsec = ST_MTIME_NSEC(st); > > + return futimens(ofd, times); > > +} > > Hmm, futimens() is relatively new. Are minority platforms folks Ok with > this patch? > > At least SunOS 5.11 (OpenSolaris 0811) seems to barf on UTIME_OMIT. If it's a problem we can use utime() instead. I was just trying to use the file descriptors, since they were available. But the patch would be a little smaller if I didn't touch copy_fd(). Clemens