mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 02:47:34 +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:
parent
eb719aa726
commit
f999e30afd
3 changed files with 28 additions and 7 deletions
|
@ -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
|
||||
|
|
|
@ -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();
|
||||
|
@ -548,7 +567,7 @@ char* getlogin()
|
|||
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);
|
||||
__RETURN_WITH_ERRNO(rc, rc, -1);
|
||||
|
|
|
@ -20,13 +20,12 @@ __BEGIN_DECLS
|
|||
#define STDERR_FILENO 2
|
||||
|
||||
/* lseek whence values */
|
||||
#ifndef _STDIO_H /* also defined in stdio.h */
|
||||
#define SEEK_SET 0 /* from beginning of file. */
|
||||
#define SEEK_CUR 1 /* from current position in file. */
|
||||
#define SEEK_END 2 /* from the end of the file. */
|
||||
#ifndef _STDIO_H /* also defined in stdio.h */
|
||||
# define SEEK_SET 0 /* from beginning of file. */
|
||||
# define SEEK_CUR 1 /* from current position in file. */
|
||||
# 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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue