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

Method InitializePartitions

Kernel/src/storage/diskdevice.cpp:20–53  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

18}
19
20int DiskDevice::InitializePartitions(){
21 static char letter = 'a';
22 for(unsigned i = 0; i < partitions.get_length(); i++){
23 if(fs::FAT32::Identify(partitions.get_at(i)) > 0) {
24 char vname[] = {'h', 'd', letter++, 0};
25 auto vol = new fs::FAT32::Fat32Volume(partitions.get_at(i),vname);
26 fs::volumes->add_back(vol);
27 } else if(fs::Ext2::Identify(partitions.get_at(i)) > 0) {
28 bool systemFound = false;
29
30 for(auto& vol : *fs::volumes){ // First Ext2 partition is mounted as /system
31 if(strcmp(vol->mountPointDirent.name, "system") == 0){
32 systemFound = true; // System partition found
33 }
34 }
35
36 fs::Ext2::Ext2Volume* vol = nullptr;
37
38 if(systemFound){
39 char vname[] = {'h', 'd', letter++, 0};
40 vol = new fs::Ext2::Ext2Volume(partitions.get_at(i), vname);
41 } else {
42 vol = new fs::Ext2::Ext2Volume(partitions.get_at(i), "system");
43 }
44
45 if(!vol->Error())
46 fs::volumes->add_back(vol);
47 else
48 delete vol;
49 }
50 }
51
52 return 0;
53}
54
55int DiskDevice::ReadDiskBlock(uint64_t lba, uint32_t count, void* buffer){
56 return -1;

Callers

nothing calls this directly

Calls 6

strcmpFunction · 0.85
get_atMethod · 0.80
ErrorMethod · 0.80
IdentifyFunction · 0.50
get_lengthMethod · 0.45
add_backMethod · 0.45

Tested by

no test coverage detected