Skip to content

Commit 0fb4af8

Browse files
committed
libc: add '__get_fdpath' function
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.
1 parent 7d43f34 commit 0fb4af8

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

repos/libports/lib/symbols/libc

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ __error T
1515
__flt_rounds T
1616
__fpclassifyd T
1717
__fpclassifyf T
18+
__get_fdpath T
1819
__h_errno T
1920
__h_errno_set T
2021
__has_sse D 4

repos/libports/src/lib/libc/file_operations.cc

+14
Original file line numberDiff line numberDiff line change
@@ -805,3 +805,17 @@ extern "C" int __getcwd(char *dst, ::size_t dst_size)
805805
copy_cstring(dst, cwd().base(), dst_size);
806806
return 0;
807807
}
808+
809+
810+
extern "C" int __get_fdpath(int libc_fd, char *dst, ::size_t dst_size)
811+
{
812+
using namespace Libc;
813+
814+
File_descriptor *fd = file_descriptor_allocator()->find_by_libc_fd(libc_fd);
815+
if (fd == 0)
816+
return Errno(ENOTSUP);
817+
818+
copy_cstring(dst, fd->fd_path, dst_size);
819+
820+
return 0;
821+
}

0 commit comments

Comments
 (0)