| 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; |
no test coverage detected