Skip to content

Commit

Permalink
libc: add '__get_fdpath' function
Browse files Browse the repository at this point in the history
This function allows for querying the underlying 'fd_path' of a given
libc fd.

So far it is only used by Haiku-on-Genode and the initial implementation
was provided by Cedric.

Issue genodelabs/genode-world#354.
  • Loading branch information
cnuke committed Jan 11, 2024
1 parent 7d43f34 commit 0fb4af8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions repos/libports/lib/symbols/libc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ __error T
__flt_rounds T
__fpclassifyd T
__fpclassifyf T
__get_fdpath T
__h_errno T
__h_errno_set T
__has_sse D 4
Expand Down
14 changes: 14 additions & 0 deletions repos/libports/src/lib/libc/file_operations.cc
Original file line number Diff line number Diff line change
Expand Up @@ -805,3 +805,17 @@ extern "C" int __getcwd(char *dst, ::size_t dst_size)
copy_cstring(dst, cwd().base(), dst_size);
return 0;
}


extern "C" int __get_fdpath(int libc_fd, char *dst, ::size_t dst_size)
{
using namespace Libc;

File_descriptor *fd = file_descriptor_allocator()->find_by_libc_fd(libc_fd);
if (fd == 0)
return Errno(ENOTSUP);

copy_cstring(dst, fd->fd_path, dst_size);

return 0;
}

0 comments on commit 0fb4af8

Please sign in to comment.