From 5c91c3a8484997ab21922bbf6a9307466805f3be Mon Sep 17 00:00:00 2001 From: Frank Lahm Date: Thu, 14 Oct 2010 11:14:47 +0200 Subject: [PATCH] Portability fixes --- bin/ad/ad.h | 7 +++++++ bin/ad/ad_cp.c | 5 +++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/bin/ad/ad.h b/bin/ad/ad.h index b8941e69..53869e0d 100644 --- a/bin/ad/ad.h +++ b/bin/ad/ad.h @@ -28,6 +28,13 @@ #define DIR_DOT_OR_DOTDOT(a) \ ((strcmp(a, ".") == 0) || (strcmp(a, "..") == 0)) +#ifndef TIMESPEC_TO_TIMEVAL +#define TIMESPEC_TO_TIMEVAL(tv, ts) { \ + (tv)->tv_sec = (ts)->tv_sec; \ + (tv)->tv_usec = (ts)->tv_nsec / 1000; \ + } +#endif + enum logtype {STD, DBG}; #define SLOG(...) \ diff --git a/bin/ad/ad_cp.c b/bin/ad/ad_cp.c index b7596fdf..15fc3ba5 100644 --- a/bin/ad/ad_cp.c +++ b/bin/ad/ad_cp.c @@ -59,6 +59,7 @@ #include #include #include +#include #include #include @@ -829,8 +830,8 @@ static int setfile(const struct stat *fs, int fd) TIMESPEC_TO_TIMEVAL(&tv[0], &fs->st_atim); TIMESPEC_TO_TIMEVAL(&tv[1], &fs->st_mtim); - if (islink ? lutimes(to.p_path, tv) : utimes(to.p_path, tv)) { - SLOG("%sutimes: %s", islink ? "l" : "", to.p_path); + if (utimes(to.p_path, tv)) { + SLOG("utimes: %s", to.p_path); rval = 1; } if (fdval ? fstat(fd, &ts) : -- 2.39.2