Compare commits
6 Commits
fc7a7063c2
...
577f362382
Author | SHA1 | Date | |
---|---|---|---|
577f362382 | |||
775c893c65 | |||
3b904945bb | |||
875517a334 | |||
d810f287c2 | |||
8d12ef22b9 |
@ -94,10 +94,12 @@ fallocate_impl
|
||||
fext
|
||||
fgetattr
|
||||
flac_version
|
||||
flag_nopath
|
||||
flarge
|
||||
fontconfig_version
|
||||
freetype2_version
|
||||
fsetattr_x
|
||||
fusermount
|
||||
futimens
|
||||
getxtimes
|
||||
glapi
|
||||
@ -177,6 +179,7 @@ strequal
|
||||
uring
|
||||
userenv
|
||||
utimens_impl
|
||||
utimensat
|
||||
vorbis_version
|
||||
waggressive
|
||||
wall
|
||||
|
@ -133,7 +133,7 @@ auto fuse_base::chmod_(const char *path, mode_t mode,
|
||||
|
||||
return instance().execute_callback(
|
||||
function_name, path, [&](std::string api_path) -> api_error {
|
||||
return instance().chmod_impl(std::move(api_path) mode, fi);
|
||||
return instance().chmod_impl(std::move(api_path), mode, fi);
|
||||
});
|
||||
}
|
||||
#else
|
||||
@ -223,12 +223,12 @@ void fuse_base::display_version_information(std::vector<const char *> args) {
|
||||
|
||||
auto fuse_base::execute_callback(
|
||||
std::string_view function_name, const char *from, const char *to,
|
||||
const std::function<api_error(const std::string &from_api_file,
|
||||
const std::string &to_api_path)> &cb,
|
||||
const std::function<api_error(std::string from_api_file,
|
||||
std::string to_api_path)> &cb,
|
||||
bool disable_logging) -> int {
|
||||
const auto from_api_file = utils::path::create_api_path(from ? from : "");
|
||||
const auto to_api_file = utils::path::create_api_path(to ? to : "");
|
||||
const auto res = utils::from_api_error(cb(from_api_file, to_api_file));
|
||||
auto from_api_file = utils::path::create_api_path(from ? from : "");
|
||||
auto to_api_file = utils::path::create_api_path(to ? to : "");
|
||||
auto res = utils::from_api_error(cb(from_api_file, to_api_file));
|
||||
raise_fuse_event(function_name,
|
||||
"from|" + from_api_file + "|to|" + to_api_file, res,
|
||||
disable_logging);
|
||||
@ -583,9 +583,9 @@ auto fuse_base::rename_(const char *from, const char *to,
|
||||
|
||||
return instance().execute_callback(
|
||||
function_name, from, to,
|
||||
[&](const std::string &from_api_file,
|
||||
const std::string &to_api_path) -> api_error {
|
||||
return instance().rename_impl(from_api_file, to_api_path, flags);
|
||||
[&](std::string from_api_file, std::string to_api_path) -> api_error {
|
||||
return instance().rename_impl(std::move(from_api_file),
|
||||
std::move(to_api_path), flags);
|
||||
});
|
||||
}
|
||||
#else
|
||||
@ -596,9 +596,9 @@ auto fuse_base::rename_(const char *from, const char *to) -> int {
|
||||
|
||||
return instance().execute_callback(
|
||||
function_name, from, to,
|
||||
[&](const std::string &from_api_file,
|
||||
const std::string &to_api_path) -> api_error {
|
||||
return instance().rename_impl(from_api_file, to_api_path);
|
||||
[&](std::string from_api_file, std::string to_api_path) -> api_error {
|
||||
return instance().rename_impl(std::move(from_api_file),
|
||||
std::move(to_api_path));
|
||||
});
|
||||
}
|
||||
#endif
|
||||
|
@ -1155,8 +1155,8 @@ auto fuse_drive::setbkuptime_impl(
|
||||
std::string api_path, const struct timespec *bkuptime) -> api_error {
|
||||
return check_and_perform(
|
||||
api_path, X_OK, [&](api_meta_map &meta) -> api_error {
|
||||
const auto nanos =
|
||||
bkuptime->tv_nsec + (bkuptime->tv_nsec * NANOS_PER_SECOND);
|
||||
const auto nanos = bkuptime->tv_nsec +
|
||||
(bkuptime->tv_nsec * utils::time::NANOS_PER_SECOND);
|
||||
return provider_.set_item_meta(api_path, META_BACKUP,
|
||||
std::to_string(nanos));
|
||||
});
|
||||
@ -1166,8 +1166,8 @@ auto fuse_drive::setchgtime_impl(std::string api_path,
|
||||
const struct timespec *chgtime) -> api_error {
|
||||
return check_and_perform(
|
||||
api_path, X_OK, [&](api_meta_map &meta) -> api_error {
|
||||
const auto nanos =
|
||||
chgtime->tv_nsec + (chgtime->tv_nsec * NANOS_PER_SECOND);
|
||||
const auto nanos = chgtime->tv_nsec +
|
||||
(chgtime->tv_nsec * utils::time::NANOS_PER_SECOND);
|
||||
return provider_.set_item_meta(api_path, META_CHANGED,
|
||||
std::to_string(nanos));
|
||||
});
|
||||
@ -1178,7 +1178,7 @@ auto fuse_drive::setcrtime_impl(std::string api_path,
|
||||
return check_and_perform(
|
||||
api_path, X_OK, [&](api_meta_map &meta) -> api_error {
|
||||
const auto nanos =
|
||||
crtime->tv_nsec + (crtime->tv_nsec * NANOS_PER_SECOND);
|
||||
crtime->tv_nsec + (crtime->tv_nsec * utils::time::NANOS_PER_SECOND);
|
||||
return provider_.set_item_meta(api_path, META_CREATION,
|
||||
std::to_string(nanos));
|
||||
});
|
||||
@ -1310,19 +1310,24 @@ auto fuse_drive::utimens_impl(std::string api_path,
|
||||
}
|
||||
|
||||
meta.clear();
|
||||
if ((tv == nullptr) || (tv[0U].tv_nsec == UTIME_NOW)) {
|
||||
meta[META_ACCESSED] = std::to_string(utils::time::get_time_now());
|
||||
} else if (tv[0U].tv_nsec != UTIME_OMIT) {
|
||||
const auto val = tv[0U].tv_nsec + (tv[0U].tv_sec * NANOS_PER_SECOND);
|
||||
meta[META_ACCESSED] = std::to_string(val);
|
||||
|
||||
const auto process_timespec = [&meta, &tv](const auto &src,
|
||||
std::string attr) {
|
||||
if ((tv == nullptr) || (src.tv_nsec == UTIME_NOW)) {
|
||||
meta[attr] = std::to_string(utils::time::get_time_now());
|
||||
return;
|
||||
}
|
||||
|
||||
if ((tv == nullptr) || (tv[1U].tv_nsec == UTIME_NOW)) {
|
||||
meta[META_MODIFIED] = std::to_string(utils::time::get_time_now());
|
||||
} else if (tv[1U].tv_nsec != UTIME_OMIT) {
|
||||
const auto val = tv[1U].tv_nsec + (tv[1U].tv_sec * NANOS_PER_SECOND);
|
||||
meta[META_MODIFIED] = std::to_string(val);
|
||||
if (src.tv_nsec != UTIME_OMIT) {
|
||||
meta[attr] = std::to_string(
|
||||
src.tv_nsec +
|
||||
(src.tv_sec * static_cast<std::decay_t<decltype(src.tv_sec)>>(
|
||||
utils::time::NANOS_PER_SECOND)));
|
||||
}
|
||||
};
|
||||
|
||||
process_timespec(tv[0U], META_ACCESSED);
|
||||
process_timespec(tv[1U], META_MODIFIED);
|
||||
|
||||
if (not meta.empty()) {
|
||||
return provider_.set_item_meta(api_path, meta);
|
||||
@ -1369,8 +1374,7 @@ void fuse_drive::update_accessed_time(const std::string &api_path) {
|
||||
|
||||
if (atime_enabled_) {
|
||||
auto res = provider_.set_item_meta(
|
||||
api_path, META_ACCESSED,
|
||||
std::to_string(utils::time::get_time_now()));
|
||||
api_path, META_ACCESSED, std::to_string(utils::time::get_time_now()));
|
||||
if (res != api_error::success) {
|
||||
utils::error::raise_api_path_error(function_name, api_path, res,
|
||||
"failed to set accessed time");
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include "platform/platform.hpp"
|
||||
#include "providers/i_provider.hpp"
|
||||
#include "utils/common.hpp"
|
||||
#include "utils/time.hpp"
|
||||
|
||||
namespace repertory {
|
||||
auto fuse_drive_base::access_impl(std::string api_path, int mask) -> api_error {
|
||||
@ -234,8 +235,8 @@ void fuse_drive_base::get_timespec_from_meta(const api_meta_map &meta,
|
||||
const std::string &name,
|
||||
struct timespec &ts) {
|
||||
const auto meta_time = utils::string::to_int64(meta.at(name));
|
||||
ts.tv_nsec = meta_time % NANOS_PER_SECOND;
|
||||
ts.tv_sec = meta_time / NANOS_PER_SECOND;
|
||||
ts.tv_nsec = meta_time % utils::time::NANOS_PER_SECOND;
|
||||
ts.tv_sec = meta_time / utils::time::NANOS_PER_SECOND;
|
||||
}
|
||||
|
||||
auto fuse_drive_base::get_uid_from_meta(const api_meta_map &meta) -> uid_t {
|
||||
@ -342,8 +343,8 @@ void fuse_drive_base::set_timespec_from_meta(const api_meta_map &meta,
|
||||
const std::string &name,
|
||||
struct timespec &ts) {
|
||||
const auto meta_time = utils::string::to_int64(meta.at(name));
|
||||
ts.tv_nsec = meta_time % NANOS_PER_SECOND;
|
||||
ts.tv_sec = meta_time / NANOS_PER_SECOND;
|
||||
ts.tv_nsec = meta_time % utils::time::NANOS_PER_SECOND;
|
||||
ts.tv_sec = meta_time / utils::time::NANOS_PER_SECOND;
|
||||
}
|
||||
} // namespace repertory
|
||||
|
||||
|
@ -570,6 +570,7 @@ auto remote_fuse_drive::utimens_impl(std::string api_path,
|
||||
if (tv != nullptr) {
|
||||
rtv[0U] = static_cast<remote::file_time>(
|
||||
tv[0U].tv_nsec + (tv[0U].tv_sec * utils::time::NANOS_PER_SECOND));
|
||||
|
||||
rtv[1U] = static_cast<remote::file_time>(
|
||||
tv[1U].tv_nsec + (tv[1U].tv_sec * utils::time::NANOS_PER_SECOND));
|
||||
}
|
||||
|
@ -1006,25 +1006,19 @@ auto remote_server::fuse_utimens(const char *path, const remote::file_time *tv,
|
||||
const auto file_path = construct_path(path);
|
||||
|
||||
struct timespec tv2[2] = {{0, 0}};
|
||||
if ((op0 == UTIME_NOW) || (op0 == UTIME_OMIT)) {
|
||||
tv2[0U].tv_nsec = static_cast<time_t>(op0);
|
||||
tv2[0U].tv_sec = 0;
|
||||
} else {
|
||||
tv2[0U].tv_nsec =
|
||||
static_cast<time_t>(tv[0U] % utils::time::NANOS_PER_SECOND);
|
||||
tv2[0U].tv_sec =
|
||||
static_cast<time_t>(tv[0U] / utils::time::NANOS_PER_SECOND);
|
||||
const auto process_timespec = [](auto op, const auto &src, auto &dst) {
|
||||
if ((op == UTIME_NOW) || (op == UTIME_OMIT)) {
|
||||
dst.tv_nsec = static_cast<time_t>(op);
|
||||
dst.tv_sec = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
if ((op1 == UTIME_NOW) || (op1 == UTIME_OMIT)) {
|
||||
tv2[1U].tv_nsec = static_cast<time_t>(op1);
|
||||
tv2[1U].tv_sec = 0;
|
||||
} else {
|
||||
tv2[1U].tv_nsec =
|
||||
static_cast<time_t>(tv[1U] % utils::time::NANOS_PER_SECOND);
|
||||
tv2[1U].tv_sec =
|
||||
static_cast<time_t>(tv[1U] / utils::time::NANOS_PER_SECOND);
|
||||
}
|
||||
dst.tv_nsec = static_cast<time_t>(src % utils::time::NANOS_PER_SECOND);
|
||||
dst.tv_sec = static_cast<time_t>(src / utils::time::NANOS_PER_SECOND);
|
||||
};
|
||||
|
||||
process_timespec(op0, tv[0U], tv2[0U]);
|
||||
process_timespec(op1, tv[1U], tv2[1U]);
|
||||
|
||||
const auto res =
|
||||
utimensat(0, file_path.c_str(), &tv2[0U], AT_SYMLINK_NOFOLLOW);
|
||||
@ -1775,7 +1769,7 @@ auto remote_server::update_to_windows_format(json &item) -> json & {
|
||||
if (item["meta"][META_WRITTEN].empty() ||
|
||||
(item["meta"][META_WRITTEN].get<std::string>() == "0") ||
|
||||
(item["meta"][META_WRITTEN].get<std::string>() ==
|
||||
std::to_string(WIN32_TIME_CONVERSION))) {
|
||||
std::to_string(utils::time::WIN32_TIME_CONVERSION))) {
|
||||
drive_.set_item_meta(api_path, META_WRITTEN,
|
||||
item["meta"][META_MODIFIED].get<std::string>());
|
||||
item["meta"][META_WRITTEN] = item["meta"][META_MODIFIED];
|
||||
|
@ -864,26 +864,24 @@ auto remote_server::fuse_utimens(const char *path, const remote::file_time *tv,
|
||||
FILETIME *access_time_ptr = nullptr;
|
||||
FILETIME *write_time_ptr = nullptr;
|
||||
|
||||
if ((tv[0U] == 0U) || (op0 == UTIME_NOW)) {
|
||||
const auto now = utils::time::get_time_now();
|
||||
access_time.dwHighDateTime =
|
||||
static_cast<DWORD>((now >> 32U) & 0xFFFFFFFF);
|
||||
access_time.dwLowDateTime = now & 0xFFFFFFFF;
|
||||
access_time_ptr = &access_time;
|
||||
} else if (op0 != UTIME_OMIT) {
|
||||
access_time = utils::time::unix_time_to_filetime(tv[0U]);
|
||||
access_time_ptr = &access_time;
|
||||
const auto proccess_timespec = [](auto op, const auto &src, auto &dst,
|
||||
auto *&dst_ptr) {
|
||||
if ((src == 0U) || (op == UTIME_NOW)) {
|
||||
auto now =
|
||||
utils::time::unix_error_to_windows(utils::time::get_time_now());
|
||||
dest.dwHighDateTime = static_cast<DWORD>((now >> 32U) & 0xFFFFFFFF);
|
||||
dest.dwLowDateTime = now & 0xFFFFFFFF;
|
||||
dst_ptr = &dest;
|
||||
return;
|
||||
}
|
||||
|
||||
if ((tv[1U] == 0U) || (op1 == UTIME_NOW)) {
|
||||
const auto now = utils::time::get_time_now();
|
||||
write_time.dwHighDateTime = static_cast<DWORD>((now >> 32U) & 0xFFFFFFFF);
|
||||
write_time.dwLowDateTime = now & 0xFFFFFFFF;
|
||||
write_time_ptr = &write_time;
|
||||
} else if (op1 != UTIME_OMIT) {
|
||||
write_time = utils::time::unix_time_to_filetime(tv[1U]);
|
||||
write_time_ptr = &write_time;
|
||||
if (op != UTIME_OMIT) {
|
||||
dest = utils::time::unix_time_to_filetime(src);
|
||||
dst_ptr = &dest;
|
||||
}
|
||||
};
|
||||
proccess_timespec(op0, tv[0U], access_time, access_time_ptr);
|
||||
proccess_timespec(op1, tv[1U], write_time, write_time_ptr);
|
||||
|
||||
errno = EFAULT;
|
||||
if (::SetFileTime(os_handle, nullptr, access_time_ptr, write_time_ptr) !=
|
||||
@ -891,6 +889,7 @@ auto remote_server::fuse_utimens(const char *path, const remote::file_time *tv,
|
||||
res = 0;
|
||||
errno = 0;
|
||||
}
|
||||
|
||||
::CloseHandle(os_handle);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user