source: rtems/cpukit/libblock/src/bdpart-dump.c @ e682fffd

4.104.115
Last change on this file since e682fffd was 6780829, checked in by Sebastian Huber <sebastian.huber@…>, on 04/30/10 at 08:42:13

2010-04-30 Sebastian Huber <sebastian.huber@…>

  • libblock/src/bdpart.c: Removed file.
  • libblock/src/bdpart-create.c, libblock/src/bdpart-dump.c, libblock/src/bdpart-mount.c, libblock/src/bdpart-read.c, libblock/src/bdpart-register.c, libblock/src/bdpart-sort.c, libblock/src/bdpart-write.c: New files.
  • libblock/include/rtems/bdpart.h: Moved some definitions from bdpart.c.
  • libblock/Makefile.am: Update for file changes.
  • Property mode set to 100644
File size: 2.3 KB
Line 
1/**
2 * @file
3 *
4 * @ingroup rtems_bdpart
5 *
6 * Block device partition management.
7 */
8
9/*
10 * Copyright (c) 2009, 2010
11 * embedded brains GmbH
12 * Obere Lagerstr. 30
13 * D-82178 Puchheim
14 * Germany
15 * <rtems@embedded-brains.de>
16 *
17 * The license and distribution terms for this file may be
18 * found in the file LICENSE in this distribution or at
19 * http://www.rtems.com/license/LICENSE.
20 */
21
22#ifdef HAVE_CONFIG_H
23#include "config.h"
24#endif
25
26#include <stdio.h>
27#include <inttypes.h>
28
29#include <rtems.h>
30#include <rtems/bdpart.h>
31
32static void rtems_bdpart_type_to_string(
33  const uuid_t type,
34  char str [37]
35)
36{
37  uuid_unparse_lower( type, str);
38}
39
40void rtems_bdpart_dump( const rtems_bdpart_partition *pt, size_t count)
41{
42  size_t i = 0;
43
44  printf(
45    "-------------------------------------------------------------------------------\n"
46    "                                PARTITION TABLE\n"
47    "------------+------------+-----------------------------------------------------\n"
48    " BEGIN      | END        | TYPE\n"
49    "------------+------------+-----------------------------------------------------\n"
50  );
51
52  for (i = 0; i < count; ++i) {
53    const rtems_bdpart_partition *p = pt + i;
54    const char *type = NULL;
55    char type_buffer [52];
56    uint8_t type_mbr = 0;
57
58    if (rtems_bdpart_to_mbr_partition_type( p->type, &type_mbr)) {
59      switch (type_mbr) {
60        case RTEMS_BDPART_MBR_FAT_12:
61          type = "FAT 12";
62          break;
63        case RTEMS_BDPART_MBR_FAT_16:
64          type = "FAT 16";
65          break;
66        case RTEMS_BDPART_MBR_FAT_16_LBA:
67          type = "FAT 16 LBA";
68          break;
69        case RTEMS_BDPART_MBR_FAT_32:
70          type = "FAT 32";
71          break;
72        case RTEMS_BDPART_MBR_FAT_32_LBA:
73          type = "FAT 32 LBA";
74          break;
75        case RTEMS_BDPART_MBR_DATA:
76          type = "DATA";
77          break;
78        default:
79          snprintf( type_buffer, sizeof( type_buffer), "0x%02" PRIx8, type_mbr);
80          type = type_buffer;
81          break;
82      }
83    } else {
84      rtems_bdpart_type_to_string( p->type, type_buffer);
85      type = type_buffer;
86    }
87
88    printf(
89      " %10" PRIu32 " | %10" PRIu32 " |%52s\n",
90      p->begin,
91      p->end,
92      type
93    );
94  }
95
96  puts( "------------+------------+-----------------------------------------------------");
97}
Note: See TracBrowser for help on using the repository browser.