-
Notifications
You must be signed in to change notification settings - Fork 192
Closed
Labels
POSIXPOSIX type backend is affectedPOSIX type backend is affectedavailable on masterFix is done on master branch, issue closed on next releaseFix is done on master branch, issue closed on next releasebugSomething isn't workingSomething isn't working
Milestone
Description
Hi!
The call to ghc::filesystem::remove_all(path)
(same with the version with the std::error_code
) appears to fail when "path" is a symlink on a read-write filesystem that points to a non-empty directory on a read-only filesystem. It works correctly when the symlink target is a file or if the target directory is empty. The call returns an error with the "Read-only file system" message.
Tested on Ubuntu 18.04 with gcc 9.2.0 with filesystem 1.0.8 as well as current master. Using std::filesystem
instead, the symlink is deleted as expected.
Test procedure:
- Create virtual filesystem as described here : https://www.thegeekdiary.com/how-to-create-virtual-block-device-loop-device-filesystem-in-linux/ (or use real one, whatever is available)
- Create directory test_dir with a file in it
- Remount filesystem as read-only.
- Create symlink (called sym_test_dir in the example below) to test_dir from a different, read-write filesystem and try to delete that symlink via
remove_all
Sample executable:
#include <iostream>
#include <string>
#include "ghc_filesystem.hpp"
namespace fs = ghc::filesystem;
void removeSomething(const std::string& name) {
std::error_code ec_remove;
fs::remove_all(name, ec_remove);
if (ec_remove.value() != 0) {
std::string msg = ec_remove.message();
std::cout << "Could not remove " << name << ": " << msg << std::endl;
} else {
std::cout << "Happily removed " << name << std::endl;
}
}
int main() {
std::string symlink_path = "sym_test_dir";
// try to remove non-empty dir --> fails with "Read-only file system"
removeSomething(symlink_dir);
return 0;
}
Thanks!
Metadata
Metadata
Assignees
Labels
POSIXPOSIX type backend is affectedPOSIX type backend is affectedavailable on masterFix is done on master branch, issue closed on next releaseFix is done on master branch, issue closed on next releasebugSomething isn't workingSomething isn't working