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

Method Link

Kernel/src/fs/ext2.cpp:1359–1387  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1357 }
1358
1359 int Ext2Volume::Link(Ext2Node* node, Ext2Node* file, DirectoryEntry* ent){
1360 ent->inode = file->inode;
1361 if(!ent->inode){
1362 Log::Error("[Ext2] Link: Invalid inode %d", ent->inode);
1363 return -EINVAL;
1364 }
1365
1366 List<DirectoryEntry> entries;
1367 if(int e = ListDir(node, entries)){
1368 Log::Error("[Ext2] Link: Error listing directory!", ent->inode);
1369 return e;
1370 }
1371
1372 for(DirectoryEntry& dirent : entries){
1373 if(strcmp(dirent.name, ent->name) == 0){
1374 Log::Error("[Ext2] Link: Directory entry %s already exists!", ent->name);
1375 return -EEXIST;
1376 }
1377 }
1378
1379 entries.add_back(*ent);
1380
1381 file->nlink++;
1382 file->e2inode.linkCount++;
1383
1384 SyncNode(file);
1385
1386 return WriteDir(node, entries);
1387 }
1388
1389 int Ext2Volume::Unlink(Ext2Node* node, DirectoryEntry* ent, bool unlinkDirectories){
1390 List<DirectoryEntry> entries;

Callers 3

SysLinkFunction · 0.45
LinkFunction · 0.45
RenameFunction · 0.45

Calls 6

ErrorFunction · 0.85
strcmpFunction · 0.85
WarningFunction · 0.85
AcquireWriteMethod · 0.80
ReleaseWriteMethod · 0.80
add_backMethod · 0.45

Tested by

no test coverage detected