mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 06:17:35 +00:00
LibC: Add LibC wrapper for sys$readlink()
To avoid having to make direct syscalls in LibCore, let's add a wrapper for the kernel's readlink syscall in LibC.
This commit is contained in:
parent
775ae27a55
commit
1658df9b6e
2 changed files with 16 additions and 2 deletions
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
* Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org>
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
@ -27,6 +27,7 @@
|
||||||
#include <Kernel/API/Syscall.h>
|
#include <Kernel/API/Syscall.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <serenity.h>
|
#include <serenity.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|
||||||
|
@ -118,4 +119,14 @@ int anon_create(size_t size, int options)
|
||||||
int rc = syscall(SC_anon_create, size, options);
|
int rc = syscall(SC_anon_create, size, options);
|
||||||
__RETURN_WITH_ERRNO(rc, rc, -1);
|
__RETURN_WITH_ERRNO(rc, rc, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int serenity_readlink(const char* path, size_t path_length, char* buffer, size_t buffer_size)
|
||||||
|
{
|
||||||
|
Syscall::SC_readlink_params small_params {
|
||||||
|
{ path, path_length },
|
||||||
|
{ buffer, buffer_size }
|
||||||
|
};
|
||||||
|
int rc = syscall(SC_readlink, &small_params);
|
||||||
|
__RETURN_WITH_ERRNO(rc, rc, -1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
* Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org>
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
@ -28,6 +28,7 @@
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
__BEGIN_DECLS
|
__BEGIN_DECLS
|
||||||
|
|
||||||
|
@ -103,6 +104,8 @@ int get_stack_bounds(uintptr_t* user_stack_base, size_t* user_stack_size);
|
||||||
|
|
||||||
int anon_create(size_t size, int options);
|
int anon_create(size_t size, int options);
|
||||||
|
|
||||||
|
int serenity_readlink(const char* path, size_t path_length, char* buffer, size_t buffer_size);
|
||||||
|
|
||||||
#ifdef __i386__
|
#ifdef __i386__
|
||||||
ALWAYS_INLINE void send_secret_data_to_userspace_emulator(uintptr_t data1, uintptr_t data2, uintptr_t data3)
|
ALWAYS_INLINE void send_secret_data_to_userspace_emulator(uintptr_t data1, uintptr_t data2, uintptr_t data3)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue