subproc/mount: use better types for flags, u64 for clone, unsigned long for mount
This commit is contained in:
parent
2e62649b4c
commit
285ea15811
8
mnt.cc
8
mnt.cc
@ -53,11 +53,11 @@ namespace mnt {
|
|||||||
#define MS_LAZYTIME (1 << 25)
|
#define MS_LAZYTIME (1 << 25)
|
||||||
#endif /* if !defined(MS_LAZYTIME) */
|
#endif /* if !defined(MS_LAZYTIME) */
|
||||||
|
|
||||||
static const std::string flagsToStr(uintptr_t flags) {
|
static const std::string flagsToStr(unsigned long flags) {
|
||||||
std::string res;
|
std::string res;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
const uint64_t flag;
|
const unsigned long flag;
|
||||||
const char* const name;
|
const char* const name;
|
||||||
} static const mountFlags[] = {
|
} static const mountFlags[] = {
|
||||||
NS_VALSTR_STRUCT(MS_RDONLY),
|
NS_VALSTR_STRUCT(MS_RDONLY),
|
||||||
@ -92,7 +92,7 @@ static const std::string flagsToStr(uintptr_t flags) {
|
|||||||
#endif /* defined(MS_NOUSER) */
|
#endif /* defined(MS_NOUSER) */
|
||||||
};
|
};
|
||||||
|
|
||||||
uint64_t knownFlagMask = 0U;
|
unsigned knownFlagMask = 0U;
|
||||||
for (const auto& i : mountFlags) {
|
for (const auto& i : mountFlags) {
|
||||||
if (flags & i.flag) {
|
if (flags & i.flag) {
|
||||||
if (!res.empty()) {
|
if (!res.empty()) {
|
||||||
@ -104,7 +104,7 @@ static const std::string flagsToStr(uintptr_t flags) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (flags & ~(knownFlagMask)) {
|
if (flags & ~(knownFlagMask)) {
|
||||||
util::StrAppend(&res, "|%#tx", flags & ~(knownFlagMask));
|
util::StrAppend(&res, "|%#lx", flags & ~(knownFlagMask));
|
||||||
}
|
}
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
|
12
subproc.cc
12
subproc.cc
@ -63,7 +63,7 @@ namespace subproc {
|
|||||||
#define CLONE_NEWTIME 0x00000080
|
#define CLONE_NEWTIME 0x00000080
|
||||||
#endif /* !defined(CLONE_NEWTIME) */
|
#endif /* !defined(CLONE_NEWTIME) */
|
||||||
|
|
||||||
static const std::string cloneFlagsToStr(uintptr_t flags) {
|
static const std::string cloneFlagsToStr(uint64_t flags) {
|
||||||
std::string res;
|
std::string res;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
@ -112,7 +112,7 @@ static const std::string cloneFlagsToStr(uintptr_t flags) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (flags & ~(knownFlagMask)) {
|
if (flags & ~(knownFlagMask)) {
|
||||||
util::StrAppend(&res, "|%#tx", flags & ~(knownFlagMask));
|
util::StrAppend(&res, "|%#" PRIx64, flags & ~(knownFlagMask));
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
@ -445,7 +445,7 @@ pid_t runChild(nsjconf_t* nsjconf, int netfd, int fd_in, int fd_out, int fd_err)
|
|||||||
if (!net::limitConns(nsjconf, netfd)) {
|
if (!net::limitConns(nsjconf, netfd)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
unsigned long flags = 0UL;
|
uint64_t flags = 0UL;
|
||||||
flags |= (nsjconf->clone_newnet ? CLONE_NEWNET : 0);
|
flags |= (nsjconf->clone_newnet ? CLONE_NEWNET : 0);
|
||||||
flags |= (nsjconf->clone_newuser ? CLONE_NEWUSER : 0);
|
flags |= (nsjconf->clone_newuser ? CLONE_NEWUSER : 0);
|
||||||
flags |= (nsjconf->clone_newns ? CLONE_NEWNS : 0);
|
flags |= (nsjconf->clone_newns ? CLONE_NEWNS : 0);
|
||||||
@ -527,7 +527,7 @@ static int cloneFunc(void* arg __attribute__((unused))) {
|
|||||||
* update the internal PID/TID caches, what can lead to invalid values being returned by getpid()
|
* update the internal PID/TID caches, what can lead to invalid values being returned by getpid()
|
||||||
* or incorrect PID/TIDs used in raise()/abort() functions
|
* or incorrect PID/TIDs used in raise()/abort() functions
|
||||||
*/
|
*/
|
||||||
pid_t cloneProc(uintptr_t flags, int exit_signal) {
|
pid_t cloneProc(uint64_t flags, int exit_signal) {
|
||||||
exit_signal &= CSIGNAL;
|
exit_signal &= CSIGNAL;
|
||||||
|
|
||||||
if (flags & CLONE_VM) {
|
if (flags & CLONE_VM) {
|
||||||
@ -544,7 +544,7 @@ pid_t cloneProc(uintptr_t flags, int exit_signal) {
|
|||||||
|
|
||||||
#if defined(__NR_clone3)
|
#if defined(__NR_clone3)
|
||||||
struct clone_args ca = {};
|
struct clone_args ca = {};
|
||||||
ca.flags = (uint64_t)flags;
|
ca.flags = flags;
|
||||||
ca.exit_signal = (uint64_t)exit_signal;
|
ca.exit_signal = (uint64_t)exit_signal;
|
||||||
|
|
||||||
pid_t ret = util::syscall(__NR_clone3, (uintptr_t)&ca, sizeof(ca));
|
pid_t ret = util::syscall(__NR_clone3, (uintptr_t)&ca, sizeof(ca));
|
||||||
@ -568,7 +568,7 @@ pid_t cloneProc(uintptr_t flags, int exit_signal) {
|
|||||||
*/
|
*/
|
||||||
void* stack = &cloneStack[sizeof(cloneStack) / 2];
|
void* stack = &cloneStack[sizeof(cloneStack) / 2];
|
||||||
/* Parent */
|
/* Parent */
|
||||||
return clone(cloneFunc, stack, flags | exit_signal, NULL, NULL, NULL);
|
return clone(cloneFunc, stack, (int)flags | exit_signal, NULL, NULL, NULL);
|
||||||
}
|
}
|
||||||
/* Child */
|
/* Child */
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user