mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 14:07:46 +00:00
LibC: Add realpath
This commit is contained in:
parent
18fbe4ac83
commit
2ca8158a73
2 changed files with 19 additions and 0 deletions
|
@ -568,6 +568,24 @@ int umount(const char* mountpoint)
|
||||||
__RETURN_WITH_ERRNO(rc, rc, -1);
|
__RETURN_WITH_ERRNO(rc, rc, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char* realpath(const char* pathname, char* buffer)
|
||||||
|
{
|
||||||
|
size_t size;
|
||||||
|
if (buffer == nullptr) {
|
||||||
|
size = PATH_MAX;
|
||||||
|
buffer = (char*)malloc(size);
|
||||||
|
} else {
|
||||||
|
size = sizeof(buffer);
|
||||||
|
}
|
||||||
|
int rc = syscall(SC_realpath, pathname, buffer, size);
|
||||||
|
if (rc < 0) {
|
||||||
|
errno = -rc;
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
errno = 0;
|
||||||
|
return buffer;
|
||||||
|
}
|
||||||
|
|
||||||
void dump_backtrace()
|
void dump_backtrace()
|
||||||
{
|
{
|
||||||
syscall(SC_dump_backtrace);
|
syscall(SC_dump_backtrace);
|
||||||
|
|
|
@ -103,6 +103,7 @@ int halt();
|
||||||
int reboot();
|
int reboot();
|
||||||
int mount(const char* device, const char* mountpoint, const char* fstype);
|
int mount(const char* device, const char* mountpoint, const char* fstype);
|
||||||
int umount(const char* mountpoint);
|
int umount(const char* mountpoint);
|
||||||
|
char* realpath(const char* pathname, char* buffer);
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
_PC_NAME_MAX,
|
_PC_NAME_MAX,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue