RTEMS 6.1-rc1
bdpart.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: BSD-2-Clause */
2
11/*
12 * Copyright (C) 2009, 2012 embedded brains GmbH & Co. KG
13 *
14 * Redistribution and use in source and binary forms, with or without
15 * modification, are permitted provided that the following conditions
16 * are met:
17 * 1. Redistributions of source code must retain the above copyright
18 * notice, this list of conditions and the following disclaimer.
19 * 2. Redistributions in binary form must reproduce the above copyright
20 * notice, this list of conditions and the following disclaimer in the
21 * documentation and/or other materials provided with the distribution.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
24 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
27 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
31 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33 * POSSIBILITY OF SUCH DAMAGE.
34 */
35
36#ifndef RTEMS_BDPART_H
37#define RTEMS_BDPART_H
38
39#include <uuid/uuid.h>
40
41#include <rtems.h>
42#include <rtems/blkdev.h>
43
44#ifdef __cplusplus
45extern "C" {
46#endif /* __cplusplus */
47
103#define RTEMS_BDPART_MBR_EMPTY 0x0U
104
105#define RTEMS_BDPART_MBR_FAT_12 0x1U
106
107#define RTEMS_BDPART_MBR_FAT_16 0x4U
108
109#define RTEMS_BDPART_MBR_FAT_16_LBA 0xeU
110
111#define RTEMS_BDPART_MBR_FAT_32 0xbU
112
113#define RTEMS_BDPART_MBR_FAT_32_LBA 0xcU
114
115#define RTEMS_BDPART_MBR_EXTENDED 0x5U
116
117#define RTEMS_BDPART_MBR_DATA 0xdaU
118
119#define RTEMS_BDPART_MBR_GPT 0xeeU
120
121#define RTEMS_BDPART_MBR_FLAG_ACTIVE 0x80U
122
128#define RTEMS_BDPART_PARTITION_NUMBER_HINT 16
129
138
143
147 uuid_t type;
148
152 uuid_t id;
153
157 uint64_t flags;
159
163typedef enum {
168
174
178typedef union {
183
187 struct {
189
193 uint32_t disk_id;
194
203 } mbr;
204
208 struct {
210
214 uuid_t disk_id;
215 } gpt;
217
229 const char *disk_name,
231 rtems_bdpart_partition *partitions,
232 size_t *count
233);
234
239void rtems_bdpart_sort( rtems_bdpart_partition *partitions, size_t count);
240
255 const char *disk_name,
257 const rtems_bdpart_partition *partitions,
258 size_t count
259);
260
272 const char *disk_name,
274 rtems_bdpart_partition *partitions,
275 const unsigned *distribution,
276 size_t count
277);
278
291 const char *disk_name,
292 const rtems_bdpart_partition *partitions,
293 size_t count
294);
295
303
313 const char *disk_name,
314 const rtems_bdpart_partition *partitions,
315 size_t count
316);
317
322void rtems_bdpart_dump( const rtems_bdpart_partition *partitions, size_t count);
323
328void rtems_bdpart_to_partition_type( uint8_t mbr_type, uuid_t type);
329
338 const uuid_t type,
339 uint8_t *mbr_type
340);
341
344#define RTEMS_BDPART_MBR_CYLINDER_SIZE 63
345
346#define RTEMS_BDPART_NUMBER_SIZE 4
347
348#define RTEMS_BDPART_BLOCK_SIZE 512
349
350#define RTEMS_BDPART_MBR_TABLE_ENTRY_SIZE 16
351
352#define RTEMS_BDPART_MBR_OFFSET_TABLE_0 446
353
354#define RTEMS_BDPART_MBR_OFFSET_TABLE_1 \
355 (RTEMS_BDPART_MBR_OFFSET_TABLE_0 + RTEMS_BDPART_MBR_TABLE_ENTRY_SIZE)
356
357#define RTEMS_BDPART_MBR_OFFSET_DISK_ID 440
358
359#define RTEMS_BDPART_MBR_OFFSET_SIGNATURE_0 510
360
361#define RTEMS_BDPART_MBR_OFFSET_SIGNATURE_1 511
362
363#define RTEMS_BDPART_MBR_SIGNATURE_0 0x55U
364
365#define RTEMS_BDPART_MBR_SIGNATURE_1 0xaaU
366
367#define RTEMS_BDPART_MBR_OFFSET_BEGIN 8
368
369#define RTEMS_BDPART_MBR_OFFSET_SIZE 12
370
371#define RTEMS_BDPART_MBR_OFFSET_TYPE 4
372
373#define RTEMS_BDPART_MBR_OFFSET_FLAGS 0
374
375static inline uint8_t rtems_bdpart_mbr_partition_type(
376 const uuid_t type
377)
378{
379 return type [0];
380}
381
382rtems_status_code rtems_bdpart_get_disk_data(
383 const char *disk_name,
384 int *fd_ptr,
385 rtems_disk_device **dd_ptr,
386 rtems_blkdev_bnum *disk_end
387);
388
389#ifdef __cplusplus
390}
391#endif /* __cplusplus */
392
393#endif /* RTEMS_BDPART_H */
Block Device Management.
rtems_status_code
This enumeration provides status codes for directives of the Classic API.
Definition: status.h:85
struct rtems_bdpart_partition rtems_bdpart_partition
bool rtems_bdpart_to_mbr_partition_type(const uuid_t type, uint8_t *mbr_type)
Converts the partition type in type to the MBR partition type.
Definition: bdpart-read.c:66
void rtems_bdpart_to_partition_type(uint8_t mbr_type, uuid_t type)
Returns the partition type for the MBR partition type value mbr_type in type.
Definition: bdpart-read.c:60
rtems_status_code rtems_bdpart_read(const char *disk_name, rtems_bdpart_format *format, rtems_bdpart_partition *partitions, size_t *count)
Reads the partition information from the physical disk device with name disk_name.
Definition: bdpart-read.c:238
rtems_status_code rtems_bdpart_create(const char *disk_name, const rtems_bdpart_format *format, rtems_bdpart_partition *partitions, const unsigned *distribution, size_t count)
Creates a partition table in partitions with count partitions for the physical disk device with name ...
Definition: bdpart-create.c:43
rtems_status_code rtems_bdpart_register(const char *disk_name, const rtems_bdpart_partition *partitions, size_t count)
Registers the partitions as logical disks for the physical disk device with name disk_name.
Definition: bdpart-register.c:79
rtems_bdpart_format_type
Definition: bdpart.h:163
rtems_status_code rtems_bdpart_unregister(const char *disk_name, const rtems_bdpart_partition *partitions, size_t count)
Deletes the logical disks associated with the partitions of the disk device with name disk_name.
rtems_status_code rtems_bdpart_register_from_disk(const char *disk_name)
Definition: bdpart-register.c:142
rtems_status_code rtems_bdpart_write(const char *disk_name, const rtems_bdpart_format *format, const rtems_bdpart_partition *partitions, size_t count)
Writes the partition table to the physical disk device with name disk_name.
Definition: bdpart-write.c:100
void rtems_bdpart_dump(const rtems_bdpart_partition *partitions, size_t count)
Prints the partition table partitions with count partitions to standard output.
Definition: bdpart-dump.c:54
void rtems_bdpart_sort(rtems_bdpart_partition *partitions, size_t count)
Sorts the partition table partitions with count partitions to have ascending begin blocks.
Definition: bdpart-sort.c:59
@ RTEMS_BDPART_FORMAT_MBR
Definition: bdpart.h:167
@ RTEMS_BDPART_FORMAT_GPT
Definition: bdpart.h:172
uint32_t rtems_blkdev_bnum
Block device block index type.
Definition: diskdevs.h:45
This header file defines the RTEMS Classic API.
Definition: mknod-pack_dev.c:254
Definition: bdpart.h:133
uuid_t type
Definition: bdpart.h:147
uint64_t flags
Definition: bdpart.h:157
uuid_t id
Definition: bdpart.h:152
rtems_blkdev_bnum end
Definition: bdpart.h:142
rtems_blkdev_bnum begin
Definition: bdpart.h:137
Description of a disk device (logical and physical disks).
Definition: diskdevs.h:177
Definition: bdpart.h:178
uint32_t disk_id
Definition: bdpart.h:193
uuid_t disk_id
Definition: bdpart.h:214
bool dos_compatibility
Definition: bdpart.h:202
rtems_bdpart_format_type type
Definition: bdpart.h:182