mirror of
https://github.com/trapexit/mergerfs.git
synced 2026-11-19 22:46:34 -05:00
Some checks are pending
mkdocs / deploy (push) Waiting to run
Run in an elevated credential mode (root) and let the kernel manage entitlements. Will result in slightly different behavior but should not be noticed by most.
49 lines
714 B
C++
49 lines
714 B
C++
#pragma once
|
|
|
|
#include "fs_mkdir.hpp"
|
|
#include "ugid.hpp"
|
|
|
|
|
|
#if defined __linux__
|
|
namespace fs
|
|
{
|
|
template<typename T>
|
|
static
|
|
inline
|
|
int
|
|
mkdir_as(const ugid_t ugid_,
|
|
const T &path_,
|
|
const mode_t mode_)
|
|
{
|
|
const ugid::SetGuard _(ugid_);
|
|
|
|
return fs::mkdir(path_,mode_);
|
|
}
|
|
}
|
|
#elif defined __FreeBSD__
|
|
#include "fs_lchown.hpp"
|
|
|
|
namespace fs
|
|
{
|
|
template<typename T>
|
|
static
|
|
inline
|
|
int
|
|
mkdir_as(const ugid_t ugid_,
|
|
const T &path_,
|
|
const mode_t mode_)
|
|
{
|
|
int rv;
|
|
|
|
rv = fs::mkdir(path_,mode_);
|
|
if(rv < 0)
|
|
return rv;
|
|
|
|
fs::lchown(path_,ugid_.uid,ugid_.gid);
|
|
|
|
return 0;
|
|
}
|
|
}
|
|
#else
|
|
#error "Not Supported"
|
|
#endif
|