mirror of
https://github.com/trapexit/mergerfs.git
synced 2026-11-20 15:06:33 -05:00
general code cleanup
This commit is contained in:
parent
5a1a60742e
commit
9d9ee7b71d
178 changed files with 5100 additions and 5255 deletions
|
|
@ -18,10 +18,10 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include "fs_base_stat.hpp"
|
||||
|
||||
#include <sys/stat.h>
|
||||
|
||||
#define MODE_BITS (S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO)
|
||||
|
||||
namespace fs
|
||||
|
|
@ -29,50 +29,50 @@ namespace fs
|
|||
static
|
||||
inline
|
||||
int
|
||||
chmod(const std::string &path,
|
||||
const mode_t mode)
|
||||
chmod(const std::string &path_,
|
||||
const mode_t mode_)
|
||||
{
|
||||
return ::chmod(path.c_str(),mode);
|
||||
return ::chmod(path_.c_str(),mode_);
|
||||
}
|
||||
|
||||
static
|
||||
inline
|
||||
int
|
||||
fchmod(const int fd,
|
||||
const mode_t mode)
|
||||
fchmod(const int fd_,
|
||||
const mode_t mode_)
|
||||
{
|
||||
return ::fchmod(fd,mode);
|
||||
return ::fchmod(fd_,mode_);
|
||||
}
|
||||
|
||||
static
|
||||
inline
|
||||
int
|
||||
fchmod(const int fd,
|
||||
const struct stat &st)
|
||||
fchmod(const int fd_,
|
||||
const struct stat &st_)
|
||||
{
|
||||
return ::fchmod(fd,st.st_mode);
|
||||
return ::fchmod(fd_,st_.st_mode);
|
||||
}
|
||||
|
||||
static
|
||||
inline
|
||||
int
|
||||
chmod_check_on_error(const std::string &path,
|
||||
const mode_t mode)
|
||||
chmod_check_on_error(const std::string &path_,
|
||||
const mode_t mode_)
|
||||
{
|
||||
int rv;
|
||||
|
||||
rv = fs::chmod(path,mode);
|
||||
rv = fs::chmod(path_,mode_);
|
||||
if(rv == -1)
|
||||
{
|
||||
int error;
|
||||
struct stat st;
|
||||
|
||||
error = errno;
|
||||
rv = fs::stat(path,st);
|
||||
rv = fs::stat(path_,&st);
|
||||
if(rv == -1)
|
||||
return -1;
|
||||
|
||||
if((st.st_mode & MODE_BITS) != (mode & MODE_BITS))
|
||||
if((st.st_mode & MODE_BITS) != (mode_ & MODE_BITS))
|
||||
return (errno=error,-1);
|
||||
}
|
||||
|
||||
|
|
@ -82,23 +82,23 @@ namespace fs
|
|||
static
|
||||
inline
|
||||
int
|
||||
fchmod_check_on_error(const int fd,
|
||||
const struct stat &st)
|
||||
fchmod_check_on_error(const int fd_,
|
||||
const struct stat &st_)
|
||||
{
|
||||
int rv;
|
||||
|
||||
rv = fs::fchmod(fd,st);
|
||||
rv = fs::fchmod(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_mode & MODE_BITS) != (tmpst.st_mode & MODE_BITS))
|
||||
if((st_.st_mode & MODE_BITS) != (tmpst.st_mode & MODE_BITS))
|
||||
return (errno=error,-1);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue