summaryrefslogtreecommitdiff
path: root/libguile/filesys.c
diff options
context:
space:
mode:
authorAndy Wingo <wingo@oblong.net>2010-01-17 16:56:21 +0100
committerAndy Wingo <wingo@oblong.net>2010-01-17 16:56:34 +0100
commit06bfe276c8bfd71cf601761659d6b20acebc23b8 (patch)
tree1df6b43c2e1d1d61fc3a61c40596861541a46f1b /libguile/filesys.c
parentf826a8864a4ec7bfffac0f67d45f8ce0085e9d23 (diff)
downloadguile-06bfe276c8bfd71cf601761659d6b20acebc23b8.tar.gz
nanosecond timestamp support in stat and utime
* libguile/posix.h: * libguile/posix.c (scm_utime): Add optional nanosecond arguments. This is an incompatible change on the C level, but it's unlikely people are using this POSIX wrapper function, because they would just use the POSIX function directly. Hopefully, anyway. * module/system/base/compile.scm (call-with-output-file/atomic): Propagate source timestamps to targets with nanosecond precision, if available. Fixes build on systems with ext4 filesystems. * libguile/filesys.c (scm_stat2scm): * module/ice-9/posix.scm (stat:atimensec, stat:mtimensec) (stat:ctimensec): Add three new elements to Scheme stat structures, for nanosecond-level timestamps. * configure.ac: Add checks for utimensat, and for nanosecond fields in struct stat. We should switch to using Gnulib things for these, though. * doc/ref/posix.texi (File System): Add documentation for utime's additional arguments, and nanosecond stat timestamp accessors.
Diffstat (limited to 'libguile/filesys.c')
-rw-r--r--libguile/filesys.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/libguile/filesys.c b/libguile/filesys.c
index 3a2a47ed1..37b45deff 100644
--- a/libguile/filesys.c
+++ b/libguile/filesys.c
@@ -405,7 +405,7 @@ SCM_SYMBOL (scm_sym_unknown, "unknown");
static SCM
scm_stat2scm (struct stat_or_stat64 *stat_temp)
{
- SCM ans = scm_c_make_vector (15, SCM_UNSPECIFIED);
+ SCM ans = scm_c_make_vector (18, SCM_UNSPECIFIED);
SCM_SIMPLE_VECTOR_SET(ans, 0, scm_from_ulong (stat_temp->st_dev));
SCM_SIMPLE_VECTOR_SET(ans, 1, scm_from_ino_t_or_ino64_t (stat_temp->st_ino));
@@ -490,6 +490,21 @@ scm_stat2scm (struct stat_or_stat64 *stat_temp)
*/
}
+#ifdef HAVE_STRUCT_STAT_ST_ATIM
+ SCM_SIMPLE_VECTOR_SET(ans, 15, scm_from_long (stat_temp->st_atim.tv_nsec));
+#else
+ SCM_SIMPLE_VECTOR_SET(ans, 15, SCM_I_MAKINUM (0));
+#endif
+#ifdef HAVE_STRUCT_STAT_ST_MTIM
+ SCM_SIMPLE_VECTOR_SET(ans, 16, scm_from_long (stat_temp->st_mtim.tv_nsec));
+#else
+ SCM_SIMPLE_VECTOR_SET(ans, 16, SCM_I_MAKINUM (0));
+#endif
+#ifdef HAVE_STRUCT_STAT_ST_CTIM
+ SCM_SIMPLE_VECTOR_SET(ans, 17, scm_from_ulong (stat_temp->st_ctim.tv_sec));
+#else
+ SCM_SIMPLE_VECTOR_SET(ans, 17, SCM_I_MAKINUM (0));
+#endif
return ans;
}