blob: b3e16ea2dc14b9fe9c8be64460eafdd40691b50d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
/*
* Copyright (c) 2020, Liav A. <liavalb@hotmail.co.il>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibPartition/PartitionTable.h>
#ifndef KERNEL
# include <sys/ioctl.h>
#endif
namespace Partition {
#ifdef KERNEL
PartitionTable::PartitionTable(Kernel::StorageDevice const& device)
: m_device(device)
, m_block_size(device.block_size())
{
}
#else
PartitionTable::PartitionTable(NonnullRefPtr<Core::File> device_file)
: m_device_file(device_file)
{
VERIFY(ioctl(m_device_file->leak_fd(), STORAGE_DEVICE_GET_BLOCK_SIZE, &m_block_size) >= 0);
}
#endif
Optional<DiskPartitionMetadata> PartitionTable::partition(unsigned index) const
{
if (index > partitions_count())
return {};
return m_partitions[index];
}
}
|