1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 02:37:35 +00:00

LibC: Added execlp method and new pathconf setting

Added execlp method, and _PC_PIPE_BUF setting to pathconf method.
This commit is contained in:
Brandon Scott 2019-11-16 02:35:48 -06:00 committed by Andreas Kling
parent eb719aa726
commit f999e30afd
3 changed files with 28 additions and 7 deletions

View file

@ -8,6 +8,7 @@
#if !defined MAXPATHLEN && defined PATH_MAX #if !defined MAXPATHLEN && defined PATH_MAX
# define MAXPATHLEN PATH_MAX # define MAXPATHLEN PATH_MAX
#endif #endif
#define PIPE_BUF 4096
#define INT_MAX INT32_MAX #define INT_MAX INT32_MAX
#define INT_MIN INT32_MIN #define INT_MIN INT32_MIN

View file

@ -104,6 +104,24 @@ int execl(const char* filename, const char* arg0, ...)
return execve(filename, const_cast<char* const*>(args.data()), environ); return execve(filename, const_cast<char* const*>(args.data()), environ);
} }
int execlp(const char* filename, const char* arg0, ...)
{
Vector<const char*, 16> args;
args.append(arg0);
va_list ap;
va_start(ap, arg0);
for (;;) {
const char* arg = va_arg(ap, const char*);
if (!arg)
break;
args.append(arg);
}
va_end(ap);
args.append(nullptr);
return execvpe(filename, const_cast<char* const*>(args.data()), environ);
}
uid_t getuid() uid_t getuid()
{ {
return syscall(SC_getuid); return syscall(SC_getuid);
@ -459,11 +477,12 @@ long fpathconf(int fd, int name)
long pathconf(const char* path, int name) long pathconf(const char* path, int name)
{ {
(void)path; (void)path;
(void)name;
switch (name) { switch (name) {
case _PC_PATH_MAX: case _PC_PATH_MAX:
return PATH_MAX; return PATH_MAX;
case _PC_PIPE_BUF:
return PIPE_BUF;
} }
ASSERT_NOT_REACHED(); ASSERT_NOT_REACHED();
@ -548,7 +567,7 @@ char* getlogin()
return nullptr; return nullptr;
} }
int create_thread(void *(*entry)(void*), void* argument) int create_thread(void* (*entry)(void*), void* argument)
{ {
int rc = syscall(SC_create_thread, entry, argument); int rc = syscall(SC_create_thread, entry, argument);
__RETURN_WITH_ERRNO(rc, rc, -1); __RETURN_WITH_ERRNO(rc, rc, -1);

View file

@ -20,13 +20,12 @@ __BEGIN_DECLS
#define STDERR_FILENO 2 #define STDERR_FILENO 2
/* lseek whence values */ /* lseek whence values */
#ifndef _STDIO_H /* also defined in stdio.h */ #ifndef _STDIO_H /* also defined in stdio.h */
#define SEEK_SET 0 /* from beginning of file. */ # define SEEK_SET 0 /* from beginning of file. */
#define SEEK_CUR 1 /* from current position in file. */ # define SEEK_CUR 1 /* from current position in file. */
#define SEEK_END 2 /* from the end of the file. */ # define SEEK_END 2 /* from the end of the file. */
#endif #endif
extern char** environ; extern char** environ;
int get_process_name(char* buffer, int buffer_size); int get_process_name(char* buffer, int buffer_size);
@ -54,6 +53,7 @@ int execve(const char* filename, char* const argv[], char* const envp[]);
int execvpe(const char* filename, char* const argv[], char* const envp[]); int execvpe(const char* filename, char* const argv[], char* const envp[]);
int execvp(const char* filename, char* const argv[]); int execvp(const char* filename, char* const argv[]);
int execl(const char* filename, const char* arg, ...); int execl(const char* filename, const char* arg, ...);
int execlp(const char* filename, const char* arg, ...);
void sync(); void sync();
void _exit(int status); void _exit(int status);
pid_t getsid(pid_t); pid_t getsid(pid_t);
@ -127,6 +127,7 @@ char* realpath(const char* pathname, char* buffer);
enum { enum {
_PC_NAME_MAX, _PC_NAME_MAX,
_PC_PATH_MAX, _PC_PATH_MAX,
_PC_PIPE_BUF
}; };
#define HOST_NAME_MAX 64 #define HOST_NAME_MAX 64