MCPcopy Create free account
hub / github.com/danoon2/Boxedwine / pread64

Method pread64

source/kernel/kprocess.cpp:1867–1889  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1865}
1866
1867U32 KProcess::pread64(KThread* thread, FD fildes, U32 address, U32 len, U64 offset) {
1868 KFileDescriptorPtr fd = this->getFileDescriptor(fildes);
1869
1870 if (!fd) {
1871 return -K_EBADF;
1872 }
1873 if (fd->kobject->type==KTYPE_NATIVE_SOCKET || fd->kobject->type==KTYPE_UNIX_SOCKET) {
1874 return -K_ESPIPE;
1875 }
1876 if (fd->kobject->type!=KTYPE_FILE) {
1877 return -K_EINVAL;
1878 }
1879 std::shared_ptr<KFile> p = std::dynamic_pointer_cast<KFile>(fd->kobject);
1880 FsOpenNode* openNode = p->openFile;
1881
1882 if (openNode->node->isDirectory()) {
1883 return -K_EISDIR;
1884 }
1885 if (!this->memory->canWrite(address, len)) {
1886 return -K_EFAULT;
1887 }
1888 return p->pread(thread, address, (S64)offset, len);
1889}
1890
1891U32 KProcess::pwrite64(KThread* thread, FD fildes, U32 address, U32 len, U64 offset) {
1892 KFileDescriptorPtr fd = this->getFileDescriptor(fildes);

Callers 1

syscall_pread64Function · 0.80

Calls 4

getFileDescriptorMethod · 0.95
isDirectoryMethod · 0.80
preadMethod · 0.80
canWriteMethod · 0.45

Tested by

no test coverage detected