mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 19:17:44 +00:00
Add sys$ttyname_r and ttyname_r() + ttyname().
And print a greeting when sh starts up so we know which TTY we're on.
This commit is contained in:
parent
7a85384e47
commit
00c21d1590
12 changed files with 78 additions and 3 deletions
|
@ -18,6 +18,8 @@ public:
|
|||
unsigned major() const { return m_major; }
|
||||
unsigned minor() const { return m_minor; }
|
||||
|
||||
virtual bool isTTY() const { return false; }
|
||||
|
||||
protected:
|
||||
CharacterDevice(unsigned major, unsigned minor) : m_major(major), m_minor(minor) { }
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#include "CharacterDevice.h"
|
||||
#include "sys-errno.h"
|
||||
#include "UnixTypes.h"
|
||||
#include "TTY.h"
|
||||
#include <AK/BufferStream.h>
|
||||
|
||||
FileHandle::FileHandle(RetainPtr<VirtualFileSystem::Node>&& vnode)
|
||||
|
@ -109,6 +110,7 @@ Unix::ssize_t FileHandle::write(const byte* data, Unix::size_t size)
|
|||
}
|
||||
// FIXME: Implement non-device writes.
|
||||
ASSERT_NOT_REACHED();
|
||||
return -1;
|
||||
}
|
||||
|
||||
bool FileHandle::hasDataAvailableForRead()
|
||||
|
@ -160,3 +162,17 @@ ssize_t FileHandle::get_dir_entries(byte* buffer, Unix::size_t size)
|
|||
memcpy(buffer, tempBuffer.pointer(), stream.offset());
|
||||
return stream.offset();
|
||||
}
|
||||
|
||||
bool FileHandle::isTTY() const
|
||||
{
|
||||
if (auto* device = m_vnode->characterDevice())
|
||||
return device->isTTY();
|
||||
return false;
|
||||
}
|
||||
|
||||
const TTY* FileHandle::tty() const
|
||||
{
|
||||
if (auto* device = m_vnode->characterDevice())
|
||||
return static_cast<const TTY*>(device);
|
||||
return nullptr;
|
||||
}
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
#include "InodeMetadata.h"
|
||||
#include <AK/ByteBuffer.h>
|
||||
|
||||
class TTY;
|
||||
|
||||
class FileHandle {
|
||||
public:
|
||||
explicit FileHandle(RetainPtr<VirtualFileSystem::Node>&&);
|
||||
|
@ -24,6 +26,9 @@ public:
|
|||
|
||||
bool isDirectory() const;
|
||||
|
||||
bool isTTY() const;
|
||||
const TTY* tty() const;
|
||||
|
||||
InodeMetadata metadata() const { return m_vnode->metadata(); }
|
||||
|
||||
VirtualFileSystem::Node* vnode() { return m_vnode.ptr(); }
|
||||
|
|
|
@ -55,6 +55,7 @@ public:
|
|||
|
||||
bool isCharacterDevice() const { return m_characterDevice; }
|
||||
CharacterDevice* characterDevice() { return m_characterDevice; }
|
||||
const CharacterDevice* characterDevice() const { return m_characterDevice; }
|
||||
|
||||
void retain();
|
||||
void release();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue