This tool sets the ACLs of the files given on the command line to those they would inherit from theirparent directories. Directories given on the command line are left unchanged, but all their content is recursively scanned and the ACLs of all their sub-directories and files are set as if freshly inherited.
More...
|
void | handleDir (const std::string &path) |
|
int | main (int argc, const char *argv[]) |
|
|
static unsigned long | nDirs = 0 |
|
static unsigned long | nFiles = 0 |
|
This tool sets the ACLs of the files given on the command line to those they would inherit from theirparent directories. Directories given on the command line are left unchanged, but all their content is recursively scanned and the ACLs of all their sub-directories and files are set as if freshly inherited.
◆ handleDir()
void handleDir |
( |
const std::string & |
path | ) |
|
Definition at line 66 of file fixGpfsAcls.cpp.
67 std::forward_list<std::string> subdirs;
71 while (
auto entry = readdir(dir)) {
72 if (entry->d_name[entry->d_name[0] !=
'.' ? 0 : entry->d_name[1] !=
'.' ? 1 : 2] ==
'\0') {
76 throwcall::good0(fstatat(dirfd(dir), entry->d_name, &statbuf, AT_SYMLINK_NOFOLLOW),
"can't stat '", entry->d_name,
"' in '", path,
"'");
77 if (S_ISDIR(statbuf.st_mode)) {
78 subdirs.emplace_front(path +
"/" + entry->d_name);
79 }
else if (S_ISREG(statbuf.st_mode)) {
80 std::string filePath(path);
82 filePath += entry->d_name;
84 throwcall::good0(gpfs_putacl(filePath.c_str(), 0, fileAcls),
"can't set acl for '", filePath,
"'");
86 std::cerr <<
"ignoring '" << entry->d_name <<
"' in '" << path <<
"', it's neither dir nor file\n";
90 if (!subdirs.empty()) {
92 for (
const auto& subdir : subdirs) {
94 throwcall::good0(gpfs_putacl(subdir.c_str(), 0, dirAcls),
"can't set acl for '", subdir,
"'");
97 for (
const auto& subdir : subdirs) {
References throwcall::good0(), nDirs, and nFiles.
Referenced by main().
◆ main()
int main |
( |
int |
argc, |
|
|
const char * |
argv[] |
|
) |
| |
Definition at line 103 of file fixGpfsAcls.cpp.
105 "set the ACLs of the files given on the command line\n"
106 "\t to those they would inherit from theirparent directories.\n"
107 "\tDirectories given on the command line are left unchanged,\n"
108 "\t but all their content is recursively scanned and the ACLs\n"
109 "\t of all their sub-directories and files are set\n"
110 "\t as if freshly inherited.\n"
113 "files to be fixed");
114 parser.fParse(argc, argv);
115 std::map<std::string, aclBuffer> fileAcls;
116 for (
const auto& file : files) {
119 if (S_ISDIR(statbuf.st_mode)) {
121 }
else if (S_ISREG(statbuf.st_mode)) {
122 auto lastSlash = file.find_last_of(
'/');
123 auto dirPath = lastSlash == std::string::npos ?
"." : file.substr(0, lastSlash);
124 auto bla = fileAcls.emplace(dirPath, dirPath);
126 throwcall::good0(gpfs_putacl(file.c_str(), 0, bla.first->second),
"can't set acl for '", file,
"'");
128 std::cerr <<
"ignoring '" << file <<
"', it's neither dir nor file\n";
131 std::cout <<
"processed " <<
nFiles <<
" files in " <<
nDirs <<
" directories\n";
References throwcall::good0(), handleDir(), nDirs, and nFiles.
◆ nDirs
◆ nFiles