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