blob: 8c65765656275d4eaf9f8bd919c3a6c396da29ee [file] [log] [blame]
// Copyright 2018 The ChromiumOS Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef INIT_FILE_ATTRS_CLEANER_H_
#define INIT_FILE_ATTRS_CLEANER_H_
#include <string>
#include <vector>
#include <base/files/file_path.h>
#include <brillo/brillo_export.h>
namespace file_attrs_cleaner {
enum class AttributeCheckStatus {
ERROR = 0,
NO_ATTR,
CLEAR_FAILED,
CLEARED,
};
// Check the file attributes of the specified path. `path` is used for logging
// and policy checking, so `fd` needs to be an open handle to it. This helps
// with TOCTTOU issues.
AttributeCheckStatus BRILLO_EXPORT
CheckFileAttributes(const base::FilePath& path, int fd);
// Recursively scan the file attributes of paths under `dir`.
// Don't recurse into any subdirectories that exactly match any string in
// `skip_recurse`.
bool BRILLO_EXPORT ScanDir(const base::FilePath& dir,
const std::vector<std::string>& skip_recurse);
// Convenience function.
static inline bool ScanDir(const std::string& dir,
const std::vector<std::string>& skip_recurse) {
return ScanDir(base::FilePath(dir), skip_recurse);
}
} // namespace file_attrs_cleaner
#endif // INIT_FILE_ATTRS_CLEANER_H_