diff --git a/libs/libc/include/unistd.h b/libs/libc/include/unistd.h index b903f850..aaa87201 100644 --- a/libs/libc/include/unistd.h +++ b/libs/libc/include/unistd.h @@ -6,15 +6,20 @@ #include #include +// Standard IO streams. #define STDIN_FILENO 0 // The standard input stream. #define STDOUT_FILENO 1 // The standard output stream. #define STDERR_FILENO 2 // The standard error stream. +// Possible arguments to access() #define F_OK 0 // Check for a file's existence. #define R_OK 1 // Check whether a file is readable. #define W_OK 2 // Check whether a file is writable. #define X_OK 4 // Check whether a file is executable. +// Name values for pathconf() +#define _PC_PATH_MAX 0 // Maximum length of a path relative to the provided name. + #ifdef __cplusplus extern "C" { @@ -103,6 +108,9 @@ extern "C" int chdir(const char* path); // Not implemented. int pipe(int fd[2]); // Not implemented. + /* Returns a configuration value for the file at path. */ + long pathconf(const char* path, int name); + /* Returns the maximum number of file descriptors a process can have open at the same time. */ int getdtablesize(void); diff --git a/libs/libc/src/unistd.cpp b/libs/libc/src/unistd.cpp index bd042c6a..29ec9fed 100644 --- a/libs/libc/src/unistd.cpp +++ b/libs/libc/src/unistd.cpp @@ -164,6 +164,15 @@ extern "C" NOT_IMPLEMENTED("pipe"); } + long pathconf(const char* path, int name) + { + switch (name) + { + case _PC_PATH_MAX: return PATH_MAX - (strlen(path) + 1); + default: errno = EINVAL; return -1; + } + } + int getdtablesize(void) { return OPEN_MAX;