RTEMS  5.1
bdpart.h
Go to the documentation of this file.
1 
9 /*
10  * Copyright (c) 2009-2012 embedded brains GmbH. All rights reserved.
11  *
12  * embedded brains GmbH
13  * Obere Lagerstr. 30
14  * 82178 Puchheim
15  * Germany
16  * <rtems@embedded-brains.de>
17  *
18  * The license and distribution terms for this file may be
19  * found in the file LICENSE in this distribution or at
20  * http://www.rtems.org/license/LICENSE.
21  */
22 
23 #ifndef RTEMS_BDPART_H
24 #define RTEMS_BDPART_H
25 
26 #include <uuid/uuid.h>
27 
28 #include <rtems.h>
29 #include <rtems/blkdev.h>
30 
31 #ifdef __cplusplus
32 extern "C" {
33 #endif /* __cplusplus */
34 
90 #define RTEMS_BDPART_MBR_EMPTY 0x0U
91 
92 #define RTEMS_BDPART_MBR_FAT_12 0x1U
93 
94 #define RTEMS_BDPART_MBR_FAT_16 0x4U
95 
96 #define RTEMS_BDPART_MBR_FAT_16_LBA 0xeU
97 
98 #define RTEMS_BDPART_MBR_FAT_32 0xbU
99 
100 #define RTEMS_BDPART_MBR_FAT_32_LBA 0xcU
101 
102 #define RTEMS_BDPART_MBR_EXTENDED 0x5U
103 
104 #define RTEMS_BDPART_MBR_DATA 0xdaU
105 
106 #define RTEMS_BDPART_MBR_GPT 0xeeU
107 
108 #define RTEMS_BDPART_MBR_FLAG_ACTIVE 0x80U
109 
115 #define RTEMS_BDPART_PARTITION_NUMBER_HINT 16
116 
120 typedef struct rtems_bdpart_partition {
125 
130 
134  uuid_t type;
135 
139  uuid_t id;
140 
144  uint64_t flags;
146 
150 typedef enum {
155 
161 
165 typedef union {
170 
174  struct {
176 
180  uint32_t disk_id;
181 
190  } mbr;
191 
195  struct {
197 
201  uuid_t disk_id;
202  } gpt;
204 
216  const char *disk_name,
218  rtems_bdpart_partition *partitions,
219  size_t *count
220 );
221 
226 void rtems_bdpart_sort( rtems_bdpart_partition *partitions, size_t count);
227 
242  const char *disk_name,
244  const rtems_bdpart_partition *partitions,
245  size_t count
246 );
247 
259  const char *disk_name,
261  rtems_bdpart_partition *partitions,
262  const unsigned *distribution,
263  size_t count
264 );
265 
278  const char *disk_name,
279  const rtems_bdpart_partition *partitions,
280  size_t count
281 );
282 
289 rtems_status_code rtems_bdpart_register_from_disk( const char *disk_name);
290 
300  const char *disk_name,
301  const rtems_bdpart_partition *partitions,
302  size_t count
303 );
304 
320  const char *disk_name,
321  const rtems_bdpart_partition *partitions,
322  size_t count,
323  const char *mount_base
324 );
325 
330  const char *disk_name,
331  const rtems_bdpart_partition *partitions,
332  size_t count,
333  const char *mount_base
334 );
335 
340 void rtems_bdpart_dump( const rtems_bdpart_partition *partitions, size_t count);
341 
346 void rtems_bdpart_to_partition_type( uint8_t mbr_type, uuid_t type);
347 
356  const uuid_t type,
357  uint8_t *mbr_type
358 );
359 
362 #define RTEMS_BDPART_MBR_CYLINDER_SIZE 63
363 
364 #define RTEMS_BDPART_NUMBER_SIZE 4
365 
366 #define RTEMS_BDPART_BLOCK_SIZE 512
367 
368 #define RTEMS_BDPART_MBR_TABLE_ENTRY_SIZE 16
369 
370 #define RTEMS_BDPART_MBR_OFFSET_TABLE_0 446
371 
372 #define RTEMS_BDPART_MBR_OFFSET_TABLE_1 \
373  (RTEMS_BDPART_MBR_OFFSET_TABLE_0 + RTEMS_BDPART_MBR_TABLE_ENTRY_SIZE)
374 
375 #define RTEMS_BDPART_MBR_OFFSET_DISK_ID 440
376 
377 #define RTEMS_BDPART_MBR_OFFSET_SIGNATURE_0 510
378 
379 #define RTEMS_BDPART_MBR_OFFSET_SIGNATURE_1 511
380 
381 #define RTEMS_BDPART_MBR_SIGNATURE_0 0x55U
382 
383 #define RTEMS_BDPART_MBR_SIGNATURE_1 0xaaU
384 
385 #define RTEMS_BDPART_MBR_OFFSET_BEGIN 8
386 
387 #define RTEMS_BDPART_MBR_OFFSET_SIZE 12
388 
389 #define RTEMS_BDPART_MBR_OFFSET_TYPE 4
390 
391 #define RTEMS_BDPART_MBR_OFFSET_FLAGS 0
392 
393 static inline uint8_t rtems_bdpart_mbr_partition_type(
394  const uuid_t type
395 )
396 {
397  return type [0];
398 }
399 
400 rtems_status_code rtems_bdpart_get_disk_data(
401  const char *disk_name,
402  int *fd_ptr,
403  rtems_disk_device **dd_ptr,
404  rtems_blkdev_bnum *disk_end
405 );
406 
407 #ifdef __cplusplus
408 }
409 #endif /* __cplusplus */
410 
411 #endif /* RTEMS_BDPART_H */
struct rtems_bdpart_partition rtems_bdpart_partition
uint32_t rtems_blkdev_bnum
Block device block index type.
Definition: diskdevs.h:45
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:52
uuid_t id
Definition: bdpart.h:139
rtems_bdpart_format_type
Definition: bdpart.h:150
uuid_t type
Definition: bdpart.h:134
uint64_t flags
Definition: bdpart.h:144
Definition: mknod-pack_dev.c:254
rtems_blkdev_bnum end
Definition: bdpart.h:129
rtems_status_code rtems_bdpart_unmount(const char *disk_name, const rtems_bdpart_partition *partitions, size_t count, const char *mount_base)
Unmounts all file systems mounted with rtems_bdpart_mount().
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:64
rtems_status_code rtems_bdpart_mount(const char *disk_name, const rtems_bdpart_partition *partitions, size_t count, const char *mount_base)
Mounts all supported file systems inside the logical disks derived from the partitions of the physica...
Definition: bdpart.h:165
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:224
Description of a disk device (logical and physical disks).
Definition: diskdevs.h:157
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:45
rtems_status_code
Classic API Status.
Definition: status.h:43
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:46
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.
Definition: bdpart.h:159
rtems_status_code rtems_bdpart_register_from_disk(const char *disk_name)
Definition: bdpart-register.c:127
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:40
bool dos_compatibility
Definition: bdpart.h:189
rtems_bdpart_format_type type
Definition: bdpart.h:169
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:86
Definition: bdpart.h:120
uuid_t disk_id
Definition: bdpart.h:201
uint32_t disk_id
Definition: bdpart.h:180
Definition: bdpart.h:154
Block Device Management.
rtems_blkdev_bnum begin
Definition: bdpart.h:124
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:29