76 lines
1.4 KiB
C++
76 lines
1.4 KiB
C++
#pragma once
|
|
#include "fs/VFS.h"
|
|
#include "fs/devices/DeviceRegistry.h"
|
|
#include "fs/devices/MasterPTY.h"
|
|
#include <luna/Bitset.h>
|
|
|
|
/* /dev/tty implementation. */
|
|
class TTYLink : public VFS::DeviceInode
|
|
{
|
|
public:
|
|
TTYLink();
|
|
|
|
VFS::InodeType type() const override
|
|
{
|
|
return VFS::InodeType::CharacterDevice;
|
|
}
|
|
|
|
void set_fs(VFS::FileSystem& fs)
|
|
{
|
|
m_fs = &fs;
|
|
}
|
|
|
|
void set_inode_number(usize inum)
|
|
{
|
|
m_metadata.inum = inum;
|
|
}
|
|
|
|
Result<u64> query_shared_memory(off_t, usize) override
|
|
{
|
|
unreachable();
|
|
}
|
|
|
|
Result<SharedPtr<VFS::Inode>> open() override;
|
|
|
|
VFS::FileSystem* fs() const override
|
|
{
|
|
return m_fs;
|
|
}
|
|
|
|
Result<usize> read(u8*, usize, usize) const override
|
|
{
|
|
unreachable();
|
|
}
|
|
|
|
Result<usize> write(const u8*, usize, usize) override
|
|
{
|
|
unreachable();
|
|
}
|
|
|
|
Result<void> truncate(usize) override
|
|
{
|
|
// POSIX says truncate is for regular files, but doesn't tell us what error to return for non-regular files.
|
|
return err(EINVAL);
|
|
}
|
|
|
|
bool will_block_if_read() const override
|
|
{
|
|
unreachable();
|
|
}
|
|
|
|
void did_link() override
|
|
{
|
|
m_metadata.nlinks++;
|
|
}
|
|
|
|
void did_unlink() override
|
|
{
|
|
m_metadata.nlinks--;
|
|
}
|
|
|
|
virtual ~TTYLink() = default;
|
|
|
|
private:
|
|
VFS::FileSystem* m_fs;
|
|
};
|