Commit a78f78ebeb51169ce0ae22f2cd6db93ca33b20e3
Committed by
Tom Rini
1 parent
437a7293a7
Exists in
v2017.01-smarct4x
and in
34 other branches
common: cmd_part: Proper alignment
This fixes a misaligned declaration. Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
Showing 1 changed file with 1 additions and 1 deletions Inline Diff
common/cmd_part.c
1 | /* | 1 | /* |
2 | * Copyright (c) 2012, NVIDIA CORPORATION. All rights reserved. | 2 | * Copyright (c) 2012, NVIDIA CORPORATION. All rights reserved. |
3 | * | 3 | * |
4 | * made from cmd_ext2, which was: | 4 | * made from cmd_ext2, which was: |
5 | * | 5 | * |
6 | * (C) Copyright 2004 | 6 | * (C) Copyright 2004 |
7 | * esd gmbh <www.esd-electronics.com> | 7 | * esd gmbh <www.esd-electronics.com> |
8 | * Reinhard Arlt <reinhard.arlt@esd-electronics.com> | 8 | * Reinhard Arlt <reinhard.arlt@esd-electronics.com> |
9 | * | 9 | * |
10 | * made from cmd_reiserfs by | 10 | * made from cmd_reiserfs by |
11 | * | 11 | * |
12 | * (C) Copyright 2003 - 2004 | 12 | * (C) Copyright 2003 - 2004 |
13 | * Sysgo Real-Time Solutions, AG <www.elinos.com> | 13 | * Sysgo Real-Time Solutions, AG <www.elinos.com> |
14 | * Pavel Bartusek <pba@sysgo.com> | 14 | * Pavel Bartusek <pba@sysgo.com> |
15 | * | 15 | * |
16 | * SPDX-License-Identifier: GPL-2.0+ | 16 | * SPDX-License-Identifier: GPL-2.0+ |
17 | */ | 17 | */ |
18 | 18 | ||
19 | #include <common.h> | 19 | #include <common.h> |
20 | #include <config.h> | 20 | #include <config.h> |
21 | #include <command.h> | 21 | #include <command.h> |
22 | #include <part.h> | 22 | #include <part.h> |
23 | #include <vsprintf.h> | 23 | #include <vsprintf.h> |
24 | 24 | ||
25 | #ifndef CONFIG_PARTITION_UUIDS | 25 | #ifndef CONFIG_PARTITION_UUIDS |
26 | #error CONFIG_PARTITION_UUIDS must be enabled for CONFIG_CMD_PART to be enabled | 26 | #error CONFIG_PARTITION_UUIDS must be enabled for CONFIG_CMD_PART to be enabled |
27 | #endif | 27 | #endif |
28 | 28 | ||
29 | static int do_part_uuid(int argc, char * const argv[]) | 29 | static int do_part_uuid(int argc, char * const argv[]) |
30 | { | 30 | { |
31 | int part; | 31 | int part; |
32 | block_dev_desc_t *dev_desc; | 32 | block_dev_desc_t *dev_desc; |
33 | disk_partition_t info; | 33 | disk_partition_t info; |
34 | 34 | ||
35 | if (argc < 2) | 35 | if (argc < 2) |
36 | return CMD_RET_USAGE; | 36 | return CMD_RET_USAGE; |
37 | if (argc > 3) | 37 | if (argc > 3) |
38 | return CMD_RET_USAGE; | 38 | return CMD_RET_USAGE; |
39 | 39 | ||
40 | part = get_device_and_partition(argv[0], argv[1], &dev_desc, &info, 0); | 40 | part = get_device_and_partition(argv[0], argv[1], &dev_desc, &info, 0); |
41 | if (part < 0) | 41 | if (part < 0) |
42 | return 1; | 42 | return 1; |
43 | 43 | ||
44 | if (argc > 2) | 44 | if (argc > 2) |
45 | setenv(argv[2], info.uuid); | 45 | setenv(argv[2], info.uuid); |
46 | else | 46 | else |
47 | printf("%s\n", info.uuid); | 47 | printf("%s\n", info.uuid); |
48 | 48 | ||
49 | return 0; | 49 | return 0; |
50 | } | 50 | } |
51 | 51 | ||
52 | static int do_part_list(int argc, char * const argv[]) | 52 | static int do_part_list(int argc, char * const argv[]) |
53 | { | 53 | { |
54 | int ret; | 54 | int ret; |
55 | block_dev_desc_t *desc; | 55 | block_dev_desc_t *desc; |
56 | char *var = NULL; | 56 | char *var = NULL; |
57 | bool bootable = false; | 57 | bool bootable = false; |
58 | int i; | 58 | int i; |
59 | 59 | ||
60 | if (argc < 2) | 60 | if (argc < 2) |
61 | return CMD_RET_USAGE; | 61 | return CMD_RET_USAGE; |
62 | 62 | ||
63 | if (argc > 2) { | 63 | if (argc > 2) { |
64 | for (i = 2; i < argc ; i++) { | 64 | for (i = 2; i < argc ; i++) { |
65 | if (argv[i][0] == '-') { | 65 | if (argv[i][0] == '-') { |
66 | if (!strcmp(argv[i], "-bootable")) { | 66 | if (!strcmp(argv[i], "-bootable")) { |
67 | bootable = true; | 67 | bootable = true; |
68 | } else { | 68 | } else { |
69 | printf("Unknown option %s\n", argv[i]); | 69 | printf("Unknown option %s\n", argv[i]); |
70 | return CMD_RET_USAGE; | 70 | return CMD_RET_USAGE; |
71 | } | 71 | } |
72 | } else { | 72 | } else { |
73 | var = argv[i]; | 73 | var = argv[i]; |
74 | break; | 74 | break; |
75 | } | 75 | } |
76 | } | 76 | } |
77 | 77 | ||
78 | /* Loops should have been exited at the last argument, which | 78 | /* Loops should have been exited at the last argument, which |
79 | * as it contained the variable */ | 79 | * as it contained the variable */ |
80 | if (argc != i + 1) | 80 | if (argc != i + 1) |
81 | return CMD_RET_USAGE; | 81 | return CMD_RET_USAGE; |
82 | } | 82 | } |
83 | 83 | ||
84 | ret = get_device(argv[0], argv[1], &desc); | 84 | ret = get_device(argv[0], argv[1], &desc); |
85 | if (ret < 0) | 85 | if (ret < 0) |
86 | return 1; | 86 | return 1; |
87 | 87 | ||
88 | if (var != NULL) { | 88 | if (var != NULL) { |
89 | int p; | 89 | int p; |
90 | char str[512] = { '\0', }; | 90 | char str[512] = { '\0', }; |
91 | disk_partition_t info; | 91 | disk_partition_t info; |
92 | 92 | ||
93 | for (p = 1; p < 128; p++) { | 93 | for (p = 1; p < 128; p++) { |
94 | char t[5]; | 94 | char t[5]; |
95 | int r = get_partition_info(desc, p, &info); | 95 | int r = get_partition_info(desc, p, &info); |
96 | 96 | ||
97 | if (r != 0) | 97 | if (r != 0) |
98 | continue; | 98 | continue; |
99 | 99 | ||
100 | if (bootable && !info.bootable) | 100 | if (bootable && !info.bootable) |
101 | continue; | 101 | continue; |
102 | 102 | ||
103 | sprintf(t, "%s%d", str[0] ? " " : "", p); | 103 | sprintf(t, "%s%d", str[0] ? " " : "", p); |
104 | strcat(str, t); | 104 | strcat(str, t); |
105 | } | 105 | } |
106 | setenv(var, str); | 106 | setenv(var, str); |
107 | return 0; | 107 | return 0; |
108 | } | 108 | } |
109 | 109 | ||
110 | print_part(desc); | 110 | print_part(desc); |
111 | 111 | ||
112 | return 0; | 112 | return 0; |
113 | } | 113 | } |
114 | 114 | ||
115 | static int do_part(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) | 115 | static int do_part(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
116 | { | 116 | { |
117 | if (argc < 2) | 117 | if (argc < 2) |
118 | return CMD_RET_USAGE; | 118 | return CMD_RET_USAGE; |
119 | 119 | ||
120 | if (!strcmp(argv[1], "uuid")) | 120 | if (!strcmp(argv[1], "uuid")) |
121 | return do_part_uuid(argc - 2, argv + 2); | 121 | return do_part_uuid(argc - 2, argv + 2); |
122 | else if (!strcmp(argv[1], "list")) | 122 | else if (!strcmp(argv[1], "list")) |
123 | return do_part_list(argc - 2, argv + 2); | 123 | return do_part_list(argc - 2, argv + 2); |
124 | 124 | ||
125 | return CMD_RET_USAGE; | 125 | return CMD_RET_USAGE; |
126 | } | 126 | } |
127 | 127 | ||
128 | U_BOOT_CMD( | 128 | U_BOOT_CMD( |
129 | part, CONFIG_SYS_MAXARGS, 1, do_part, | 129 | part, CONFIG_SYS_MAXARGS, 1, do_part, |
130 | "disk partition related commands", | 130 | "disk partition related commands", |
131 | "uuid <interface> <dev>:<part>\n" | 131 | "uuid <interface> <dev>:<part>\n" |
132 | " - print partition UUID\n" | 132 | " - print partition UUID\n" |
133 | "part uuid <interface> <dev>:<part> <varname>\n" | 133 | "part uuid <interface> <dev>:<part> <varname>\n" |
134 | " - set environment variable to partition UUID\n" | 134 | " - set environment variable to partition UUID\n" |
135 | "part list <interface> <dev>\n" | 135 | "part list <interface> <dev>\n" |
136 | " - print a device's partition table\n" | 136 | " - print a device's partition table\n" |
137 | "part list <interface> <dev> [flags] <varname>\n" | 137 | "part list <interface> <dev> [flags] <varname>\n" |
138 | " - set environment variable to the list of partitions\n" | 138 | " - set environment variable to the list of partitions\n" |
139 | " flags can be -bootable (list only bootable partitions)" | 139 | " flags can be -bootable (list only bootable partitions)" |
140 | ); | 140 | ); |
141 | 141 |