Loading src/client/gkfs_functions.cpp +28 −0 Original line number Diff line number Diff line Loading @@ -373,10 +373,36 @@ gkfs_remove(const std::string& path) { */ int gkfs_access(const std::string& path, const int mask, bool follow_links) { LOG(DEBUG, "Checking '{}'", path); auto md = gkfs::utils::get_metadata(path, follow_links); LOG(DEBUG, "Checked '{}'", path); if(!md) { LOG(DEBUG, "File does not exist '{}'", path); return -1; } #ifdef HAS_SYMLINKS #ifdef HAS_RENAME LOG(DEBUG, "Checking for renamed file '{}'", path); if(md.value().blocks() == -1) { errno = ENOENT; LOG(DEBUG, "File exist but it is renamed '{}'", path); return -1; } else { while(md.value().target_path() != "") { LOG(DEBUG, "File exist but it is renamed '{} -> {}'", path, md.value().target_path()); md = gkfs::utils::get_metadata(md.value().target_path(), false); if(!md) { LOG(DEBUG, "File does not al all exist but it is renamed '{} -> {}'", path, md.value().target_path()); return -1; } } } #endif #endif return 0; } Loading Loading @@ -466,6 +492,7 @@ gkfs_stat(const string& path, struct stat* buf, bool follow_links) { if(!md) { return -1; } #ifdef HAS_SYMLINKS #ifdef HAS_RENAME if(md.value().blocks() == -1) { errno = ENOENT; Loading @@ -478,6 +505,7 @@ gkfs_stat(const string& path, struct stat* buf, bool follow_links) { } } } #endif #endif gkfs::utils::metadata_to_stat(path, *md, *buf); return 0; Loading tests/integration/rename/test_rename_operation.py +8 −0 Original line number Diff line number Diff line Loading @@ -51,6 +51,9 @@ def test_rename(gkfs_daemon, gkfs_client): assert ret.retval == 10000 ret = gkfs_client.access(file, os.R_OK) assert ret.retval == 0 # write a buffer we know buf = b'42' ret = gkfs_client.write(file, buf, len(buf)) Loading @@ -64,7 +67,12 @@ def test_rename(gkfs_daemon, gkfs_client): assert ret.retval == -1 ret = gkfs_client.rename(file, file2) assert ret.retval == 0 ret = gkfs_client.access(file, os.R_OK) assert ret.retval == -1 ret = gkfs_client.access(file2, os.R_OK) assert ret.retval == 0 ret = gkfs_client.stat(file) Loading Loading
src/client/gkfs_functions.cpp +28 −0 Original line number Diff line number Diff line Loading @@ -373,10 +373,36 @@ gkfs_remove(const std::string& path) { */ int gkfs_access(const std::string& path, const int mask, bool follow_links) { LOG(DEBUG, "Checking '{}'", path); auto md = gkfs::utils::get_metadata(path, follow_links); LOG(DEBUG, "Checked '{}'", path); if(!md) { LOG(DEBUG, "File does not exist '{}'", path); return -1; } #ifdef HAS_SYMLINKS #ifdef HAS_RENAME LOG(DEBUG, "Checking for renamed file '{}'", path); if(md.value().blocks() == -1) { errno = ENOENT; LOG(DEBUG, "File exist but it is renamed '{}'", path); return -1; } else { while(md.value().target_path() != "") { LOG(DEBUG, "File exist but it is renamed '{} -> {}'", path, md.value().target_path()); md = gkfs::utils::get_metadata(md.value().target_path(), false); if(!md) { LOG(DEBUG, "File does not al all exist but it is renamed '{} -> {}'", path, md.value().target_path()); return -1; } } } #endif #endif return 0; } Loading Loading @@ -466,6 +492,7 @@ gkfs_stat(const string& path, struct stat* buf, bool follow_links) { if(!md) { return -1; } #ifdef HAS_SYMLINKS #ifdef HAS_RENAME if(md.value().blocks() == -1) { errno = ENOENT; Loading @@ -478,6 +505,7 @@ gkfs_stat(const string& path, struct stat* buf, bool follow_links) { } } } #endif #endif gkfs::utils::metadata_to_stat(path, *md, *buf); return 0; Loading
tests/integration/rename/test_rename_operation.py +8 −0 Original line number Diff line number Diff line Loading @@ -51,6 +51,9 @@ def test_rename(gkfs_daemon, gkfs_client): assert ret.retval == 10000 ret = gkfs_client.access(file, os.R_OK) assert ret.retval == 0 # write a buffer we know buf = b'42' ret = gkfs_client.write(file, buf, len(buf)) Loading @@ -64,7 +67,12 @@ def test_rename(gkfs_daemon, gkfs_client): assert ret.retval == -1 ret = gkfs_client.rename(file, file2) assert ret.retval == 0 ret = gkfs_client.access(file, os.R_OK) assert ret.retval == -1 ret = gkfs_client.access(file2, os.R_OK) assert ret.retval == 0 ret = gkfs_client.stat(file) Loading