File tree 1 file changed +19
-2
lines changed
1 file changed +19
-2
lines changed Original file line number Diff line number Diff line change 8
8
#include < sys/ioctl.h>
9
9
#include < bluetooth/bluetooth.h>
10
10
#include < bluetooth/hci.h>
11
+ #include < cerrno>
12
+ #include < iostream>
13
+ #include < cstring>
11
14
12
15
#ifdef USE_X11
13
16
#include < thread>
@@ -154,11 +157,24 @@ void portduinoAddArguments(const struct argp_child &child,
154
157
}
155
158
156
159
void reboot () {
157
- execv (progArgv[0 ], progArgv);
160
+ int err = execv (progArgv[0 ], progArgv);
161
+ printf (" execv() returned %i!\n " , err);
162
+ std::cout << " error: " << std::strerror (errno) << ' \n ' ;
163
+ exit (EXIT_FAILURE);
158
164
}
159
165
160
166
int main (int argc, char *argv[]) {
161
- progArgv = argv;
167
+
168
+ progArgv = (char **) malloc ((argc + 1 ) * sizeof (char *)); // New pointer array, argc + 1 to hold the final null
169
+ int j = 0 ;
170
+ for (int i = 0 ; i < argc; i++) { // iterate through the arguments, stripping out the erase command, to avoid erase on reboot()
171
+ if (strcmp (argv[i], " -e" ) != 0 && strcmp (argv[i], " --erase" ) != 0 ) {
172
+ progArgv[j] = argv[i];
173
+ j++;
174
+ }
175
+ }
176
+ progArgv[j] = NULL ;
177
+
162
178
portduinoCustomInit ();
163
179
164
180
auto *args = &portduinoArguments;
@@ -189,6 +205,7 @@ int main(int argc, char *argv[]) {
189
205
int status = mkdir (fsRoot.c_str (), 0700 );
190
206
if (status != 0 && errno == EEXIST && args->erase ) {
191
207
// Remove contents of existing VFS root directory
208
+ std::cout << " Erasing virtual Filesystem!" << std::endl;
192
209
rmrf (const_cast <char *>(fsRoot.c_str ()));
193
210
}
194
211
You can’t perform that action at this time.
0 commit comments