@@ -37,17 +37,18 @@ static void usage(FILE* where, int argc, char* argv[])
37
37
" %s COMMAND\n"
38
38
"\n"
39
39
"Commands:\n"
40
- " %s hal-info - Show info about boot_control HAL used.\n"
41
- " %s get-number-slots - Prints number of slots.\n"
42
- " %s get-current-slot - Prints currently running SLOT.\n"
43
- " %s mark-boot-successful - Mark current slot as GOOD.\n"
44
- " %s set-active-boot-slot SLOT - On next boot, load and execute SLOT.\n"
45
- " %s set-slot-as-unbootable SLOT - Mark SLOT as invalid.\n"
46
- " %s is-slot-bootable SLOT - Returns 0 only if SLOT is bootable.\n"
47
- " %s get-suffix SLOT - Prints suffix for SLOT.\n"
40
+ " %s hal-info - Show info about boot_control HAL used.\n"
41
+ " %s get-number-slots - Prints number of slots.\n"
42
+ " %s get-current-slot - Prints currently running SLOT.\n"
43
+ " %s mark-boot-successful - Mark current slot as GOOD.\n"
44
+ " %s set-active-boot-slot SLOT - On next boot, load and execute SLOT.\n"
45
+ " %s set-slot-as-unbootable SLOT - Mark SLOT as invalid.\n"
46
+ " %s is-slot-bootable SLOT - Returns 0 only if SLOT is bootable.\n"
47
+ " %s is-slot-marked-successful SLOT - Returns 0 only if SLOT is marked GOOD.\n"
48
+ " %s get-suffix SLOT - Prints suffix for SLOT.\n"
48
49
"\n"
49
50
"SLOT parameter is the zero-based slot-number.\n" ,
50
- argv [0 ], argv [0 ], argv [0 ], argv [0 ], argv [0 ],
51
+ argv [0 ], argv [0 ], argv [0 ], argv [0 ], argv [0 ], argv [ 0 ],
51
52
argv [0 ], argv [0 ], argv [0 ], argv [0 ], argv [0 ]);
52
53
}
53
54
@@ -112,8 +113,13 @@ static int do_set_slot_as_unbootable(boot_control_module_t *module,
112
113
static int do_is_slot_bootable (boot_control_module_t * module , int slot_number )
113
114
{
114
115
int ret = module -> isSlotBootable (module , slot_number );
115
- if (ret == 0 )
116
+ if (ret == 0 ) {
117
+ return EX_SOFTWARE ;
118
+ } else if (ret < 0 ) {
119
+ fprintf (stderr , "Error calling isSlotBootable(): %s\n" ,
120
+ strerror (- ret ));
116
121
return EX_SOFTWARE ;
122
+ }
117
123
return EX_OK ;
118
124
}
119
125
@@ -125,6 +131,24 @@ static int do_get_suffix(boot_control_module_t *module, int slot_number)
125
131
return EX_OK ;
126
132
}
127
133
134
+ static int do_is_slot_marked_successful (boot_control_module_t * module ,
135
+ int slot_number )
136
+ {
137
+ if (module -> isSlotMarkedSuccessful == NULL ) {
138
+ fprintf (stderr , "isSlotMarkedSuccessful() is not implemented by HAL.\n" );
139
+ return EX_UNAVAILABLE ;
140
+ }
141
+ int ret = module -> isSlotMarkedSuccessful (module , slot_number );
142
+ if (ret == 0 ) {
143
+ return EX_SOFTWARE ;
144
+ } else if (ret < 0 ) {
145
+ fprintf (stderr , "Error calling isSlotMarkedSuccessful(): %s\n" ,
146
+ strerror (- ret ));
147
+ return EX_SOFTWARE ;
148
+ }
149
+ return EX_OK ;
150
+ }
151
+
128
152
static int parse_slot (int pos , int argc , char * argv [])
129
153
{
130
154
if (pos > argc - 1 ) {
@@ -177,6 +201,8 @@ int main(int argc, char *argv[])
177
201
return do_is_slot_bootable (module , parse_slot (2 , argc , argv ));
178
202
} else if (strcmp (argv [1 ], "get-suffix" ) == 0 ) {
179
203
return do_get_suffix (module , parse_slot (2 , argc , argv ));
204
+ } else if (strcmp (argv [1 ], "is-slot-marked-successful" ) == 0 ) {
205
+ return do_is_slot_marked_successful (module , parse_slot (2 , argc , argv ));
180
206
} else {
181
207
usage (stderr , argc , argv );
182
208
return EX_USAGE ;
0 commit comments