Merge branch '3821_init_st_mtim'

This commit is contained in:
Yury V. Zaytsev 2017-05-17 21:19:10 +02:00
commit b088459e0e
11 changed files with 61 additions and 1 deletions

View File

@ -181,7 +181,7 @@ AC_TYPE_PID_T
AC_TYPE_UID_T
AC_STRUCT_ST_BLOCKS
AC_CHECK_MEMBERS([struct stat.st_blksize, struct stat.st_rdev])
AC_CHECK_MEMBERS([struct stat.st_blksize, struct stat.st_rdev, struct stat.st_mtim])
gl_STAT_SIZE
AH_TEMPLATE([sig_atomic_t],

View File

@ -976,7 +976,11 @@ vfs_s_default_stat (struct vfs_class *me, mode_t mode)
st.st_blksize = 512;
#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_adjust_stat (&st);

View File

@ -809,6 +809,10 @@ vfs_parse_ls_lga (const char *p, struct stat * s, char **filename, char **linkna
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
s->st_blksize = 512;

View File

@ -462,9 +462,15 @@ 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
}
g_free (name);
@ -589,6 +595,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 = (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
st.st_atime = st.st_mtime = st.st_ctime = (u.buf.c_mtimes[0] << 16) | u.buf.c_mtimes[1];
return cpio_create_entry (me, super, &st, name);
@ -658,6 +667,9 @@ 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
u.st.st_atime = u.st.st_mtime = u.st.st_ctime = hd.c_mtime;
return cpio_create_entry (me, super, &u.st, name);
@ -736,6 +748,9 @@ 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
u.st.st_atime = u.st.st_mtime = u.st.st_ctime = hd.c_mtime;
return cpio_create_entry (me, super, &u.st, name);

View File

@ -1099,6 +1099,9 @@ extfs_stat_move (struct stat *buf, const struct inode *inode)
buf->st_atime = inode->atime;
buf->st_mtime = inode->mtime;
buf->st_ctime = inode->ctime;
#ifdef HAVE_STRUCT_STAT_ST_MTIM
buf->st_atim.tv_nsec = buf->st_mtim.tv_nsec = buf->st_ctim.tv_nsec = 0;
#endif
}
/* --------------------------------------------------------------------------------------------- */

View File

@ -834,6 +834,9 @@ fish_dir_load (struct vfs_class *me, struct vfs_s_inode *dir, char *remote_path)
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':
@ -845,6 +848,9 @@ fish_dir_load (struct vfs_class *me, struct vfs_s_inode *dir, char *remote_path)
&tim.tm_mday, &tim.tm_hour, &tim.tm_min, &tim.tm_sec) != 6)
break;
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;
case 'E':

View File

@ -230,6 +230,10 @@ sftpfs_fstat (void *data, struct stat *buf, GError ** mcerror)
buf->st_atime = attrs.atime;
buf->st_mtime = attrs.mtime;
buf->st_ctime = attrs.mtime;
#ifdef HAVE_STRUCT_STAT_ST_MTIM
buf->st_atim.tv_nsec = buf->st_mtim.tv_nsec = buf->st_ctim.tv_nsec = 0;
#endif
}
if ((attrs.flags & LIBSSH2_SFTP_ATTR_SIZE) != 0)

View File

@ -203,6 +203,9 @@ sftpfs_lstat (const vfs_path_t * vpath, struct stat *buf, GError ** mcerror)
buf->st_atime = attrs.atime;
buf->st_mtime = attrs.mtime;
buf->st_ctime = attrs.mtime;
#ifdef HAVE_STRUCT_STAT_ST_MTIM
buf->st_atim.tv_nsec = buf->st_mtim.tv_nsec = buf->st_ctim.tv_nsec = 0;
#endif
}
if ((attrs.flags & LIBSSH2_SFTP_ATTR_SIZE) != 0)
@ -286,6 +289,9 @@ sftpfs_stat (const vfs_path_t * vpath, struct stat *buf, GError ** mcerror)
buf->st_atime = attrs.atime;
buf->st_mtime = attrs.mtime;
buf->st_ctime = attrs.mtime;
#ifdef HAVE_STRUCT_STAT_ST_MTIM
buf->st_atim.tv_nsec = buf->st_mtim.tv_nsec = buf->st_ctim.tv_nsec = 0;
#endif
}
if ((attrs.flags & LIBSSH2_SFTP_ATTR_SIZE) != 0)

View File

@ -442,6 +442,9 @@ tar_fill_stat (struct vfs_s_super *archive, struct stat *st, union record *heade
}
st->st_size = h_size;
#ifdef HAVE_STRUCT_STAT_ST_MTIM
st->st_atim.tv_nsec = st->st_mtim.tv_nsec = st->st_ctim.tv_nsec = 0;
#endif
st->st_mtime = tar_from_oct (1 + 12, header->header.mtime);
st->st_atime = 0;
st->st_ctime = 0;

View File

@ -634,6 +634,9 @@ undelfs_stat_int (int inode_index, struct stat *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;
}

View File

@ -110,6 +110,11 @@ 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
switch (iterator)
{
case 0:
@ -299,6 +304,13 @@ START_PARAMETRIZED_TEST (test_vfs_parse_ls_lga, test_vfs_parse_ls_lga_ds)
mctest_assert_int_eq (etalon_stat.st_mtime, test_stat.st_mtime);
mctest_assert_int_eq (etalon_stat.st_ctime, test_stat.st_ctime);
*/
#ifdef HAVE_STRUCT_STAT_ST_MTIM
mctest_assert_int_eq (0, test_stat.st_atim.tv_nsec);
mctest_assert_int_eq (0, test_stat.st_mtim.tv_nsec);
mctest_assert_int_eq (0, test_stat.st_ctim.tv_nsec);
#endif
}
/* *INDENT-OFF* */
END_PARAMETRIZED_TEST