8 #include <forward_list>
27 "maximum number of aces in an acl considered good",14);
29 "minimum number of aces in an acl considered good",0);
38 unsigned duplicates(0);
40 gpfs_ace_v4_t nullAce = {0,0,0,0,0};
42 for (
auto ace1 =
acl.begin(); ace1 !=
acl.end(); ++ace1) {
43 for (
auto ace2 = ace1 + 1; ace2 !=
acl.end(); ++ace2) {
44 if (!(*ace1 == nullAce) && *ace1 == *ace2) {
52 std::cout << path <<
" " <<
acl.size() <<
" " << duplicates <<
"\n";
57 std::forward_list<std::string> subdirs;
60 while (
auto entry = readdir(dir)) {
61 if (entry->d_name[entry->d_name[0] !=
'.' ? 0 : entry->d_name[1] !=
'.' ? 1 : 2] ==
'\0') {
64 if (entry->d_type == DT_DIR) {
65 subdirs.emplace_front(path +
"/" + entry->d_name);
67 }
else if (entry->d_type == DT_REG) {
68 std::string filePath(path);
70 filePath += entry->d_name;
74 std::cerr <<
"ignoring '" << entry->d_name <<
"' in '" << path <<
"', it's neither dir nor file\n";
78 for (
const auto& subdir : subdirs) {
85 int main(
int argc,
const char *argv[]) {
87 "set the ACLs of the files given on the command line\n"
88 "\t to those they would inherit from theirparent directories.\n"
89 "\tDirectories given on the command line are left unchanged,\n"
90 "\t but all their content is recursively scanned and the ACLs\n"
91 "\t of all their sub-directories and files are set\n"
92 "\t as if freshly inherited.\n"
95 "files to be checked");
96 parser.fParse(argc, argv);
97 for (
const auto& file : files) {
100 if (S_ISDIR(statbuf.st_mode)) {
104 }
else if (S_ISREG(statbuf.st_mode)) {
108 std::cerr <<
"ignoring '" << file <<
"', it's neither dir nor file\n";
111 std::cout <<
"processed " <<
nFiles <<
" files in " <<
nDirs <<
" directories\n";
113 std::cout <<
"files with " << item.first <<
" aces in the acl: " << item.second <<
"\n";
116 std::cout <<
"files with " << item.first <<
" duplicates in the acl: " << item.second <<
"\n";