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
# define MAXPATHLEN PATH_MAX
#endif
#define PIPE_BUF 4096
#define INT_MAX INT32_MAX
#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);
}
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()
{
return syscall(SC_getuid);
@ -459,11 +477,12 @@ long fpathconf(int fd, int name)
long pathconf(const char* path, int name)
{
(void)path;
(void)name;
switch (name) {
case _PC_PATH_MAX:
return PATH_MAX;
case _PC_PIPE_BUF:
return PIPE_BUF;
}
ASSERT_NOT_REACHED();

View file

@ -26,7 +26,6 @@ __BEGIN_DECLS
# define SEEK_END 2 /* from the end of the file. */
#endif
extern char** environ;
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 execvp(const char* filename, char* const argv[]);
int execl(const char* filename, const char* arg, ...);
int execlp(const char* filename, const char* arg, ...);
void sync();
void _exit(int status);
pid_t getsid(pid_t);
@ -127,6 +127,7 @@ char* realpath(const char* pathname, char* buffer);
enum {
_PC_NAME_MAX,
_PC_PATH_MAX,
_PC_PIPE_BUF
};
#define HOST_NAME_MAX 64