mirror of
https://github.com/trapexit/mergerfs.git
synced 2026-11-26 18:06:27 -05:00
general code cleanup
This commit is contained in:
parent
5a1a60742e
commit
9d9ee7b71d
178 changed files with 5100 additions and 5255 deletions
|
|
@ -18,94 +18,94 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "fs_base_stat.hpp"
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "fs_base_stat.hpp"
|
||||
|
||||
namespace fs
|
||||
{
|
||||
static
|
||||
inline
|
||||
int
|
||||
chown(const std::string &path,
|
||||
const uid_t uid,
|
||||
const gid_t gid)
|
||||
chown(const std::string &path_,
|
||||
const uid_t uid_,
|
||||
const gid_t gid_)
|
||||
{
|
||||
return ::chown(path.c_str(),uid,gid);
|
||||
return ::chown(path_.c_str(),uid_,gid_);
|
||||
}
|
||||
|
||||
static
|
||||
inline
|
||||
int
|
||||
chown(const std::string &path,
|
||||
const struct stat &st)
|
||||
chown(const std::string &path_,
|
||||
const struct stat &st_)
|
||||
{
|
||||
return fs::chown(path,st.st_uid,st.st_gid);
|
||||
return fs::chown(path_,st_.st_uid,st_.st_gid);
|
||||
}
|
||||
|
||||
static
|
||||
inline
|
||||
int
|
||||
lchown(const std::string &path,
|
||||
const uid_t uid,
|
||||
const gid_t gid)
|
||||
lchown(const std::string &path_,
|
||||
const uid_t uid_,
|
||||
const gid_t gid_)
|
||||
{
|
||||
return ::lchown(path.c_str(),uid,gid);
|
||||
return ::lchown(path_.c_str(),uid_,gid_);
|
||||
}
|
||||
|
||||
static
|
||||
inline
|
||||
int
|
||||
lchown(const std::string &path,
|
||||
const struct stat &st)
|
||||
lchown(const std::string &path_,
|
||||
const struct stat &st_)
|
||||
{
|
||||
return fs::lchown(path,st.st_uid,st.st_gid);
|
||||
return fs::lchown(path_,st_.st_uid,st_.st_gid);
|
||||
}
|
||||
|
||||
static
|
||||
inline
|
||||
int
|
||||
fchown(const int fd,
|
||||
const uid_t uid,
|
||||
const gid_t gid)
|
||||
fchown(const int fd_,
|
||||
const uid_t uid_,
|
||||
const gid_t gid_)
|
||||
{
|
||||
return ::fchown(fd,uid,gid);
|
||||
return ::fchown(fd_,uid_,gid_);
|
||||
}
|
||||
|
||||
static
|
||||
inline
|
||||
int
|
||||
fchown(const int fd,
|
||||
const struct stat &st)
|
||||
fchown(const int fd_,
|
||||
const struct stat &st_)
|
||||
{
|
||||
return fs::fchown(fd,st.st_uid,st.st_gid);
|
||||
return fs::fchown(fd_,st_.st_uid,st_.st_gid);
|
||||
}
|
||||
|
||||
static
|
||||
inline
|
||||
int
|
||||
lchown_check_on_error(const std::string &path,
|
||||
const struct stat &st)
|
||||
lchown_check_on_error(const std::string &path_,
|
||||
const struct stat &st_)
|
||||
{
|
||||
int rv;
|
||||
|
||||
rv = fs::lchown(path,st);
|
||||
rv = fs::lchown(path_,st_);
|
||||
if(rv == -1)
|
||||
{
|
||||
int error;
|
||||
struct stat tmpst;
|
||||
|
||||
error = errno;
|
||||
rv = fs::lstat(path,tmpst);
|
||||
rv = fs::lstat(path_,&tmpst);
|
||||
if(rv == -1)
|
||||
return -1;
|
||||
|
||||
if((st.st_uid != tmpst.st_uid) ||
|
||||
(st.st_gid != tmpst.st_gid))
|
||||
if((st_.st_uid != tmpst.st_uid) ||
|
||||
(st_.st_gid != tmpst.st_gid))
|
||||
return (errno=error,-1);
|
||||
}
|
||||
|
||||
|
|
@ -115,24 +115,24 @@ namespace fs
|
|||
static
|
||||
inline
|
||||
int
|
||||
fchown_check_on_error(const int fd,
|
||||
const struct stat &st)
|
||||
fchown_check_on_error(const int fd_,
|
||||
const struct stat &st_)
|
||||
{
|
||||
int rv;
|
||||
|
||||
rv = fs::fchown(fd,st);
|
||||
rv = fs::fchown(fd_,st_);
|
||||
if(rv == -1)
|
||||
{
|
||||
int error;
|
||||
struct stat tmpst;
|
||||
|
||||
error = errno;
|
||||
rv = fs::fstat(fd,tmpst);
|
||||
rv = fs::fstat(fd_,&tmpst);
|
||||
if(rv == -1)
|
||||
return -1;
|
||||
|
||||
if((st.st_uid != tmpst.st_uid) ||
|
||||
(st.st_gid != tmpst.st_gid))
|
||||
if((st_.st_uid != tmpst.st_uid) ||
|
||||
(st_.st_gid != tmpst.st_gid))
|
||||
return (errno=error,-1);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue