libc: Add symlink(), symlinkat(), and lstat()
This commit is contained in:
parent
67a9d130e2
commit
cb205c851c
@ -29,6 +29,9 @@ extern "C"
|
|||||||
|
|
||||||
#pragma GCC pop_options
|
#pragma GCC pop_options
|
||||||
|
|
||||||
|
/* Retrieve information about a file or symbolic link. */
|
||||||
|
int lstat(const char* path, struct stat* st);
|
||||||
|
|
||||||
/* Retrieve information about a file. */
|
/* Retrieve information about a file. */
|
||||||
int fstat(int fd, struct stat* st);
|
int fstat(int fd, struct stat* st);
|
||||||
|
|
||||||
|
@ -133,6 +133,12 @@ extern "C"
|
|||||||
/* Create a pipe for inter-process communication. */
|
/* Create a pipe for inter-process communication. */
|
||||||
int pipe(int pfds[2]);
|
int pipe(int pfds[2]);
|
||||||
|
|
||||||
|
/* Create a symbolic link. */
|
||||||
|
int symlink(const char* target, const char* linkpath);
|
||||||
|
|
||||||
|
/* Create a symbolic link relative to a file descriptor. */
|
||||||
|
int symlinkat(const char* target, int dirfd, const char* linkpath);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -30,6 +30,12 @@ extern "C"
|
|||||||
__errno_return(rc, int);
|
__errno_return(rc, int);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int lstat(const char* path, struct stat* st)
|
||||||
|
{
|
||||||
|
long rc = syscall(SYS_fstatat, AT_FDCWD, path, st, AT_SYMLINK_NOFOLLOW);
|
||||||
|
__errno_return(rc, int);
|
||||||
|
}
|
||||||
|
|
||||||
int fstat(int fd, struct stat* st)
|
int fstat(int fd, struct stat* st)
|
||||||
{
|
{
|
||||||
long rc = syscall(SYS_fstatat, fd, "", st, AT_EMPTY_PATH);
|
long rc = syscall(SYS_fstatat, fd, "", st, AT_EMPTY_PATH);
|
||||||
|
@ -406,4 +406,16 @@ extern "C"
|
|||||||
long rc = syscall(SYS_pipe, (int*)pfds);
|
long rc = syscall(SYS_pipe, (int*)pfds);
|
||||||
__errno_return(rc, int);
|
__errno_return(rc, int);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int symlink(const char* target, const char* linkpath)
|
||||||
|
{
|
||||||
|
long rc = syscall(SYS_symlinkat, target, AT_FDCWD, linkpath);
|
||||||
|
__errno_return(rc, int);
|
||||||
|
}
|
||||||
|
|
||||||
|
int symlinkat(const char* target, int dirfd, const char* linkpath)
|
||||||
|
{
|
||||||
|
long rc = syscall(SYS_symlinkat, target, dirfd, linkpath);
|
||||||
|
__errno_return(rc, int);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user