Skip to content

Commit a3b2204

Browse files
Remove SD Card migration (#228)
Co-authored-by: madelen-at-work <madelen-at-work@users.noreply.github.com>
1 parent 116321f commit a3b2204

File tree

1 file changed

+1
-60
lines changed

1 file changed

+1
-60
lines changed

app/dockerdwrapper.c

Lines changed: 1 addition & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ typedef enum {
5252
STATUS_NO_SD_CARD,
5353
STATUS_SD_CARD_WRONG_FS,
5454
STATUS_SD_CARD_WRONG_PERMISSION,
55-
STATUS_SD_CARD_MIGRATION_FAILED,
5655
STATUS_CODE_COUNT,
5756
} status_code_t;
5857

@@ -64,8 +63,7 @@ static const char* const status_code_strs[STATUS_CODE_COUNT] = {"-1 NOT STARTED"
6463
"4 NO SOCKET",
6564
"5 NO SD CARD",
6665
"6 SD CARD WRONG FS",
67-
"7 SD CARD WRONG PERMISSION",
68-
"8 SD CARD MIGRATION FAILED"};
66+
"7 SD CARD WRONG PERMISSION"};
6967

7068
struct settings {
7169
char* data_root;
@@ -258,57 +256,6 @@ static char* get_parameter_value(AXParameter* param_handle, const char* paramete
258256
return parameter_value;
259257
}
260258

261-
/**
262-
* @brief Migrate the contents of the data directory from the old setup on the
263-
* SD card to 'new_dir' The new directory must be created and empty. If the
264-
* operation is successful, the old setup directory will be removed.
265-
*
266-
* @return True if operation was successful, false otherwise.
267-
*/
268-
static bool migrate_from_old_sdcard_setup(const char* new_dir) {
269-
const char* old_top_dir = "/var/spool/storage/SD_DISK/dockerd";
270-
struct stat directory_stat;
271-
int stat_result = stat(old_top_dir, &directory_stat);
272-
if (stat(old_top_dir, &directory_stat) != 0) {
273-
// No files to move
274-
return true;
275-
}
276-
277-
// The new directory must be created and empty.
278-
GDir* dir = g_dir_open(new_dir, 0, NULL);
279-
if (dir == NULL) {
280-
log_error("Failed to open %s", new_dir);
281-
return false;
282-
}
283-
// Get name to first entry in directory, NULL if empty, . and .. are omitted
284-
const char* dir_entry = g_dir_read_name(dir);
285-
bool directory_not_empty = dir_entry != NULL;
286-
g_dir_close(dir);
287-
288-
if (directory_not_empty) {
289-
log_error("Target directory %s is not empty. Will not move files.", new_dir);
290-
return false;
291-
}
292-
293-
// Move data from the old directory
294-
const char* move_command = g_strdup_printf("mv %s/data/* %s/.", old_top_dir, new_dir);
295-
log_info("Run move cmd: \"%s\"", move_command);
296-
int res = system(move_command);
297-
if (res != 0) {
298-
log_error("Failed to move %s to %s, error: %d", old_top_dir, new_dir, res);
299-
return false;
300-
}
301-
302-
// Remove the directory
303-
const char* remove_command = g_strdup_printf("rm -rf %s", old_top_dir);
304-
res = system(remove_command);
305-
if (res != 0) {
306-
log_error("Failed to remove %s, error: %d", old_top_dir, res);
307-
}
308-
309-
return res == 0;
310-
}
311-
312259
/**
313260
* @brief Retrieve the file system type of the device containing this path.
314261
*
@@ -394,12 +341,6 @@ static bool setup_sdcard(AXParameter* param_handle, const char* data_root) {
394341
return false;
395342
}
396343

397-
if (!migrate_from_old_sdcard_setup(data_root)) {
398-
log_error("Failed to migrate data from old data-root");
399-
set_status_parameter(param_handle, STATUS_SD_CARD_MIGRATION_FAILED);
400-
return false;
401-
}
402-
403344
return true;
404345
}
405346

0 commit comments

Comments
 (0)