MCPcopy Create free account
hub / github.com/ClickHouse/ClickHouse / recursiveChown

Function recursiveChown

programs/docker-init/docker-init.cpp:269–283  ·  view source on GitHub ↗

Recursively chown a path. Logs warnings but does not abort on failure.

Source from the content-addressed store, hash-verified

267
268/// Recursively chown a path. Logs warnings but does not abort on failure.
269void recursiveChown(const std::string & path_str, uid_t uid, gid_t gid)
270{
271 if (lchown(path_str.c_str(), uid, gid) < 0)
272 std::cerr << "docker-init: warning: lchown " << path_str << ": " << strerror(errno) << "\n"; // NOLINT(concurrency-mt-unsafe)
273
274 std::error_code ec;
275 if (!fs::is_directory(path_str, ec))
276 return;
277
278 for (const auto & entry : fs::recursive_directory_iterator(path_str, fs::directory_options::skip_permission_denied, ec))
279 {
280 if (lchown(entry.path().c_str(), uid, gid) < 0)
281 std::cerr << "docker-init: warning: lchown " << entry.path() << ": " << strerror(errno) << "\n"; // NOLINT(concurrency-mt-unsafe)
282 }
283}
284
285/// Create a directory (and all parents) and optionally chown it.
286///

Callers 1

createDirectoryAndChownFunction · 0.85

Calls 2

lchownFunction · 0.85
pathMethod · 0.45

Tested by

no test coverage detected