diff --git a/autogen.sh b/autogen.sh index ee76efc22..8c06da89c 100755 --- a/autogen.sh +++ b/autogen.sh @@ -2,7 +2,9 @@ set -e -srcdir="$(cd "$(dirname "$0")" && pwd)" +# Use backticks to support ksh on Solaris +basedir=`dirname "$0"` +srcdir=`cd "$basedir" && pwd` cd "$srcdir" diff --git a/configure.ac b/configure.ac index 12556f563..e3d89eac4 100644 --- a/configure.ac +++ b/configure.ac @@ -36,6 +36,10 @@ dnl ############################################################################ dnl Check for compiler dnl ############################################################################ +dnl This should be checked before toolchain macros, otherwise they will remember +dnl that ar cannot be found and linking via libtool will fail at a later stage +AC_CHECK_TOOLS([AR], [ar gar]) + AC_PROG_CC AM_PROG_CC_C_O @@ -211,8 +215,7 @@ dnl ############################################################################ dnl Check for other tools dnl ############################################################################ -AC_CHECK_TOOL(AR, ar, ar) -AC_CHECK_TOOL(INDENT, gindent, indent) +AC_CHECK_TOOLS([INDENT], [gindent indent]) mc_UNIT_TESTS @@ -261,7 +264,7 @@ AC_CHECK_TYPE([major_t], [], [AC_DEFINE([major_t], [int], [Type of major device AC_CHECK_TYPE([minor_t], [], [AC_DEFINE([minor_t], [int], [Type of minor device numbers.])]) AC_STRUCT_ST_BLOCKS -AC_CHECK_MEMBERS([struct stat.st_blksize, struct stat.st_rdev, struct stat.st_mtim]) +AC_CHECK_MEMBERS([struct stat.st_blksize, struct stat.st_rdev, struct stat.st_mtim, struct stat.st_mtimespec, struct stat.st_mtimensec]) gl_STAT_SIZE AH_TEMPLATE([sig_atomic_t], @@ -387,14 +390,7 @@ AC_EGREP_CPP([yes], ]) dnl utimensat is supported since glibc 2.6 and specified in POSIX.1-2008 -dnl utimensat() causes different timespec structures to cause failures on IBM i and AIX -case $host_os in -*os400 | aix*) - ;; -*) - AC_CHECK_FUNCS([utimensat]) - ;; -esac +AC_CHECK_FUNCS([utimensat]) case $host_os in *os400) diff --git a/lib/unixcompat.h b/lib/unixcompat.h index 591a709de..c5d3aac88 100644 --- a/lib/unixcompat.h +++ b/lib/unixcompat.h @@ -113,13 +113,6 @@ #define get_default_editor() "vi" #define OS_SORT_CASE_SENSITIVE_DEFAULT TRUE -/* struct stat members */ -#ifdef __APPLE__ -#define st_atim st_atimespec -#define st_ctim st_ctimespec -#define st_mtim st_mtimespec -#endif - /*** enums ***************************************************************************************/ /*** structures declarations (and typedefs of structures)*****************************************/ diff --git a/lib/vfs/direntry.c b/lib/vfs/direntry.c index 294df5f1b..b0db9145a 100644 --- a/lib/vfs/direntry.c +++ b/lib/vfs/direntry.c @@ -1030,10 +1030,7 @@ vfs_s_default_stat (struct vfs_class *me, mode_t mode) #endif st.st_size = 0; - st.st_mtime = st.st_atime = st.st_ctime = time (NULL); -#ifdef HAVE_STRUCT_STAT_ST_MTIM - st.st_atim.tv_nsec = st.st_mtim.tv_nsec = st.st_ctim.tv_nsec = 0; -#endif + vfs_zero_stat_times (&st); vfs_adjust_stat (&st); diff --git a/lib/vfs/parse_ls_vga.c b/lib/vfs/parse_ls_vga.c index dd304257b..0f8de3dc4 100644 --- a/lib/vfs/parse_ls_vga.c +++ b/lib/vfs/parse_ls_vga.c @@ -796,15 +796,14 @@ vfs_parse_ls_lga (const char *p, struct stat *s, char **filename, char **linknam #endif } + vfs_zero_stat_times (s); + idx = vfs_parse_filedate (idx, &s->st_mtime); if (idx == 0) goto error; /* Use resulting time value */ s->st_atime = s->st_ctime = s->st_mtime; -#ifdef HAVE_STRUCT_STAT_ST_MTIM - s->st_atim.tv_nsec = s->st_mtim.tv_nsec = s->st_ctim.tv_nsec = 0; -#endif /* s->st_dev and s->st_ino must be initialized by vfs_s_new_inode () */ #ifdef HAVE_STRUCT_STAT_ST_BLKSIZE diff --git a/lib/vfs/utilvfs.c b/lib/vfs/utilvfs.c index 5a9fa453b..0fb0a3cea 100644 --- a/lib/vfs/utilvfs.c +++ b/lib/vfs/utilvfs.c @@ -38,6 +38,10 @@ #include #include +#if !defined (HAVE_UTIMENSAT) && defined (HAVE_UTIME_H) +#include +#endif + #include "lib/global.h" #include "lib/unixcompat.h" #include "lib/widget.h" /* message() */ @@ -372,3 +376,102 @@ vfs_get_password (const char *msg) } /* --------------------------------------------------------------------------------------------- */ + +int +vfs_utime (const char *path, mc_timesbuf_t *times) +{ +#ifdef HAVE_UTIMENSAT + return utimensat (AT_FDCWD, path, *times, AT_SYMLINK_NOFOLLOW); +#else + return utime (path, times); +#endif +} + +/* --------------------------------------------------------------------------------------------- */ + +void +vfs_get_timespecs_from_timesbuf (mc_timesbuf_t *times, mc_timespec_t *atime, mc_timespec_t *mtime) +{ +#ifdef HAVE_UTIMENSAT + atime->tv_sec = (*times)[0].tv_sec; + atime->tv_nsec = (*times)[0].tv_nsec; + mtime->tv_sec = (*times)[1].tv_sec; + mtime->tv_nsec = (*times)[1].tv_nsec; +#else + atime->tv_sec = times->actime; + atime->tv_nsec = 0; + mtime->tv_sec = times->modtime; + mtime->tv_nsec = 0; +#endif +} + +/* --------------------------------------------------------------------------------------------- */ + +void +vfs_get_timesbuf_from_stat (const struct stat *s, mc_timesbuf_t *times) +{ +#ifdef HAVE_UTIMENSAT +#ifdef HAVE_STRUCT_STAT_ST_MTIM + /* POSIX IEEE Std 1003.1-2008 should be the preferred way + * + * AIX has internal type st_timespec_t conflicting with timespec, so assign per field, for details see: + * https://github.com/libuv/libuv/pull/4404 + */ + (*times)[0].tv_sec = s->st_atim.tv_sec; + (*times)[0].tv_nsec = s->st_atim.tv_nsec; + (*times)[1].tv_sec = s->st_mtim.tv_sec; + (*times)[1].tv_nsec = s->st_mtim.tv_nsec; +#elif HAVE_STRUCT_STAT_ST_MTIMESPEC + /* Modern BSD solution */ + (*times)[0] = s->st_atimespec; + (*times)[1] = s->st_mtimespec; +#elif HAVE_STRUCT_STAT_ST_MTIMENSEC + /* Legacy BSD solution */ + (*times)[0].tv_sec = s->st_atime; + (*times)[0].tv_nsec = s->st_atimensec; + (*times)[1].tv_sec = s->st_mtime; + (*times)[1].tv_nsec = s->st_mtimensec; +#else +#error "Found utimensat for nanosecond timestamps, but unsupported struct stat format!" +#endif +#else + times->actime = s->st_atime; + times->modtime = s->st_mtime; +#endif +} + +/* --------------------------------------------------------------------------------------------- */ + +void +vfs_copy_stat_times (const struct stat *src, struct stat *dst) +{ + dst->st_atime = src->st_atime; + dst->st_mtime = src->st_mtime; + dst->st_ctime = src->st_ctime; + +#ifdef HAVE_STRUCT_STAT_ST_MTIM + dst->st_atim.tv_nsec = src->st_atim.tv_nsec; + dst->st_mtim.tv_nsec = src->st_mtim.tv_nsec; + dst->st_ctim.tv_nsec = src->st_ctim.tv_nsec; +#elif HAVE_STRUCT_STAT_ST_MTIMESPEC + dst->st_atimespec.tv_nsec = src->st_atimespec.tv_nsec; + dst->st_mtimespec.tv_nsec = src->st_mtimespec.tv_nsec; + dst->st_ctimespec.tv_nsec = src->st_ctimespec.tv_nsec; +#elif HAVE_STRUCT_STAT_ST_MTIMENSEC + dst->st_atimensec = src->st_atimensec; + dst->st_mtimensec = src->st_mtimensec; + dst->st_ctimensec = src->st_ctimensec; +#endif +} + +/* --------------------------------------------------------------------------------------------- */ + +void +vfs_zero_stat_times (struct stat *s) +{ + const struct stat empty = { 0 }; + + vfs_copy_stat_times (&empty, s); +} + +/* --------------------------------------------------------------------------------------------- */ diff --git a/lib/vfs/utilvfs.h b/lib/vfs/utilvfs.h index 362bd55d1..ff94bdbde 100644 --- a/lib/vfs/utilvfs.h +++ b/lib/vfs/utilvfs.h @@ -60,5 +60,13 @@ size_t vfs_parse_ls_lga_get_final_spaces (void); gboolean vfs_parse_month (const char *str, struct tm *tim); int vfs_parse_filedate (int idx, time_t * t); +int vfs_utime (const char *path, mc_timesbuf_t *times); +void vfs_get_timespecs_from_timesbuf (mc_timesbuf_t *times, mc_timespec_t *atime, + mc_timespec_t *mtime); +void vfs_get_timesbuf_from_stat (const struct stat *s, mc_timesbuf_t *times); +void vfs_copy_stat_times (const struct stat *src, struct stat *dst); +void vfs_zero_stat_times (struct stat *s); + /*** inline functions ****************************************************************************/ + #endif diff --git a/lib/vfs/vfs.h b/lib/vfs/vfs.h index 0a55c98bb..55e9530ec 100644 --- a/lib/vfs/vfs.h +++ b/lib/vfs/vfs.h @@ -95,6 +95,12 @@ typedef struct timespec mc_timesbuf_t[2]; typedef struct utimbuf mc_timesbuf_t; #endif +typedef struct mc_timespec +{ + time_t tv_sec; + long tv_nsec; +} mc_timespec_t; + /*** enums ***************************************************************************************/ typedef enum diff --git a/src/filemanager/cmd.c b/src/filemanager/cmd.c index 70602db04..b1e9a0d6b 100644 --- a/src/filemanager/cmd.c +++ b/src/filemanager/cmd.c @@ -210,7 +210,7 @@ compare_files (const vfs_path_t *vpath1, const vfs_path_t *vpath2, off_t size) #else /* Don't have mmap() :( Even more ugly :) */ char buf1[BUFSIZ], buf2[BUFSIZ]; - int n1, n2; + ssize_t n1, n2; rotate_dash (TRUE); do diff --git a/src/filemanager/file.c b/src/filemanager/file.c index f7f07960c..8ded73c9d 100644 --- a/src/filemanager/file.c +++ b/src/filemanager/file.c @@ -67,6 +67,7 @@ #include "lib/strutil.h" #include "lib/util.h" #include "lib/vfs/vfs.h" +#include "lib/vfs/utilvfs.h" #include "lib/widget.h" #include "src/setup.h" @@ -927,20 +928,6 @@ check_same_file (const char *a, const struct stat *ast, const char *b, const str return TRUE; } -/* --------------------------------------------------------------------------------------------- */ - -static void -get_times (const struct stat *sb, mc_timesbuf_t *times) -{ -#ifdef HAVE_UTIMENSAT - (*times)[0] = sb->st_atim; - (*times)[1] = sb->st_mtim; -#else - times->actime = sb->st_atime; - times->modtime = sb->st_mtime; -#endif -} - /* --------------------------------------------------------------------------------------------- */ /* {{{ Query/status report routines */ @@ -1297,7 +1284,7 @@ move_file_file (const WPanel *panel, file_op_total_context_t *tctx, file_op_cont { mc_timesbuf_t times; - get_times (&src_stat, ×); + vfs_get_timesbuf_from_stat (&src_stat, ×); mc_utime (dst_vpath, ×); } goto retry_src_remove; @@ -2375,7 +2362,7 @@ copy_file_file (file_op_total_context_t *tctx, file_op_context_t *ctx, } } - get_times (&src_stat, ×); + vfs_get_timesbuf_from_stat (&src_stat, ×); if (!ctx->do_append) { @@ -3232,7 +3219,7 @@ copy_dir_dir (file_op_total_context_t *tctx, file_op_context_t *ctx, const char if (attrs_ok) mc_fsetflags (dst_vpath, attrs); - get_times (&src_stat, ×); + vfs_get_timesbuf_from_stat (&src_stat, ×); mc_utime (dst_vpath, ×); } else diff --git a/src/vfs/cpio/cpio.c b/src/vfs/cpio/cpio.c index f14443f36..035876e7b 100644 --- a/src/vfs/cpio/cpio.c +++ b/src/vfs/cpio/cpio.c @@ -470,15 +470,8 @@ cpio_create_entry (struct vfs_class *me, struct vfs_s_super *super, struct stat entry->ino->st.st_mode = st->st_mode; entry->ino->st.st_uid = st->st_uid; entry->ino->st.st_gid = st->st_gid; -#ifdef HAVE_STRUCT_STAT_ST_MTIM - entry->ino->st.st_atim = st->st_atim; - entry->ino->st.st_mtim = st->st_mtim; - entry->ino->st.st_ctim = st->st_ctim; -#else - entry->ino->st.st_atime = st->st_atime; - entry->ino->st.st_mtime = st->st_mtime; - entry->ino->st.st_ctime = st->st_ctime; -#endif + + vfs_copy_stat_times (st, &entry->ino->st); } g_free (name); @@ -603,9 +596,9 @@ cpio_read_bin_head (struct vfs_class *me, struct vfs_s_super *super) st.st_rdev = u.buf.c_rdev; #endif st.st_size = ((off_t) u.buf.c_filesizes[0] << 16) | u.buf.c_filesizes[1]; -#ifdef HAVE_STRUCT_STAT_ST_MTIM - st.st_atim.tv_nsec = st.st_mtim.tv_nsec = st.st_ctim.tv_nsec = 0; -#endif + + vfs_zero_stat_times (&st); + st.st_atime = st.st_mtime = st.st_ctime = ((time_t) u.buf.c_mtimes[0] << 16) | u.buf.c_mtimes[1]; @@ -676,9 +669,8 @@ cpio_read_oldc_head (struct vfs_class *me, struct vfs_s_super *super) u.st.st_rdev = hd.c_rdev; #endif u.st.st_size = hd.c_filesize; -#ifdef HAVE_STRUCT_STAT_ST_MTIM - u.st.st_atim.tv_nsec = u.st.st_mtim.tv_nsec = u.st.st_ctim.tv_nsec = 0; -#endif + + vfs_zero_stat_times (&u.st); u.st.st_atime = u.st.st_mtime = u.st.st_ctime = hd.c_mtime; return cpio_create_entry (me, super, &u.st, name); @@ -757,9 +749,8 @@ cpio_read_crc_head (struct vfs_class *me, struct vfs_s_super *super) u.st.st_rdev = makedev (hd.c_rdev, hd.c_rdevmin); #endif u.st.st_size = hd.c_filesize; -#ifdef HAVE_STRUCT_STAT_ST_MTIM - u.st.st_atim.tv_nsec = u.st.st_mtim.tv_nsec = u.st.st_ctim.tv_nsec = 0; -#endif + + vfs_zero_stat_times (&u.st); u.st.st_atime = u.st.st_mtime = u.st.st_ctime = hd.c_mtime; return cpio_create_entry (me, super, &u.st, name); diff --git a/src/vfs/extfs/extfs.c b/src/vfs/extfs/extfs.c index 2e8522795..279c7f15a 100644 --- a/src/vfs/extfs/extfs.c +++ b/src/vfs/extfs/extfs.c @@ -1230,15 +1230,22 @@ extfs_closedir (void *data) static void extfs_stat_move (struct stat *buf, const struct vfs_s_inode *inode) { + const time_t atime = inode->st.st_atime; + const time_t mtime = inode->st.st_mtime; + const time_t ctime = inode->st.st_ctime; + *buf = inode->st; #ifdef HAVE_STRUCT_STAT_ST_BLKSIZE buf->st_blksize = RECORDSIZE; #endif + vfs_adjust_stat (buf); -#ifdef HAVE_STRUCT_STAT_ST_MTIM - buf->st_atim.tv_nsec = buf->st_mtim.tv_nsec = buf->st_ctim.tv_nsec = 0; -#endif + vfs_zero_stat_times (buf); + + buf->st_atime = atime; + buf->st_mtime = mtime; + buf->st_ctime = ctime; } /* --------------------------------------------------------------------------------------------- */ diff --git a/src/vfs/local/local.c b/src/vfs/local/local.c index 88450a568..337646508 100644 --- a/src/vfs/local/local.c +++ b/src/vfs/local/local.c @@ -26,6 +26,7 @@ */ #include + #include #include #include @@ -217,16 +218,7 @@ local_fsetflags (const vfs_path_t *vpath, unsigned long flags) static int local_utime (const vfs_path_t *vpath, mc_timesbuf_t *times) { - int ret; - const char *path; - - path = vfs_path_get_last_path_str (vpath); -#ifdef HAVE_UTIMENSAT - ret = utimensat (AT_FDCWD, path, *times, AT_SYMLINK_NOFOLLOW); -#else - ret = utime (path, times); -#endif - return ret; + return vfs_utime (vfs_path_get_last_path_str (vpath), times); } /* --------------------------------------------------------------------------------------------- */ diff --git a/src/vfs/sfs/sfs.c b/src/vfs/sfs/sfs.c index c7107f5d5..e3be15f35 100644 --- a/src/vfs/sfs/sfs.c +++ b/src/vfs/sfs/sfs.c @@ -349,11 +349,7 @@ sfs_chown (const vfs_path_t *vpath, uid_t owner, gid_t group) static int sfs_utime (const vfs_path_t *vpath, mc_timesbuf_t *times) { -#ifdef HAVE_UTIMENSAT - return utimensat (AT_FDCWD, sfs_redirect (vpath), *times, 0); -#else - return utime (sfs_redirect (vpath), times); -#endif + return vfs_utime (sfs_redirect (vpath), times); } /* --------------------------------------------------------------------------------------------- */ diff --git a/src/vfs/sftpfs/internal.c b/src/vfs/sftpfs/internal.c index a229de403..b94668d96 100644 --- a/src/vfs/sftpfs/internal.c +++ b/src/vfs/sftpfs/internal.c @@ -37,6 +37,7 @@ #include "lib/global.h" #include "lib/util.h" +#include "lib/vfs/utilvfs.h" #include "internal.h" @@ -255,12 +256,10 @@ sftpfs_attr_to_stat (const LIBSSH2_SFTP_ATTRIBUTES *attrs, struct stat *s) if ((attrs->flags & LIBSSH2_SFTP_ATTR_ACMODTIME) != 0) { + vfs_zero_stat_times (s); s->st_atime = attrs->atime; s->st_mtime = attrs->mtime; s->st_ctime = attrs->mtime; -#ifdef HAVE_STRUCT_STAT_ST_MTIM - s->st_atim.tv_nsec = s->st_mtim.tv_nsec = s->st_ctim.tv_nsec = 0; -#endif } if ((attrs->flags & LIBSSH2_SFTP_ATTR_SIZE) != 0) diff --git a/src/vfs/sftpfs/sftpfs.c b/src/vfs/sftpfs/sftpfs.c index fcc93470e..e3936a310 100644 --- a/src/vfs/sftpfs/sftpfs.c +++ b/src/vfs/sftpfs/sftpfs.c @@ -336,16 +336,11 @@ sftpfs_cb_utime (const vfs_path_t *vpath, mc_timesbuf_t *times) { int rc; GError *mcerror = NULL; + mc_timespec_t atime, mtime; -#ifdef HAVE_UTIMENSAT - time_t atime = (*times)[0].tv_sec; - time_t mtime = (*times)[1].tv_sec; -#else - time_t atime = times->actime; - time_t mtime = times->modtime; -#endif + vfs_get_timespecs_from_timesbuf (times, &atime, &mtime); + rc = sftpfs_utime (vpath, atime.tv_sec, mtime.tv_sec, &mcerror); - rc = sftpfs_utime (vpath, atime, mtime, &mcerror); mc_error_message (&mcerror, NULL); return rc; } diff --git a/src/vfs/shell/shell.c b/src/vfs/shell/shell.c index 96fe4fcf5..f4133771a 100644 --- a/src/vfs/shell/shell.c +++ b/src/vfs/shell/shell.c @@ -860,12 +860,10 @@ shell_parse_ls (char *buffer, struct vfs_s_entry *ent) case 'd': vfs_split_text (buffer); + vfs_zero_stat_times (&ST); if (vfs_parse_filedate (0, &ST.st_ctime) == 0) break; ST.st_atime = ST.st_mtime = ST.st_ctime; -#ifdef HAVE_STRUCT_STAT_ST_MTIM - ST.st_atim.tv_nsec = ST.st_mtim.tv_nsec = ST.st_ctim.tv_nsec = 0; -#endif break; case 'D': @@ -877,10 +875,8 @@ shell_parse_ls (char *buffer, struct vfs_s_entry *ent) if (sscanf (buffer, "%d %d %d %d %d %d", &tim.tm_year, &tim.tm_mon, &tim.tm_mday, &tim.tm_hour, &tim.tm_min, &tim.tm_sec) != 6) break; + vfs_zero_stat_times (&ST); ST.st_atime = ST.st_mtime = ST.st_ctime = mktime (&tim); -#ifdef HAVE_STRUCT_STAT_ST_MTIM - ST.st_atim.tv_nsec = ST.st_mtim.tv_nsec = ST.st_ctim.tv_nsec = 0; -#endif } break; @@ -1451,41 +1447,12 @@ shell_chown (const vfs_path_t *vpath, uid_t owner, gid_t group) /* --------------------------------------------------------------------------------------------- */ -static void -shell_get_atime (mc_timesbuf_t *times, time_t *sec, long *nsec) -{ -#ifdef HAVE_UTIMENSAT - *sec = (*times)[0].tv_sec; - *nsec = (*times)[0].tv_nsec; -#else - *sec = times->actime; - *nsec = 0; -#endif -} - -/* --------------------------------------------------------------------------------------------- */ - -static void -shell_get_mtime (mc_timesbuf_t *times, time_t *sec, long *nsec) -{ -#ifdef HAVE_UTIMENSAT - *sec = (*times)[1].tv_sec; - *nsec = (*times)[1].tv_nsec; -#else - *sec = times->modtime; - *nsec = 0; -#endif -} - -/* --------------------------------------------------------------------------------------------- */ - static int shell_utime (const vfs_path_t *vpath, mc_timesbuf_t *times) { char utcatime[16], utcmtime[16]; char utcatime_w_nsec[30], utcmtime_w_nsec[30]; - time_t atime, mtime; - long atime_nsec, mtime_nsec; + mc_timespec_t atime, mtime; struct tm *gmt; const char *crpath; char *rpath; @@ -1499,31 +1466,32 @@ shell_utime (const vfs_path_t *vpath, mc_timesbuf_t *times) rpath = str_shell_escape (crpath); - shell_get_atime (times, &atime, &atime_nsec); - gmt = gmtime (&atime); + vfs_get_timespecs_from_timesbuf (times, &atime, &mtime); + + gmt = gmtime (&atime.tv_sec); g_snprintf (utcatime, sizeof (utcatime), "%04d%02d%02d%02d%02d.%02d", gmt->tm_year + 1900, gmt->tm_mon + 1, gmt->tm_mday, gmt->tm_hour, gmt->tm_min, gmt->tm_sec); g_snprintf (utcatime_w_nsec, sizeof (utcatime_w_nsec), "%04d-%02d-%02d %02d:%02d:%02d.%09ld", gmt->tm_year + 1900, gmt->tm_mon + 1, gmt->tm_mday, - gmt->tm_hour, gmt->tm_min, gmt->tm_sec, atime_nsec); + gmt->tm_hour, gmt->tm_min, gmt->tm_sec, atime.tv_nsec); - shell_get_mtime (times, &mtime, &mtime_nsec); - gmt = gmtime (&mtime); + gmt = gmtime (&mtime.tv_sec); g_snprintf (utcmtime, sizeof (utcmtime), "%04d%02d%02d%02d%02d.%02d", gmt->tm_year + 1900, gmt->tm_mon + 1, gmt->tm_mday, gmt->tm_hour, gmt->tm_min, gmt->tm_sec); g_snprintf (utcmtime_w_nsec, sizeof (utcmtime_w_nsec), "%04d-%02d-%02d %02d:%02d:%02d.%09ld", gmt->tm_year + 1900, gmt->tm_mon + 1, gmt->tm_mday, - gmt->tm_hour, gmt->tm_min, gmt->tm_sec, mtime_nsec); + gmt->tm_hour, gmt->tm_min, gmt->tm_sec, mtime.tv_nsec); me = VFS_CLASS (vfs_path_get_last_path_vfs (vpath)); ret = shell_send_command (me, super, OPT_FLUSH, SHELL_SUPER (super)->scr_utime, - "SHELL_FILENAME=%s SHELL_FILEATIME=%ld SHELL_FILEMTIME=%ld " + "SHELL_FILENAME=%s SHELL_FILEATIME=%ju SHELL_FILEMTIME=%ju " "SHELL_TOUCHATIME=%s SHELL_TOUCHMTIME=%s SHELL_TOUCHATIME_W_NSEC=\"%s\" " - "SHELL_TOUCHMTIME_W_NSEC=\"%s\";\n", rpath, (long) atime, - (long) mtime, utcatime, utcmtime, utcatime_w_nsec, utcmtime_w_nsec); + "SHELL_TOUCHMTIME_W_NSEC=\"%s\";\n", rpath, (uintmax_t) atime.tv_sec, + (uintmax_t) mtime.tv_sec, utcatime, utcmtime, utcatime_w_nsec, + utcmtime_w_nsec); g_free (rpath); diff --git a/src/vfs/undelfs/undelfs.c b/src/vfs/undelfs/undelfs.c index 629261273..d8cefcded 100644 --- a/src/vfs/undelfs/undelfs.c +++ b/src/vfs/undelfs/undelfs.c @@ -631,12 +631,12 @@ undelfs_stat_int (int inode_index, struct stat *buf) buf->st_uid = delarray[inode_index].uid; buf->st_gid = delarray[inode_index].gid; buf->st_size = delarray[inode_index].size; + + vfs_zero_stat_times (buf); buf->st_atime = delarray[inode_index].dtime; buf->st_ctime = delarray[inode_index].dtime; buf->st_mtime = delarray[inode_index].dtime; -#ifdef HAVE_STRUCT_STAT_ST_MTIM - buf->st_atim.tv_nsec = buf->st_mtim.tv_nsec = buf->st_ctim.tv_nsec = 0; -#endif + return 0; } diff --git a/tests/lib/vfs/vfs_parse_ls_lga.c b/tests/lib/vfs/vfs_parse_ls_lga.c index 316de8f96..4867adafb 100644 --- a/tests/lib/vfs/vfs_parse_ls_lga.c +++ b/tests/lib/vfs/vfs_parse_ls_lga.c @@ -106,10 +106,7 @@ message (int flags, const char *title, const char *text, ...) static void fill_stat_struct (struct stat *etalon_stat, int iterator) { - -#ifdef HAVE_STRUCT_STAT_ST_MTIM - etalon_stat->st_atim.tv_nsec = etalon_stat->st_mtim.tv_nsec = etalon_stat->st_ctim.tv_nsec = 0; -#endif + vfs_zero_stat_times (etalon_stat); switch (iterator) {