fix . and .. incorrectly being reported as files
This commit is contained in:
@@ -6,6 +6,8 @@
|
||||
|
||||
### Changes from v2.0.6-release
|
||||
|
||||
* Fixed `.` and `..` incorrectly being reported as files in remote Linux mounts
|
||||
|
||||
## v2.0.6-release
|
||||
|
||||
### Issues
|
||||
|
@@ -19,6 +19,7 @@
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#include <memory>
|
||||
#if !defined(_WIN32)
|
||||
|
||||
#include "drives/fuse/remotefuse/remote_fuse_drive.hpp"
|
||||
@@ -102,7 +103,7 @@ void remote_fuse_drive::destroy_impl(void *ptr) {
|
||||
}
|
||||
|
||||
if (remote_instance_) {
|
||||
const auto res = remote_instance_->fuse_destroy();
|
||||
auto res = remote_instance_->fuse_destroy();
|
||||
if (res != 0) {
|
||||
utils::error::raise_error(function_name,
|
||||
"remote fuse_destroy() failed|err|" +
|
||||
@@ -128,7 +129,7 @@ auto remote_fuse_drive::fgetattr_impl(std::string api_path,
|
||||
remote::stat r_stat{};
|
||||
auto directory = false;
|
||||
|
||||
const auto res = remote_instance_->fuse_fgetattr(api_path.c_str(), r_stat,
|
||||
auto res = remote_instance_->fuse_fgetattr(api_path.c_str(), r_stat,
|
||||
directory, f_info->fh);
|
||||
if (res == 0) {
|
||||
populate_stat(r_stat, directory, *unix_st);
|
||||
@@ -191,7 +192,7 @@ auto remote_fuse_drive::getattr_impl(std::string api_path, struct stat *unix_st)
|
||||
bool directory = false;
|
||||
remote::stat r_stat{};
|
||||
|
||||
const auto res =
|
||||
auto res =
|
||||
remote_instance_->fuse_getattr(api_path.c_str(), r_stat, directory);
|
||||
if (res == 0) {
|
||||
populate_stat(r_stat, directory, *unix_st);
|
||||
@@ -208,9 +209,9 @@ api_error remote_fuse_drive::getxtimes_impl(std::string api_path,
|
||||
return utils::to_api_error(-EFAULT);
|
||||
}
|
||||
|
||||
remote::file_time repertory_bkuptime = 0u;
|
||||
remote::file_time repertory_crtime = 0u;
|
||||
const auto res = remote_instance_->fuse_getxtimes(
|
||||
remote::file_time repertory_bkuptime{0U};
|
||||
remote::file_time repertory_crtime{0U};
|
||||
auto res = remote_instance_->fuse_getxtimes(
|
||||
api_path.c_str(), repertory_bkuptime, repertory_crtime);
|
||||
if (res == 0) {
|
||||
bkuptime->tv_nsec =
|
||||
@@ -390,20 +391,32 @@ auto remote_fuse_drive::readdir_impl(std::string api_path, void *buf,
|
||||
struct fuse_file_info *f_info)
|
||||
-> api_error {
|
||||
#endif // FUSE_USE_VERSION >= 30
|
||||
|
||||
std::string item_path;
|
||||
int res = 0;
|
||||
int res{0};
|
||||
while ((res = remote_instance_->fuse_readdir(
|
||||
api_path.c_str(), static_cast<remote::file_offset>(offset),
|
||||
f_info->fh, item_path)) == 0) {
|
||||
if ((item_path != ".") && (item_path != "..")) {
|
||||
std::unique_ptr<struct stat> p_stat;
|
||||
if ((item_path == ".") || (item_path == "..")) {
|
||||
p_stat = std::make_unique<struct stat>();
|
||||
if (item_path == ".") {
|
||||
stat(get_mount_location().c_str(), p_stat.get());
|
||||
} else {
|
||||
stat(utils::path::get_parent_path(get_mount_location()).c_str(),
|
||||
p_stat.get());
|
||||
}
|
||||
// p_stat->st_mode = S_IFDIR | 0755;
|
||||
// p_stat->st_nlink = 2;
|
||||
} else {
|
||||
item_path = utils::path::strip_to_file_name(item_path);
|
||||
}
|
||||
|
||||
#if FUSE_USE_VERSION >= 30
|
||||
if (fuse_fill_dir(buf, item_path.c_str(), nullptr, ++offset,
|
||||
static_cast<fuse_fill_dir_flags>(0)) != 0) {
|
||||
if (fuse_fill_dir(buf, item_path.c_str(), p_stat.get(), ++offset,
|
||||
FUSE_FILL_DIR_PLUS) != 0) {
|
||||
#else // FUSE_USE_VERSION < 30
|
||||
if (fuse_fill_dir(buf, item_path.c_str(), nullptr, ++offset) != 0) {
|
||||
if (fuse_fill_dir(buf, item_path.c_str(), p_stat.get(), ++offset) != 0) {
|
||||
#endif // FUSE_USE_VERSION >= 30
|
||||
break;
|
||||
}
|
||||
@@ -592,7 +605,7 @@ auto remote_fuse_drive::write_impl(std::string api_path, const char *buffer,
|
||||
size_t write_size, off_t write_offset,
|
||||
struct fuse_file_info *f_info,
|
||||
std::size_t &bytes_written) -> api_error {
|
||||
const auto res = remote_instance_->fuse_write(
|
||||
auto res = remote_instance_->fuse_write(
|
||||
api_path.c_str(), buffer, write_size,
|
||||
static_cast<remote::file_offset>(write_offset), f_info->fh);
|
||||
if (res >= 0) {
|
||||
|
Reference in New Issue
Block a user