summaryrefslogtreecommitdiffstats
path: root/mdk-stage1/params.c
diff options
context:
space:
mode:
authorNicolas Lécureuil <neoclust@mageia.org>2012-11-09 20:44:52 +0000
committerNicolas Lécureuil <neoclust@mageia.org>2012-11-09 20:44:52 +0000
commit820fd62a86a88b3c53d5ebe1939e4dc51cc8bcdc (patch)
treec68a3c36dfae599c50c1f1dcda92113dab70effc /mdk-stage1/params.c
parent0db2372d5a031bad0f5df98b83f7fb7d648215ed (diff)
downloaddrakx-backup-do-not-use-820fd62a86a88b3c53d5ebe1939e4dc51cc8bcdc.tar
drakx-backup-do-not-use-820fd62a86a88b3c53d5ebe1939e4dc51cc8bcdc.tar.gz
drakx-backup-do-not-use-820fd62a86a88b3c53d5ebe1939e4dc51cc8bcdc.tar.bz2
drakx-backup-do-not-use-820fd62a86a88b3c53d5ebe1939e4dc51cc8bcdc.tar.xz
drakx-backup-do-not-use-820fd62a86a88b3c53d5ebe1939e4dc51cc8bcdc.zip
Do not mix tabs and spaces
Diffstat (limited to 'mdk-stage1/params.c')
-rw-r--r--mdk-stage1/params.c228
1 files changed, 114 insertions, 114 deletions
diff --git a/mdk-stage1/params.c b/mdk-stage1/params.c
index 692c3e511..21898b3ee 100644
--- a/mdk-stage1/params.c
+++ b/mdk-stage1/params.c
@@ -29,79 +29,79 @@ static int param_number = 0;
void process_cmdline(void)
{
- char buf[512];
- int size, i;
- int fd = -1;
-
- if (IS_TESTING) {
- log_message("TESTING: opening cmdline... ");
-
- if ((fd = open("cmdline", O_RDONLY)) == -1)
- log_message("TESTING: could not open cmdline");
- }
-
- if (fd == -1) {
- log_message("opening /proc/cmdline... ");
-
- if ((fd = open("/proc/cmdline", O_RDONLY)) == -1)
- fatal_error("could not open /proc/cmdline");
- }
-
- size = read(fd, buf, sizeof(buf));
- buf[size-1] = '\0'; // -1 to eat the \n
- close(fd);
-
- log_message("\t%s", buf);
-
- i = 0;
- while (buf[i] != '\0') {
- char *name, *value = NULL;
- int j = i;
- while (buf[i] != ' ' && buf[i] != '=' && buf[i] != '\0')
- i++;
- if (i == j) {
- i++;
- continue;
- }
- name = _memdup(&buf[j], i-j + 1);
- name[i-j] = '\0';
-
- if (buf[i] == '=') {
- int k = i+1;
- i++;
- while (buf[i] != ' ' && buf[i] != '\0')
- i++;
- value = _memdup(&buf[k], i-k + 1);
- value[i-k] = '\0';
- }
-
- params[param_number].name = name;
- params[param_number].value = value;
- param_number++;
- if (!strcmp(name, "changedisk")) set_param(MODE_CHANGEDISK);
- if (!strcmp(name, "updatemodules") ||
- !strcmp(name, "thirdparty")) set_param(MODE_THIRDPARTY);
- if (!strcmp(name, "rescue") ||
- !strcmp(name, "kamethod")) set_param(MODE_RESCUE);
- if (!strcmp(name, "rescue")) set_param(MODE_RESCUE);
- if (!strcmp(name, "keepmounted")) set_param(MODE_KEEP_MOUNTED);
- if (!strcmp(name, "noauto")) set_param(MODE_NOAUTO);
- if (!strcmp(name, "netauto")) set_param(MODE_NETAUTO);
- if (!strcmp(name, "debugstage1")) set_param(MODE_DEBUGSTAGE1);
- if (!strcmp(name, "automatic")) {
- set_param(MODE_AUTOMATIC);
- grab_automatic_params(value);
- }
- if (buf[i] == '\0')
- break;
- i++;
- }
-
- if (IS_AUTOMATIC && strcmp(get_auto_value("thirdparty"), "")) {
- set_param(MODE_THIRDPARTY);
- }
-
- log_message("\tgot %d args", param_number);
+ char buf[512];
+ int size, i;
+ int fd = -1;
+
+ if (IS_TESTING) {
+ log_message("TESTING: opening cmdline... ");
+
+ if ((fd = open("cmdline", O_RDONLY)) == -1)
+ log_message("TESTING: could not open cmdline");
+ }
+
+ if (fd == -1) {
+ log_message("opening /proc/cmdline... ");
+
+ if ((fd = open("/proc/cmdline", O_RDONLY)) == -1)
+ fatal_error("could not open /proc/cmdline");
+ }
+
+ size = read(fd, buf, sizeof(buf));
+ buf[size-1] = '\0'; // -1 to eat the \n
+ close(fd);
+
+ log_message("\t%s", buf);
+
+ i = 0;
+ while (buf[i] != '\0') {
+ char *name, *value = NULL;
+ int j = i;
+ while (buf[i] != ' ' && buf[i] != '=' && buf[i] != '\0')
+ i++;
+ if (i == j) {
+ i++;
+ continue;
+ }
+ name = _memdup(&buf[j], i-j + 1);
+ name[i-j] = '\0';
+
+ if (buf[i] == '=') {
+ int k = i+1;
+ i++;
+ while (buf[i] != ' ' && buf[i] != '\0')
+ i++;
+ value = _memdup(&buf[k], i-k + 1);
+ value[i-k] = '\0';
+ }
+
+ params[param_number].name = name;
+ params[param_number].value = value;
+ param_number++;
+ if (!strcmp(name, "changedisk")) set_param(MODE_CHANGEDISK);
+ if (!strcmp(name, "updatemodules") ||
+ !strcmp(name, "thirdparty")) set_param(MODE_THIRDPARTY);
+ if (!strcmp(name, "rescue") ||
+ !strcmp(name, "kamethod")) set_param(MODE_RESCUE);
+ if (!strcmp(name, "rescue")) set_param(MODE_RESCUE);
+ if (!strcmp(name, "keepmounted")) set_param(MODE_KEEP_MOUNTED);
+ if (!strcmp(name, "noauto")) set_param(MODE_NOAUTO);
+ if (!strcmp(name, "netauto")) set_param(MODE_NETAUTO);
+ if (!strcmp(name, "debugstage1")) set_param(MODE_DEBUGSTAGE1);
+ if (!strcmp(name, "automatic")) {
+ set_param(MODE_AUTOMATIC);
+ grab_automatic_params(value);
+ }
+ if (buf[i] == '\0')
+ break;
+ i++;
+ }
+
+ if (IS_AUTOMATIC && strcmp(get_auto_value("thirdparty"), "")) {
+ set_param(MODE_THIRDPARTY);
+ }
+
+ log_message("\tgot %d args", param_number);
}
@@ -110,68 +110,68 @@ int stage1_mode = 0;
int get_param(int i)
{
#ifdef SPAWN_INTERACTIVE
- static int fd = 0;
- char buf[5000];
- char * ptr;
- int nb;
-
- if (fd <= 0) {
- fd = open(interactive_fifo, O_RDONLY);
- if (fd == -1)
- return (stage1_mode & i);
- fcntl(fd, F_SETFL, O_NONBLOCK);
- }
-
- if (fd > 0) {
- if ((nb = read(fd, buf, sizeof(buf))) > 0) {
- buf[nb] = '\0';
- ptr = buf;
- while ((ptr = strstr(ptr, "+ "))) {
- if (!strncmp(ptr+2, "rescue", 6)) set_param(MODE_RESCUE);
- ptr++;
- }
- ptr = buf;
- while ((ptr = strstr(ptr, "- "))) {
- if (!strncmp(ptr+2, "rescue", 6)) unset_param(MODE_RESCUE);
- ptr++;
- }
- }
- }
+ static int fd = 0;
+ char buf[5000];
+ char * ptr;
+ int nb;
+
+ if (fd <= 0) {
+ fd = open(interactive_fifo, O_RDONLY);
+ if (fd == -1)
+ return (stage1_mode & i);
+ fcntl(fd, F_SETFL, O_NONBLOCK);
+ }
+
+ if (fd > 0) {
+ if ((nb = read(fd, buf, sizeof(buf))) > 0) {
+ buf[nb] = '\0';
+ ptr = buf;
+ while ((ptr = strstr(ptr, "+ "))) {
+ if (!strncmp(ptr+2, "rescue", 6)) set_param(MODE_RESCUE);
+ ptr++;
+ }
+ ptr = buf;
+ while ((ptr = strstr(ptr, "- "))) {
+ if (!strncmp(ptr+2, "rescue", 6)) unset_param(MODE_RESCUE);
+ ptr++;
+ }
+ }
+ }
#endif
- return (stage1_mode & i);
+ return (stage1_mode & i);
}
char * get_param_valued(char *param_name)
{
- int i;
- for (i = 0; i < param_number ; i++)
- if (!strcmp(params[i].name, param_name))
- return params[i].value;
+ int i;
+ for (i = 0; i < param_number ; i++)
+ if (!strcmp(params[i].name, param_name))
+ return params[i].value;
- return NULL;
+ return NULL;
}
void set_param_valued(char *param_name, char *param_value)
{
- params[param_number].name = param_name;
- params[param_number].value = param_value;
- param_number++;
+ params[param_number].name = param_name;
+ params[param_number].value = param_value;
+ param_number++;
}
void set_param(int i)
{
- stage1_mode |= i;
+ stage1_mode |= i;
}
void unset_param(int i)
{
- stage1_mode &= ~i;
+ stage1_mode &= ~i;
}
void unset_automatic(void)
{
- log_message("unsetting automatic");
- unset_param(MODE_AUTOMATIC);
- exit_bootsplash();
+ log_message("unsetting automatic");
+ unset_param(MODE_AUTOMATIC);
+ exit_bootsplash();
}