vfs: check userland buffers before reading them.
[haiku.git] / src / add-ons / kernel / partitioning_systems / apple / apple.h
blob25a6e17b9e03da84047efcd98187394f50987048
1 /*
2 ** Copyright 2003, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
3 ** Distributed under the terms of the MIT License.
4 */
5 #ifndef APPLE_H
6 #define APPLE_H
9 #include "SupportDefs.h"
10 #include "ByteOrder.h"
13 enum apple_signature {
14 kDriverDescriptorSignature = 'ER',
15 kPartitionMapSignature = 'PM',
16 kObsoletePartitionMapSignature = 'TS',
20 struct apple_driver_descriptor {
21 int16 signature;
22 int16 block_size;
23 int32 block_count;
24 int16 type; // reserved
25 int16 id; // "
26 int32 data; // "
27 int16 descriptor_count;
28 int32 driver_block;
29 int16 driver_size;
30 int16 os_type; // operating system type
32 int16 BlockSize() { return B_BENDIAN_TO_HOST_INT16(block_size); }
33 int32 BlockCount() { return B_BENDIAN_TO_HOST_INT32(block_count); }
35 bool HasValidSignature() { return B_BENDIAN_TO_HOST_INT16(signature) == kDriverDescriptorSignature; }
38 struct apple_partition_map {
39 int16 signature;
40 int16 _reserved0;
41 int32 map_block_count;
42 int32 start; // in blocks
43 int32 size;
44 char name[32];
45 char type[32];
46 int32 data_start; // in blocks
47 int32 data_size;
48 int32 status;
49 int32 boot_start;
50 int32 boot_size;
51 int32 boot_address;
52 int32 _reserved1;
53 int32 boot_entry;
54 int32 _reserved2;
55 int32 boot_code_checksum;
56 char processor_type[16];
58 int32 StartBlock() { return B_BENDIAN_TO_HOST_INT32(start); }
59 int32 BlockCount() { return B_BENDIAN_TO_HOST_INT32(size); }
60 uint64 Start(apple_driver_descriptor &descriptor) { return StartBlock() * descriptor.BlockSize(); }
61 uint64 Size(apple_driver_descriptor &descriptor) { return BlockCount() * descriptor.BlockSize(); }
63 bool HasValidSignature();
67 inline bool
68 apple_partition_map::HasValidSignature()
70 int16 sig = B_BENDIAN_TO_HOST_INT16(signature);
72 return sig == kPartitionMapSignature
73 || sig == kObsoletePartitionMapSignature;
77 enum partition_status {
78 kPartitionIsValid = 0x00000001,
79 kPartitionIsAllocated = 0x00000002,
80 kPartitionIsInUse = 0x00000004,
81 kPartitionIsBootValid = 0x00000008,
82 kPartitionIsReadable = 0x00000010,
83 kPartitionAUXIsWriteable = 0x00000020, // dunno why IsWriteable is here twice...
84 kPartitionIsBootPIC = 0x00000040,
85 kPartitionIsWriteable = 0x00000020,
86 kPartitionIsMounted = 0x40000000,
87 kPartitionIsStartup = 0x80000000,
88 kPartitionIsChainCompatible = 0x00000100,
89 kPartitionIsRealDeviceDriver = 0x00000200,
90 kPartitionCanChainToNext = 0x00000400,
93 #endif /* APPLE_H */