MCPcopy Create free account
hub / github.com/LemonOSProject/LemonOS / ReadLink

Method ReadLink

Kernel/src/fs/ext2.cpp:1344–1357  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1342 }
1343
1344 ssize_t Ext2Volume::ReadLink(Ext2Node* node, char* pathBuffer, size_t bufSize){
1345 if((node->flags & S_IFMT) != S_IFLNK){
1346 return -EINVAL; // Not a symbolic link
1347 }
1348
1349 if(node->size <= 60){
1350 size_t copySize = MIN(bufSize, node->size);
1351 strncpy(pathBuffer, (const char*)node->e2inode.blocks, copySize); // Symlinks up to 60 bytes are stored in the blocklist
1352
1353 return copySize;
1354 } else {
1355 return this->Read(node, 0, bufSize, (uint8_t*)pathBuffer);
1356 }
1357 }
1358
1359 int Ext2Volume::Link(Ext2Node* node, Ext2Node* file, DirectoryEntry* ent){
1360 ent->inode = file->inode;

Callers 2

SysReadLinkFunction · 0.45
FollowLinkFunction · 0.45

Calls 4

ReadMethod · 0.95
strncpyFunction · 0.85
AcquireReadMethod · 0.80
ReleaseReadMethod · 0.80

Tested by

no test coverage detected