Refactor filesystem & stl code

This commit is contained in:
EnderIce2
2024-05-18 07:42:01 +03:00
parent 77a291d08b
commit 6801475243
186 changed files with 15784 additions and 9746 deletions

View File

@ -24,157 +24,13 @@
namespace vfs
{
int PTYDevice::open(int Flags, mode_t Mode)
PTYDevice::PTYDevice(Inode *_pts, int _id)
{
stub;
return -ENOSYS;
}
assert(!"Function not implemented");
char nameBuffer[16];
snprintf(nameBuffer, 16, "%d", id);
// this->Name = strdup(nameBuffer);
int PTYDevice::close()
{
stub;
return -ENOSYS;
}
size_t PTYDevice::read(uint8_t *Buffer,
size_t Size,
off_t Offset)
{
if (this->isMaster)
{
if (MasterDev != nullptr)
return MasterDev->read(Buffer, Size, Offset);
else
fixme("MasterDev is nullptr");
}
if (this->SlaveDev == nullptr)
{
fixme("SlaveDev is nullptr");
return 0;
}
return SlaveDev->read(Buffer, Size, Offset);
}
size_t PTYDevice::write(uint8_t *Buffer,
size_t Size,
off_t Offset)
{
if (this->isMaster)
{
if (MasterDev != nullptr)
return MasterDev->write(Buffer, Size, Offset);
else
fixme("MasterDev is nullptr");
}
if (this->SlaveDev == nullptr)
{
fixme("SlaveDev is nullptr");
return 0;
}
return SlaveDev->write(Buffer, Size, Offset);
}
int PTYDevice::ioctl(unsigned long Request,
void *Argp)
{
static_assert(sizeof(struct termios) < PAGE_SIZE);
void *pArgp = thisProcess->PageTable->Get(Argp);
switch (Request)
{
case TCGETS:
{
struct termios *t = (struct termios *)pArgp;
memcpy(t, &this->term, sizeof(struct termios));
break;
}
case TCSETS:
{
struct termios *t = (struct termios *)pArgp;
memcpy(&this->term, t, sizeof(struct termios));
break;
}
case TCSETSW:
case TCSETSF:
case TCGETA:
case TCSETA:
case TCSETAW:
case TCSETAF:
case TCSBRK:
case TCXONC:
case TCFLSH:
case TIOCEXCL:
case TIOCNXCL:
case TIOCSCTTY:
case TIOCGPGRP:
case TIOCSPGRP:
case TIOCOUTQ:
case TIOCSTI:
{
fixme("ioctl %#lx not implemented", Request);
return -ENOSYS;
}
case TIOCGWINSZ:
{
struct winsize *ws = (struct winsize *)pArgp;
memcpy(ws, &this->termSize, sizeof(struct winsize));
break;
}
case TIOCSWINSZ:
{
struct winsize *ws = (struct winsize *)pArgp;
memcpy(&this->termSize, ws, sizeof(struct winsize));
break;
}
case TIOCMGET:
case TIOCMBIS:
case TIOCMBIC:
case TIOCMSET:
{
fixme("ioctl %#lx not implemented", Request);
return -ENOSYS;
}
case TIOCGPTN:
case 0xffffffff80045430: /* FIXME: ???? */
{
int *n = (int *)pArgp;
*n = this->id;
break;
}
case TIOCSPTLCK:
{
int *n = (int *)pArgp;
*n = 0;
break;
}
default:
{
debug("Unknown ioctl %#lx", Request);
return -EINVAL;
}
}
return 0;
}
int PTYDevice::OpenMaster(int Flags, mode_t Mode)
{
debug("Opening master PTY device %s", this->FullPath);
FileDescriptorTable *fdt = thisProcess->FileDescriptors;
int rfd = fdt->_open(this->FullPath, Flags, Mode);
debug("Opened master PTY device %s with fd %d",
this->FullPath, rfd);
return rfd;
}
PTYDevice::PTYDevice(Node *pts, int id) : Node(pts,
std::to_string(id),
CHARDEVICE)
{
/*
- ICRNL - Map Carriage Return to New Line
- IXON - Enable XON/XOFF flow control
@ -206,7 +62,7 @@ namespace vfs
this->term.c_cc[VTIME] = 0; /* Timeout for non-canonical read */
this->term.c_cc[VWERASE] = 0x17; /* ^W */
debug("Created PTY device %s", FullPath);
// debug("Created PTY device %s", this->Name);
}
PTYDevice::~PTYDevice() {}