return ret;
}
+struct hw_disk** hw_select_first_disk(const struct hw_disk** disks) {
+ struct hw_disk** ret = hw_create_disks();
+ struct hw_disk** selected_disks = ret;
+
+ unsigned int num_disks = hw_count_disks(disks);
+ assert(num_disks > 0);
+
+ for (unsigned int i = 0; i < num_disks; i++) {
+ struct hw_disk *disk = disks[i];
+ disk->ref++;
+
+ *selected_disks++ = disk;
+ break;
+ }
+
+ // Set sentinel
+ *selected_disks = NULL;
+
+ return ret;
+}
+
static unsigned long long hw_swap_size(struct hw_destination* dest) {
unsigned long long memory = hw_memory();
sync();
sync();
}
+
+int hw_start_networking(const char* output) {
+ return mysystem(output, "/usr/bin/start-networking.sh");
+}
+
+char* hw_find_backup_file(const char* output, const char* search_path) {
+ char path[STRING_SIZE];
+
+ snprintf(path, sizeof(path), "%s/backup.ipf", search_path);
+ int r = access(path, R_OK);
+
+ if (r == 0)
+ return strdup(path);
+
+ return NULL;
+}
+
+int hw_restore_backup(const char* output, const char* backup_path, const char* destination) {
+ char command[STRING_SIZE];
+
+ snprintf(command, sizeof(command), "/bin/tar xzpf %s -C %s", backup_path, destination);
+ int rc = mysystem(output, command);
+
+ if (rc)
+ return -1;
+
+ return 0;
+}