diff options
author | midipix <writeonce@midipix.org> | 2024-05-30 22:45:00 +0000 |
---|---|---|
committer | midipix <writeonce@midipix.org> | 2024-05-30 22:45:00 +0000 |
commit | ee80f814e924d7e84e02b290f5f8796d6c4b05be (patch) | |
tree | 8c78b3821a7daa042fd572083c1aa8f5cc9654af /src/io | |
parent | 55da8fe4b7c34589e14af92421077f906f65a592 (diff) | |
download | tpax-ee80f814e924d7e84e02b290f5f8796d6c4b05be.tar.bz2 tpax-ee80f814e924d7e84e02b290f5f8796d6c4b05be.tar.xz |
driver: implemented and integrated the -t (preserve atime) command-line option.
Diffstat (limited to 'src/io')
-rw-r--r-- | src/io/tpax_create_memory_snapshot.c | 8 | ||||
-rw-r--r-- | src/io/tpax_create_tmpfs_snapshot.c | 10 |
2 files changed, 13 insertions, 5 deletions
diff --git a/src/io/tpax_create_memory_snapshot.c b/src/io/tpax_create_memory_snapshot.c index 7c3dd7e..6be087f 100644 --- a/src/io/tpax_create_memory_snapshot.c +++ b/src/io/tpax_create_memory_snapshot.c @@ -18,6 +18,7 @@ #include <tpax/tpax_specs.h> #include "tpax_driver_impl.h" #include "tpax_errinfo_impl.h" +#include "tpax_ftime_impl.h" #ifndef ssizeof #define ssizeof(x) (ssize_t)(sizeof(x)) @@ -69,11 +70,11 @@ int tpax_io_create_memory_snapshot( nread = read(fd,ch,cap-ch); if (nread < 0) { - close(fd); + tpax_ftime_restore_and_close(dctx,fd,&dstst); return TPAX_SYSTEM_ERROR(dctx); } else if (nread == 0) { - close(fd); + tpax_ftime_restore_and_close(dctx,fd,&dstst); return TPAX_CUSTOM_ERROR(dctx,TPAX_ERR_FLOW_ERROR); } else { @@ -81,6 +82,9 @@ int tpax_io_create_memory_snapshot( } } + /* preserve last data access time as needed */ + tpax_ftime_restore(dctx,fd,&dstst); + /* stat compare */ if ((fstat(fd,&dstst)) < 0) { close(fd); diff --git a/src/io/tpax_create_tmpfs_snapshot.c b/src/io/tpax_create_tmpfs_snapshot.c index 9891e98..99a1665 100644 --- a/src/io/tpax_create_tmpfs_snapshot.c +++ b/src/io/tpax_create_tmpfs_snapshot.c @@ -19,6 +19,7 @@ #include "tpax_driver_impl.h" #include "tpax_tmpfile_impl.h" #include "tpax_errinfo_impl.h" +#include "tpax_ftime_impl.h" #ifndef ssizeof #define ssizeof(x) (ssize_t)(sizeof(x)) @@ -78,12 +79,12 @@ int tpax_io_create_tmpfs_snapshot( nbytes = read(fdsrc,buf,buflen); if (nbytes < 0) { - close(fdsrc); + tpax_ftime_restore_and_close(dctx,fdsrc,&dstst); close(fdtmp); return TPAX_SYSTEM_ERROR(dctx); } else if (nbytes == 0) { - close(fdsrc); + tpax_ftime_restore_and_close(dctx,fdsrc,&dstst); close(fdtmp); return TPAX_CUSTOM_ERROR(dctx,TPAX_ERR_FLOW_ERROR); @@ -98,7 +99,7 @@ int tpax_io_create_tmpfs_snapshot( ret = write(fdtmp,ch,nbytes); if (ret < 0) { - close(fdsrc); + tpax_ftime_restore_and_close(dctx,fdsrc,&dstst); close(fdtmp); return TPAX_SYSTEM_ERROR(dctx); @@ -108,6 +109,9 @@ int tpax_io_create_tmpfs_snapshot( } } + /* preserve last data access time as needed */ + tpax_ftime_restore(dctx,fdsrc,&dstst); + /* stat compare */ if ((fstat(fdsrc,&dstst)) < 0) { close(fdsrc); |