mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 21:37:34 +00:00
Kernel: Expose blocking and cloexec fd flags in ProcFS
This commit is contained in:
parent
eb18825fce
commit
9a41dda029
3 changed files with 14 additions and 0 deletions
|
@ -211,12 +211,16 @@ Optional<KBuffer> procfs$pid_fds(InodeIdentifier identifier)
|
||||||
auto* description = process.file_description(i);
|
auto* description = process.file_description(i);
|
||||||
if (!description)
|
if (!description)
|
||||||
continue;
|
continue;
|
||||||
|
bool cloexec = process.fd_flags(i) & FD_CLOEXEC;
|
||||||
|
|
||||||
JsonObjectSerializer description_object = array.add_object();
|
JsonObjectSerializer description_object = array.add_object();
|
||||||
description_object.add("fd", i);
|
description_object.add("fd", i);
|
||||||
description_object.add("absolute_path", description->absolute_path());
|
description_object.add("absolute_path", description->absolute_path());
|
||||||
description_object.add("seekable", description->file().is_seekable());
|
description_object.add("seekable", description->file().is_seekable());
|
||||||
description_object.add("class", description->file().class_name());
|
description_object.add("class", description->file().class_name());
|
||||||
description_object.add("offset", description->offset());
|
description_object.add("offset", description->offset());
|
||||||
|
description_object.add("cloexec", cloexec);
|
||||||
|
description_object.add("blocking", description->is_blocking());
|
||||||
}
|
}
|
||||||
array.finish();
|
array.finish();
|
||||||
return builder.build();
|
return builder.build();
|
||||||
|
|
|
@ -917,6 +917,15 @@ const FileDescription* Process::file_description(int fd) const
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int Process::fd_flags(int fd) const
|
||||||
|
{
|
||||||
|
if (fd < 0)
|
||||||
|
return -1;
|
||||||
|
if (fd < m_fds.size())
|
||||||
|
return m_fds[fd].flags;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
ssize_t Process::sys$get_dir_entries(int fd, void* buffer, ssize_t size)
|
ssize_t Process::sys$get_dir_entries(int fd, void* buffer, ssize_t size)
|
||||||
{
|
{
|
||||||
if (size < 0)
|
if (size < 0)
|
||||||
|
|
|
@ -95,6 +95,7 @@ public:
|
||||||
|
|
||||||
FileDescription* file_description(int fd);
|
FileDescription* file_description(int fd);
|
||||||
const FileDescription* file_description(int fd) const;
|
const FileDescription* file_description(int fd) const;
|
||||||
|
int fd_flags(int fd) const;
|
||||||
|
|
||||||
template<typename Callback>
|
template<typename Callback>
|
||||||
static void for_each(Callback);
|
static void for_each(Callback);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue