mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-23 18:02:05 -05:00
08cd75ac4b
After reading a bunch of POSIX specs, I've learned that a file descriptor is the number that refers to a file description, not the description itself. So this patch renames FileDescriptor to FileDescription, and Process now has FileDescription* file_description(int fd).
38 lines
1.2 KiB
C++
38 lines
1.2 KiB
C++
#pragma once
|
|
|
|
#include <Kernel/File.h>
|
|
|
|
class Inode;
|
|
|
|
class InodeFile final : public File {
|
|
public:
|
|
static Retained<InodeFile> create(Retained<Inode>&& inode)
|
|
{
|
|
return adopt(*new InodeFile(move(inode)));
|
|
}
|
|
|
|
virtual ~InodeFile() override;
|
|
|
|
const Inode& inode() const { return *m_inode; }
|
|
Inode& inode() { return *m_inode; }
|
|
|
|
virtual bool can_read(FileDescription&) const override { return true; }
|
|
virtual bool can_write(FileDescription&) const override { return true; }
|
|
|
|
virtual ssize_t read(FileDescription&, byte*, ssize_t) override;
|
|
virtual ssize_t write(FileDescription&, const byte*, ssize_t) override;
|
|
virtual KResultOr<Region*> mmap(Process&, FileDescription&, LinearAddress preferred_laddr, size_t offset, size_t size, int prot) override;
|
|
|
|
virtual String absolute_path(const FileDescription&) const override;
|
|
|
|
virtual KResult truncate(off_t) override;
|
|
|
|
virtual const char* class_name() const override { return "InodeFile"; }
|
|
|
|
virtual bool is_seekable() const override { return true; }
|
|
virtual bool is_inode() const override { return true; }
|
|
|
|
private:
|
|
explicit InodeFile(Retained<Inode>&&);
|
|
Retained<Inode> m_inode;
|
|
};
|