Chameleon

Chameleon Svn Source Tree

Root/branches/xZenu/src/modules/Disk/Disk.cpp

Source at commit 1406 created 12 years 10 months ago.
By meklort, Revert drivers.c so that kexts are only loaded when OSBundleRequired is set and that value is not safe mode. Added some comments about it too.
1/*
2 * Copyright (c) 2011 Evan Lojewski. All rights reserved.
3 *
4 */
5#include <Disk.hpp>
6
7Disk* Disk::gFirstDisk = NULL;
8
9
10Disk::Disk()
11{
12mNextDisk = NULL;
13 mName = NULL;
14 mPartitions = NULL;
15
16// Add disk entry to list
17
18Disk* list = gFirstDisk;
19if(!list) gFirstDisk = this;
20else {
21while(list->getNextDisk())
22{
23list = list->getNextDisk();
24}
25// Last disk found, add use to the end of the list
26
27list->setNextDisk(this);
28}
29
30}
31
32Disk::~Disk()
33{
34// remove disk entry from list
35if(getPrevDisk() != NULL) getPrevDisk()->setNextDisk(getNextDisk());
36else gFirstDisk = NULL;
37}
38
39Partition* Disk::getPartition(UInt32 index)
40{
41 PartitionList* current = mPartitions;
42 while(current)
43 {
44 if(current->entry->getPartitionNumber() == index)
45 {
46 return current->entry;
47 }
48 else
49 {
50 current = current->next;
51 }
52 }
53
54 return NULL;
55}
56
57void Disk::addPartition(Partition* partition)
58{
59 PartitionList* list = new PartitionList;
60 list->entry = partition;
61 list->next = mPartitions;
62 mPartitions = list;
63}

Archive Download this file

Revision: 1406