| 1865 | } |
| 1866 | |
| 1867 | U32 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 | |
| 1891 | U32 KProcess::pwrite64(KThread* thread, FD fildes, U32 address, U32 len, U64 offset) { |
| 1892 | KFileDescriptorPtr fd = this->getFileDescriptor(fildes); |
no test coverage detected