|
|
ee80f8 |
/**************************************************************/
|
|
|
ee80f8 |
/* tpax: a topological pax implementation */
|
|
|
ee80f8 |
/* Copyright (C) 2020--2024 SysDeer Technologies, LLC */
|
|
|
ee80f8 |
/* Released under GPLv2 and GPLv3; see COPYING.TPAX. */
|
|
|
ee80f8 |
/**************************************************************/
|
|
|
ee80f8 |
|
|
|
ee80f8 |
#include <time.h>
|
|
|
ee80f8 |
#include <sys/time.h>
|
|
|
ee80f8 |
#include <sys/stat.h>
|
|
|
ee80f8 |
|
|
|
ee80f8 |
#include "tpax_ftime_impl.h"
|
|
|
ee80f8 |
#include "tpax_driver_impl.h"
|
|
|
ee80f8 |
#include "tpax_visibility_impl.h"
|
|
|
ee80f8 |
|
|
|
ee80f8 |
tpax_hidden void tpax_ftime_restore(
|
|
|
ee80f8 |
const struct tpax_driver_ctx * dctx,
|
|
|
ee80f8 |
int fd,
|
|
|
ee80f8 |
const struct stat * refst)
|
|
|
ee80f8 |
{
|
|
|
ee80f8 |
struct timespec ts[2];
|
|
|
ee80f8 |
|
|
|
ee80f8 |
if (dctx->cctx->drvflags & TPAX_DRIVER_PRESERVE_ATIME) {
|
|
|
ee80f8 |
ts[0].tv_sec = refst->st_atim.tv_sec;
|
|
|
ee80f8 |
ts[0].tv_nsec = refst->st_atim.tv_nsec;
|
|
|
ee80f8 |
} else {
|
|
|
ee80f8 |
ts[0].tv_nsec = UTIME_OMIT;
|
|
|
ee80f8 |
}
|
|
|
ee80f8 |
|
|
|
ee80f8 |
if (dctx->cctx->drvflags & TPAX_DRIVER_PRESERVE_MTIME) {
|
|
|
ee80f8 |
ts[1].tv_sec = refst->st_mtim.tv_sec;
|
|
|
ee80f8 |
ts[1].tv_nsec = refst->st_mtim.tv_nsec;
|
|
|
ee80f8 |
} else {
|
|
|
ee80f8 |
ts[1].tv_nsec = UTIME_OMIT;
|
|
|
ee80f8 |
}
|
|
|
ee80f8 |
|
|
|
ee80f8 |
if ((ts[0].tv_nsec != UTIME_OMIT) || (ts[1].tv_nsec != UTIME_OMIT)) {
|
|
|
ee80f8 |
futimens(fd,ts);
|
|
|
ee80f8 |
}
|
|
|
ee80f8 |
}
|
|
|
ee80f8 |
|
|
|
ee80f8 |
tpax_hidden void tpax_ftime_restore_and_close(
|
|
|
ee80f8 |
const struct tpax_driver_ctx * dctx,
|
|
|
ee80f8 |
int fd,
|
|
|
ee80f8 |
const struct stat * refst)
|
|
|
ee80f8 |
{
|
|
|
ee80f8 |
tpax_ftime_restore(dctx,fd,refst);
|
|
|
ee80f8 |
close(fd);
|
|
|
ee80f8 |
}
|