mirror of
https://github.com/trapexit/mergerfs.git
synced 2026-11-29 11:26:44 -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
761 B
C++
49 lines
761 B
C++
#pragma once
|
|
|
|
#include "fs_symlink.hpp"
|
|
#include "ugid.hpp"
|
|
|
|
|
|
#if defined __linux__
|
|
namespace fs
|
|
{
|
|
template<typename T>
|
|
static
|
|
inline
|
|
int
|
|
symlink_as(const ugid_t ugid_,
|
|
const char *target_,
|
|
const T &linkpath_)
|
|
{
|
|
const ugid::SetGuard _(ugid_);
|
|
|
|
return fs::symlink(target_,linkpath_);
|
|
}
|
|
}
|
|
#elif defined __FreeBSD__
|
|
#include "fs_lchown.hpp"
|
|
|
|
namespace fs
|
|
{
|
|
template<typename T>
|
|
static
|
|
inline
|
|
int
|
|
symlink_as(const ugid_t ugid_,
|
|
const char *target_,
|
|
const T &linkpath_)
|
|
{
|
|
int rv;
|
|
|
|
rv = fs::symlink(target_,linkpath_);
|
|
if(rv < 0)
|
|
return rv;
|
|
|
|
fs::lchown(linkpath_,ugid_.uid,ugid_.gid);
|
|
|
|
return 0;
|
|
}
|
|
}
|
|
#else
|
|
#error "Not Supported!"
|
|
#endif
|