mirror of
https://github.com/EnderIce2/Fennix.git
synced 2025-05-28 15:34:31 +00:00
kernel/fs: Implement usr_pread/pwrite in FDT
Signed-off-by: EnderIce2 <enderice2@protonmail.com>
This commit is contained in:
parent
37c3ee8e99
commit
cbd671292d
@ -211,6 +211,8 @@ namespace vfs
|
||||
int usr_creat(const char *pathname, mode_t mode);
|
||||
ssize_t usr_read(int fd, void *buf, size_t count);
|
||||
ssize_t usr_write(int fd, const void *buf, size_t count);
|
||||
ssize_t usr_pread(int fd, void *buf, size_t count, off_t offset);
|
||||
ssize_t usr_pwrite(int fd, const void *buf, size_t count, off_t offset);
|
||||
int usr_close(int fd);
|
||||
off_t usr_lseek(int fd, off_t offset, int whence);
|
||||
int usr_stat(const char *pathname, struct kstat *statbuf);
|
||||
|
@ -212,6 +212,15 @@ namespace vfs
|
||||
return it->second.Node->Read(buf, count, it->second.Offset);
|
||||
}
|
||||
|
||||
ssize_t FileDescriptorTable::usr_pread(int fd, void *buf, size_t count, off_t offset)
|
||||
{
|
||||
auto it = this->FileMap.find(fd);
|
||||
if (it == this->FileMap.end())
|
||||
ReturnLogError(-EBADF, "Invalid fd %d", fd);
|
||||
|
||||
return it->second.Node->Read(buf, count, offset);
|
||||
}
|
||||
|
||||
ssize_t FileDescriptorTable::usr_write(int fd, const void *buf, size_t count)
|
||||
{
|
||||
auto it = this->FileMap.find(fd);
|
||||
@ -221,6 +230,15 @@ namespace vfs
|
||||
return it->second.Node->Write(buf, count, it->second.Offset);
|
||||
}
|
||||
|
||||
ssize_t FileDescriptorTable::usr_pwrite(int fd, const void *buf, size_t count, off_t offset)
|
||||
{
|
||||
auto it = this->FileMap.find(fd);
|
||||
if (it == this->FileMap.end())
|
||||
ReturnLogError(-EBADF, "Invalid fd %d", fd);
|
||||
|
||||
return it->second.Node->Write(buf, count, offset);
|
||||
}
|
||||
|
||||
int FileDescriptorTable::usr_close(int fd)
|
||||
{
|
||||
auto it = this->FileMap.find(fd);
|
||||
|
Loading…
x
Reference in New Issue
Block a user