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

Method ftruncate64

source/kernel/kprocess.cpp:1306–1327  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1304}
1305
1306U32 KProcess::ftruncate64(FD fildes, U64 length) {
1307 KFileDescriptorPtr fd = this->getFileDescriptor(fildes);
1308
1309 if (fd==nullptr) {
1310 return -K_EBADF;
1311 }
1312 if (fd->kobject->type!=KTYPE_FILE) {
1313 return -K_EINVAL;
1314 }
1315 std::shared_ptr<KFile> p = std::dynamic_pointer_cast<KFile>(fd->kobject);
1316 FsOpenNode* openNode = p->openFile;
1317 if (openNode->node->isDirectory()) {
1318 return -K_EISDIR;
1319 }
1320 if (!fd->canWrite()) {
1321 return -K_EINVAL;
1322 }
1323 if (!openNode->setLength(length)) {
1324 return -K_EIO;
1325 }
1326 return 0;
1327}
1328
1329#define FS_SIZE 107374182400l
1330#define FS_FREE_SIZE 96636764160l

Callers 2

syscall_ftruncateFunction · 0.80
syscall_ftruncate64Function · 0.80

Calls 4

getFileDescriptorMethod · 0.95
isDirectoryMethod · 0.80
canWriteMethod · 0.45
setLengthMethod · 0.45

Tested by

no test coverage detected