mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-23 09:51:57 -05:00
Kernel: Correctly decode proc_file_type from identifier
inode identifiers in ProcFS are encoded in a way that the parent ID is shifted 12 bits to the left and the PID is shifted by 16 bits. This means that the rightmost 12 bits are reserved for the file type or the fd. Since the to_fd and to_proc_file_type decoders only decoded the rightmost 8 bits, decoded values would wrap around beyond values of 255, resulting in a different value compared to what was originally encoded.
This commit is contained in:
parent
8cd96f031d
commit
9559ac9dd6
1 changed files with 2 additions and 2 deletions
|
@ -126,13 +126,13 @@ static inline ProcParentDirectory to_proc_parent_directory(const InodeIdentifier
|
|||
|
||||
static inline ProcFileType to_proc_file_type(const InodeIdentifier& identifier)
|
||||
{
|
||||
return (ProcFileType)(identifier.index().value() & 0xff);
|
||||
return (ProcFileType)(identifier.index().value() & 0xfff);
|
||||
}
|
||||
|
||||
static inline int to_fd(const InodeIdentifier& identifier)
|
||||
{
|
||||
VERIFY(to_proc_parent_directory(identifier) == PDI_PID_fd);
|
||||
return (identifier.index().value() & 0xff) - FI_MaxStaticFileIndex;
|
||||
return (identifier.index().value() & 0xfff) - FI_MaxStaticFileIndex;
|
||||
}
|
||||
|
||||
static inline size_t to_sys_index(const InodeIdentifier& identifier)
|
||||
|
|
Loading…
Add table
Reference in a new issue