Skip to content
Snippets Groups Projects
Commit 21947380 authored by Avi Kivity's avatar Avi Kivity
Browse files

fd: add get_fd() helper

parent 711ca3c6
No related branches found
No related tags found
No related merge requests found
...@@ -71,6 +71,19 @@ int open(const char* fname, int mode, ...) ...@@ -71,6 +71,19 @@ int open(const char* fname, int mode, ...)
}); });
} }
std::shared_ptr<file_desc> get_fd(int fd)
{
if (fd < 0) {
return std::shared_ptr<file_desc>();
}
return with_lock(file_table_mutex, [=] {
if (size_t(fd) >= file_table.size()) {
return std::shared_ptr<file_desc>();
}
return file_table[fd];
});
}
namespace { namespace {
int do_stat1(fileref f, struct stat* buf) int do_stat1(fileref f, struct stat* buf)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment