OLD | NEW |
1 /* Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 1 /* Copyright (c) 2010 The Chromium OS Authors. All rights reserved. |
2 * Use of this source code is governed by a BSD-style license that can be | 2 * Use of this source code is governed by a BSD-style license that can be |
3 * found in the LICENSE file. | 3 * found in the LICENSE file. |
4 * | 4 * |
5 * Update GPT attribute bits. | 5 * Update GPT attribute bits. |
6 */ | 6 */ |
7 #include <getopt.h> | 7 #include <getopt.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 #include <stdio.h> | 9 #include <stdio.h> |
10 #include <stdlib.h> | 10 #include <stdlib.h> |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 return CGPT_FAILED; | 118 return CGPT_FAILED; |
119 } | 119 } |
120 } | 120 } |
121 } | 121 } |
122 return CGPT_OK; | 122 return CGPT_OK; |
123 } | 123 } |
124 | 124 |
125 int OpenDriveInLastArgument(const int argc, | 125 int OpenDriveInLastArgument(const int argc, |
126 char *const *argv, | 126 char *const *argv, |
127 struct drive *drive) { | 127 struct drive *drive) { |
128 /* Then, we need a non-option argument. */ | 128 if (optind != (argc - 1)) { |
129 if (optind == (argc - 1)) { | |
130 char *path, drive_path[256]; | |
131 path = argv[optind]; | |
132 switch (path[0]) { | |
133 case '.': | |
134 case '/': | |
135 snprintf(drive_path, sizeof(drive_path), "%s", path); | |
136 break; | |
137 default: | |
138 snprintf(drive_path, sizeof(drive_path), "/dev/%s", path); | |
139 break; | |
140 } | |
141 if (CGPT_OK != DriveOpen(drive_path, drive)) { | |
142 printf("[ERROR] DriveOpen(%s) error!\n", drive_path); | |
143 return CGPT_FAILED; | |
144 } | |
145 } else { | |
146 printf("[ERROR] One (and only one) non-option argument is required.\n"); | 129 printf("[ERROR] One (and only one) non-option argument is required.\n"); |
147 return CGPT_FAILED; | 130 return CGPT_FAILED; |
148 } | 131 } |
149 | 132 |
150 return CGPT_OK; | 133 return DriveOpen(argv[optind], drive); |
151 } | 134 } |
OLD | NEW |