free(disks);
}
-unsigned int hw_count_disks(struct hw_disk** disks) {
+unsigned int hw_count_disks(const struct hw_disk** disks) {
unsigned int ret = 0;
while (*disks++)
struct hw_disk** ret = hw_create_disks();
struct hw_disk** selected_disks = ret;
- unsigned int num_disks = hw_count_disks(disks);
+ unsigned int num_disks = hw_count_disks((const struct hw_disk**)disks);
for (unsigned int i = 0; i < num_disks; i++) {
if (!selection || selection[i]) {
return uuid;
}
+#define FSTAB_FMT "UUID=%s %-8s %-4s %-10s %d %d\n"
+
int hw_write_fstab(struct hw_destination* dest) {
FILE* f = fopen(DESTINATION_MOUNT_PATH "/etc/fstab", "w");
if (!f)
return -1;
- const char* fmt = "UUID=%s %-8s %-4s %-10s %d %d\n";
char* uuid = NULL;
// boot
uuid = hw_get_uuid(dest->part_boot);
if (uuid) {
- fprintf(f, fmt, uuid, "/boot", "auto", "defaults", 1, 2);
+ fprintf(f, FSTAB_FMT, uuid, "/boot", "auto", "defaults", 1, 2);
free(uuid);
}
}
uuid = hw_get_uuid(dest->part_swap);
if (uuid) {
- fprintf(f, fmt, uuid, "swap", "swap", "defaults,pri=1", 0, 0);
+ fprintf(f, FSTAB_FMT, uuid, "swap", "swap", "defaults,pri=1", 0, 0);
free(uuid);
}
}
// root
uuid = hw_get_uuid(dest->part_root);
if (uuid) {
- fprintf(f, fmt, uuid, "/", "auto", "defaults", 1, 1);
+ fprintf(f, FSTAB_FMT, uuid, "/", "auto", "defaults", 1, 1);
free(uuid);
}
uuid = hw_get_uuid(dest->part_data);
if (uuid) {
- fprintf(f, fmt, uuid, "/var", "auto", "defaults", 1, 1);
+ fprintf(f, FSTAB_FMT, uuid, "/var", "auto", "defaults", 1, 1);
free(uuid);
}
}
* Contains main entry point, and misc functions.6
*
*/
+#define _GNU_SOURCE
#include <assert.h>
#include <errno.h>
return ret;
}
-int write_lang_configs(const char *lang) {
+int write_lang_configs(char* lang) {
struct keyvalue *kv = initkeyvalues();
/* default stuff for main/settings. */
}
#define DEFAULT_LANG "English"
-#define NUM_LANGS 8
+#define NUM_LANGS 10
static struct lang {
const char* code;
while (token) {
strncpy(buffer, token, sizeof(buffer));
- char* val = &buffer;
+ char* val = buffer;
char* key = strsep(&val, "=");
// serial console
// download url
else if (strcmp(key, "installer.download-url") == 0) {
- strncpy(&c->download_url, val, sizeof(c->download_url));
+ strncpy(c->download_url, val, sizeof(c->download_url));
c->perform_download = 1;
// Require networking for the download
char message[STRING_SIZE];
char title[STRING_SIZE];
int allok = 0;
- FILE *handle, *copying;
- char line[STRING_SIZE];
-
- setlocale (LC_ALL, "");
- sethostname( SNAME , 10);
+ FILE *copying;
+
+ setlocale(LC_ALL, "");
+ sethostname(SNAME, 10);
/* Log file/terminal stuff. */
FILE* flog = NULL;
assert(choice <= NUM_LANGS);
fprintf(flog, "Selected language: %s (%s)\n", languages[choice].name, languages[choice].code);
- snprintf(language, sizeof(language), languages[choice].code);
+ snprintf(language, sizeof(language), "%s", languages[choice].code);
setenv("LANGUAGE", language, 1);
setlocale(LC_ALL, language);
// Read the license file.
if (!(copying = fopen(LICENSE_FILE, "r"))) {
sprintf(discl_msg, "Could not open license file: %s\n", LICENSE_FILE);
- fprintf(flog, discl_msg);
+ fprintf(flog, "%s", discl_msg);
} else {
fread(discl_msg, 1, 40000, copying);
fclose(copying);
// Check how many disks have been found and what
// we can do with them.
- unsigned int num_disks = hw_count_disks(disks);
+ unsigned int num_disks = hw_count_disks((const struct hw_disk**)disks);
while (1) {
// no harddisks found
// or if we are running in unattended mode, we will select
// the first disk and go with that one
} else if ((num_disks == 1) || (config.unattended && num_disks >= 1)) {
- selected_disks = hw_select_first_disk(disks);
+ selected_disks = hw_select_first_disk((const struct hw_disk**)disks);
// more than one usable disk has been found and
// the user needs to choose what to do with them
int disk_selection[num_disks];
for (unsigned int i = 0; i < num_disks; i++) {
- disk_names[i] = &disks[i]->description;
+ disk_names[i] = disks[i]->description;
disk_selection[i] = 0;
}
if (config.unattended)
break;
- num_selected_disks = hw_count_disks(selected_disks);
+ num_selected_disks = hw_count_disks((const struct hw_disk**)selected_disks);
if (num_selected_disks == 1) {
snprintf(message, sizeof(message),
if (HW_FS_DEFAULT == filesystems[i].fstype)
fs_choice = i;
- fs_names[i] = filesystems[i].description;
+ fs_names[i] = &filesystems[i].description;
}
rc = newtWinMenu(_("Filesystem Selection"), _("Please choose your filesystem:"),