libc: Add a basic implementation of pathconf()
This commit is contained in:
parent
9e8a57cec7
commit
6ab246a05e
@ -6,15 +6,20 @@
|
||||
#include <luna/os-limits.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
// 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);
|
||||
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user