mirror of https://github.com/trapexit/mergerfs.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
49 lines
761 B
49 lines
761 B
#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
|