tools/nolibc: move open() and friends to fcntl.h
This is the location regular userspace expects these definitions. Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de> Acked-by: Willy Tarreau <w@1wt.eu> Link: https://lore.kernel.org/r/20250416-nolibc-split-sys-v1-3-a069a3f1d145@linutronix.de Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
This commit is contained in:
committed by
Thomas Weißschuh
parent
2b45ceb915
commit
ecc091d93a
@@ -32,6 +32,7 @@ all_files := \
|
||||
dirent.h \
|
||||
elf.h \
|
||||
errno.h \
|
||||
fcntl.h \
|
||||
limits.h \
|
||||
nolibc.h \
|
||||
signal.h \
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include "compiler.h"
|
||||
#include "stdint.h"
|
||||
#include "types.h"
|
||||
#include "fcntl.h"
|
||||
|
||||
#include <linux/limits.h>
|
||||
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1 OR MIT */
|
||||
/*
|
||||
* fcntl definition for NOLIBC
|
||||
* Copyright (C) 2017-2021 Willy Tarreau <w@1wt.eu>
|
||||
*/
|
||||
|
||||
#ifndef _NOLIBC_FCNTL_H
|
||||
#define _NOLIBC_FCNTL_H
|
||||
|
||||
#include "arch.h"
|
||||
#include "types.h"
|
||||
#include "sys.h"
|
||||
|
||||
/*
|
||||
* int openat(int dirfd, const char *path, int flags[, mode_t mode]);
|
||||
*/
|
||||
|
||||
static __attribute__((unused))
|
||||
int sys_openat(int dirfd, const char *path, int flags, mode_t mode)
|
||||
{
|
||||
return my_syscall4(__NR_openat, dirfd, path, flags, mode);
|
||||
}
|
||||
|
||||
static __attribute__((unused))
|
||||
int openat(int dirfd, const char *path, int flags, ...)
|
||||
{
|
||||
mode_t mode = 0;
|
||||
|
||||
if (flags & O_CREAT) {
|
||||
va_list args;
|
||||
|
||||
va_start(args, flags);
|
||||
mode = va_arg(args, mode_t);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
return __sysret(sys_openat(dirfd, path, flags, mode));
|
||||
}
|
||||
|
||||
/*
|
||||
* int open(const char *path, int flags[, mode_t mode]);
|
||||
*/
|
||||
|
||||
static __attribute__((unused))
|
||||
int sys_open(const char *path, int flags, mode_t mode)
|
||||
{
|
||||
return my_syscall4(__NR_openat, AT_FDCWD, path, flags, mode);
|
||||
}
|
||||
|
||||
static __attribute__((unused))
|
||||
int open(const char *path, int flags, ...)
|
||||
{
|
||||
mode_t mode = 0;
|
||||
|
||||
if (flags & O_CREAT) {
|
||||
va_list args;
|
||||
|
||||
va_start(args, flags);
|
||||
mode = va_arg(args, mode_t);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
return __sysret(sys_open(path, flags, mode));
|
||||
}
|
||||
|
||||
/* make sure to include all global symbols */
|
||||
#include "nolibc.h"
|
||||
|
||||
#endif /* _NOLIBC_FCNTL_H */
|
||||
@@ -106,6 +106,7 @@
|
||||
#include "time.h"
|
||||
#include "stackprotector.h"
|
||||
#include "dirent.h"
|
||||
#include "fcntl.h"
|
||||
|
||||
/* Used by programs to avoid std includes */
|
||||
#define NOLIBC
|
||||
|
||||
@@ -764,58 +764,6 @@ int mount(const char *src, const char *tgt,
|
||||
return __sysret(sys_mount(src, tgt, fst, flags, data));
|
||||
}
|
||||
|
||||
/*
|
||||
* int openat(int dirfd, const char *path, int flags[, mode_t mode]);
|
||||
*/
|
||||
|
||||
static __attribute__((unused))
|
||||
int sys_openat(int dirfd, const char *path, int flags, mode_t mode)
|
||||
{
|
||||
return my_syscall4(__NR_openat, dirfd, path, flags, mode);
|
||||
}
|
||||
|
||||
static __attribute__((unused))
|
||||
int openat(int dirfd, const char *path, int flags, ...)
|
||||
{
|
||||
mode_t mode = 0;
|
||||
|
||||
if (flags & O_CREAT) {
|
||||
va_list args;
|
||||
|
||||
va_start(args, flags);
|
||||
mode = va_arg(args, mode_t);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
return __sysret(sys_openat(dirfd, path, flags, mode));
|
||||
}
|
||||
|
||||
/*
|
||||
* int open(const char *path, int flags[, mode_t mode]);
|
||||
*/
|
||||
|
||||
static __attribute__((unused))
|
||||
int sys_open(const char *path, int flags, mode_t mode)
|
||||
{
|
||||
return my_syscall4(__NR_openat, AT_FDCWD, path, flags, mode);
|
||||
}
|
||||
|
||||
static __attribute__((unused))
|
||||
int open(const char *path, int flags, ...)
|
||||
{
|
||||
mode_t mode = 0;
|
||||
|
||||
if (flags & O_CREAT) {
|
||||
va_list args;
|
||||
|
||||
va_start(args, flags);
|
||||
mode = va_arg(args, mode_t);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
return __sysret(sys_open(path, flags, mode));
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* int pipe2(int pipefd[2], int flags);
|
||||
|
||||
Reference in New Issue
Block a user