2019-05-30 13:39:17 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <Kernel/File.h>
|
|
|
|
|
|
|
|
class Inode;
|
|
|
|
|
|
|
|
class InodeFile final : public File {
|
|
|
|
public:
|
2019-06-21 18:37:47 +02:00
|
|
|
static NonnullRefPtr<InodeFile> create(NonnullRefPtr<Inode>&& inode)
|
2019-05-30 13:39:17 +02:00
|
|
|
{
|
|
|
|
return adopt(*new InodeFile(move(inode)));
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual ~InodeFile() override;
|
|
|
|
|
|
|
|
const Inode& inode() const { return *m_inode; }
|
|
|
|
Inode& inode() { return *m_inode; }
|
|
|
|
|
2019-06-07 09:36:51 +02:00
|
|
|
virtual bool can_read(FileDescription&) const override { return true; }
|
|
|
|
virtual bool can_write(FileDescription&) const override { return true; }
|
2019-05-30 13:39:17 +02:00
|
|
|
|
2019-07-03 21:17:35 +02:00
|
|
|
virtual ssize_t read(FileDescription&, u8*, ssize_t) override;
|
|
|
|
virtual ssize_t write(FileDescription&, const u8*, ssize_t) override;
|
2019-06-07 12:56:50 +02:00
|
|
|
virtual KResultOr<Region*> mmap(Process&, FileDescription&, VirtualAddress preferred_vaddr, size_t offset, size_t size, int prot) override;
|
2019-05-30 13:39:17 +02:00
|
|
|
|
2019-06-07 09:36:51 +02:00
|
|
|
virtual String absolute_path(const FileDescription&) const override;
|
2019-05-30 13:39:17 +02:00
|
|
|
|
|
|
|
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:
|
2019-06-21 18:37:47 +02:00
|
|
|
explicit InodeFile(NonnullRefPtr<Inode>&&);
|
|
|
|
NonnullRefPtr<Inode> m_inode;
|
2019-05-30 13:39:17 +02:00
|
|
|
};
|