This commit is contained in:
@ -53,8 +53,8 @@ private:
|
|||||||
bool was_mounted_ = false;
|
bool was_mounted_ = false;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void populate_stat(const remote::stat &r_stat, bool directory,
|
static void populate_stat(const remote::stat &r_stat, bool directory,
|
||||||
struct stat &unix_st);
|
struct stat &unix_st);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
[[nodiscard]] auto access_impl(std::string api_path,
|
[[nodiscard]] auto access_impl(std::string api_path,
|
||||||
|
@ -300,10 +300,15 @@ auto remote_fuse_drive::opendir_impl(
|
|||||||
void remote_fuse_drive::populate_stat(const remote::stat &r_stat,
|
void remote_fuse_drive::populate_stat(const remote::stat &r_stat,
|
||||||
bool directory, struct stat &unix_st) {
|
bool directory, struct stat &unix_st) {
|
||||||
std::memset(&unix_st, 0, sizeof(struct stat));
|
std::memset(&unix_st, 0, sizeof(struct stat));
|
||||||
|
unix_st.st_blksize = r_stat.st_blksize;
|
||||||
|
unix_st.st_blocks = static_cast<blkcnt_t>(r_stat.st_blocks);
|
||||||
|
unix_st.st_gid = r_stat.st_gid;
|
||||||
|
unix_st.st_mode = (directory ? S_IFDIR : S_IFREG) | r_stat.st_mode;
|
||||||
|
unix_st.st_nlink = r_stat.st_nlink;
|
||||||
|
unix_st.st_size = static_cast<off_t>(r_stat.st_size);
|
||||||
|
unix_st.st_uid = r_stat.st_uid;
|
||||||
|
|
||||||
#if defined(__APPLE__)
|
#if defined(__APPLE__)
|
||||||
unix_st.st_blksize = 0;
|
|
||||||
|
|
||||||
unix_st.st_atimespec.tv_nsec =
|
unix_st.st_atimespec.tv_nsec =
|
||||||
r_stat.st_atimespec % utils::time::NANOS_PER_SECOND;
|
r_stat.st_atimespec % utils::time::NANOS_PER_SECOND;
|
||||||
unix_st.st_atimespec.tv_sec =
|
unix_st.st_atimespec.tv_sec =
|
||||||
@ -326,8 +331,6 @@ void remote_fuse_drive::populate_stat(const remote::stat &r_stat,
|
|||||||
|
|
||||||
unix_st.st_flags = r_stat.st_flags;
|
unix_st.st_flags = r_stat.st_flags;
|
||||||
#else // !defined(__APPLE__)
|
#else // !defined(__APPLE__)
|
||||||
unix_st.st_blksize = 4096;
|
|
||||||
|
|
||||||
unix_st.st_atim.tv_nsec = static_cast<suseconds_t>(
|
unix_st.st_atim.tv_nsec = static_cast<suseconds_t>(
|
||||||
r_stat.st_atimespec % utils::time::NANOS_PER_SECOND);
|
r_stat.st_atimespec % utils::time::NANOS_PER_SECOND);
|
||||||
unix_st.st_atim.tv_sec = static_cast<suseconds_t>(
|
unix_st.st_atim.tv_sec = static_cast<suseconds_t>(
|
||||||
@ -343,25 +346,6 @@ void remote_fuse_drive::populate_stat(const remote::stat &r_stat,
|
|||||||
unix_st.st_mtim.tv_sec = static_cast<suseconds_t>(
|
unix_st.st_mtim.tv_sec = static_cast<suseconds_t>(
|
||||||
r_stat.st_mtimespec / utils::time::NANOS_PER_SECOND);
|
r_stat.st_mtimespec / utils::time::NANOS_PER_SECOND);
|
||||||
#endif // defined(__APPLE__)
|
#endif // defined(__APPLE__)
|
||||||
|
|
||||||
if (not directory) {
|
|
||||||
const auto block_size_stat = static_cast<std::uint64_t>(512U);
|
|
||||||
const auto block_size = static_cast<std::uint64_t>(4096U);
|
|
||||||
const auto size =
|
|
||||||
utils::divide_with_ceiling(static_cast<std::uint64_t>(unix_st.st_size),
|
|
||||||
block_size) *
|
|
||||||
block_size;
|
|
||||||
unix_st.st_blocks = static_cast<blkcnt_t>(
|
|
||||||
std::max(block_size / block_size_stat,
|
|
||||||
utils::divide_with_ceiling(size, block_size_stat)));
|
|
||||||
}
|
|
||||||
|
|
||||||
unix_st.st_gid = r_stat.st_gid;
|
|
||||||
unix_st.st_mode = (directory ? S_IFDIR : S_IFREG) | r_stat.st_mode;
|
|
||||||
|
|
||||||
unix_st.st_nlink = r_stat.st_nlink;
|
|
||||||
unix_st.st_size = static_cast<off_t>(r_stat.st_size);
|
|
||||||
unix_st.st_uid = r_stat.st_uid;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
auto remote_fuse_drive::read_impl(std::string api_path, char *buffer,
|
auto remote_fuse_drive::read_impl(std::string api_path, char *buffer,
|
||||||
|
Reference in New Issue
Block a user