2 * Copyright (C) 2001-2003 Hewlett-Packard Co.
3 * Contributed by Stephane Eranian <eranian@hpl.hp.com>
5 * This file is part of the ELILO, the EFI Linux boot loader.
7 * ELILO is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2, or (at your option)
12 * ELILO is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with ELILO; see the file COPYING. If not, write to the Free
19 * Software Foundation, 59 Temple Place - Suite 330, Boston, MA
22 * Please check out the elilo.txt for complete documentation on how
23 * to use this program.
25 * Portions of this file are derived from the LILO/x86
26 * Copyright 1992-1997 Werner Almesberger.
31 #include <efistdarg.h>
37 * The first default config file is architecture dependent. This is useful
38 * in case of network booting where the server is used for both types of
41 #if defined(CONFIG_ia64)
42 #define ELILO_ARCH_DEFAULT_CONFIG L"elilo-ia64.conf"
43 #elif defined (CONFIG_ia32)
44 #define ELILO_ARCH_DEFAULT_CONFIG L"elilo-ia32.conf"
46 #error "You need to specfy your default arch config file"
50 * last resort config file. Common to all architectures
52 #define ELILO_DEFAULT_CONFIG L"elilo.conf"
54 #define MAX_STRING CMDLINE_MAXLEN
55 #define CONFIG_BUFSIZE 512 /* input buffer size */
58 * maximum number of message files.
60 * main message= goes at entry 0, entries [1-12] are used for function keys
63 #define MAX_MESSAGES 13
65 typedef struct boot_image {
66 struct boot_image *next;
67 CHAR16 label[MAX_STRING];
68 CHAR16 kname[FILENAME_MAXLEN];
69 CHAR16 options[MAX_STRING];
70 CHAR16 initrd[FILENAME_MAXLEN];
71 CHAR16 vmcode[FILENAME_MAXLEN];
72 CHAR16 root[FILENAME_MAXLEN];
73 CHAR16 fallback[MAX_STRING];
74 CHAR16 description[MAX_STRING];
80 sys_img_options_t sys_img_opts; /* architecture specific image options */
91 * global shared options
92 * architecture specific global options are private to each architecture
95 CHAR16 root[FILENAME_MAXLEN]; /* globally defined root fs */
96 CHAR16 initrd[FILENAME_MAXLEN];/* globally defined initrd */
97 CHAR16 vmcode[FILENAME_MAXLEN];/* globally defined boot-time module */
98 CHAR16 options[MAX_STRING];
99 CHAR16 default_image_name[MAX_STRING];
100 CHAR16 message_file[MAX_MESSAGES][FILENAME_MAXLEN];
101 CHAR16 chooser[FILENAME_MAXLEN];/* which image chooser to use */
102 CHAR16 config_file[FILENAME_MAXLEN];
103 boot_image_t *default_image;
108 * options that may affect global elilo options
116 UINTN edd30_no_force; /* don't force EDD30 if not set */
120 * structure used to point to a group of options.
121 * Several group for the same category are supported via a linked list.
123 typedef struct _config_option_group {
124 struct _config_option_group *next; /* pointer to next group */
125 config_option_t *options; /* the table of options for this group */
126 UINTN nentries; /* number of entries for this group */
127 } config_option_group_t;
129 static option_action_t do_image, do_literal, do_options;
130 static INTN check_verbosity(VOID *), check_chooser(VOID *);
132 static global_config_t global_config; /* options shared by all images */
135 * Core global options: shared by all architectures, all modules
137 static config_option_t global_common_options[]={
138 {OPT_STR, OPT_GLOBAL, L"default", NULL, NULL, global_config.default_image_name},
139 {OPT_NUM, OPT_GLOBAL, L"timeout", NULL, NULL, &global_config.timeout},
140 {OPT_NUM, OPT_GLOBAL, L"delay", NULL, NULL, &global_config.delay},
141 {OPT_BOOL, OPT_GLOBAL, L"debug", NULL, NULL, &global_config.debug},
142 {OPT_BOOL, OPT_GLOBAL, L"prompt", NULL, NULL, &global_config.prompt},
143 {OPT_NUM, OPT_GLOBAL, L"verbose", NULL, check_verbosity, &global_config.verbose},
144 {OPT_FILE, OPT_GLOBAL, L"root", NULL, NULL, global_config.root},
145 {OPT_BOOL, OPT_GLOBAL, L"read-only", NULL, NULL, &global_config.readonly},
146 {OPT_BOOL, OPT_GLOBAL, L"noedd30", NULL, NULL, &global_config.edd30_no_force},
147 {OPT_CMD, OPT_GLOBAL, L"append", NULL, NULL, global_config.options},
148 {OPT_FILE, OPT_GLOBAL, L"initrd", NULL, NULL, global_config.initrd},
149 {OPT_FILE, OPT_GLOBAL, L"vmm", NULL, NULL, global_config.vmcode},
150 {OPT_FILE, OPT_GLOBAL, L"image", do_image, NULL, opt_offsetof(kname)},
151 {OPT_BOOL, OPT_GLOBAL, L"checkalt", NULL, NULL, &global_config.alt_check},
152 {OPT_STR, OPT_GLOBAL, L"chooser", NULL, check_chooser, global_config.chooser},
153 {OPT_FILE, OPT_GLOBAL, L"message", NULL, NULL, global_config.message_file[0]},
154 {OPT_FILE, OPT_GLOBAL, L"f1", NULL, NULL, global_config.message_file[1]},
155 {OPT_FILE, OPT_GLOBAL, L"f2", NULL, NULL, global_config.message_file[2]},
156 {OPT_FILE, OPT_GLOBAL, L"f3", NULL, NULL, global_config.message_file[3]},
157 {OPT_FILE, OPT_GLOBAL, L"f4", NULL, NULL, global_config.message_file[4]},
158 {OPT_FILE, OPT_GLOBAL, L"f5", NULL, NULL, global_config.message_file[5]},
159 {OPT_FILE, OPT_GLOBAL, L"f6", NULL, NULL, global_config.message_file[6]},
160 {OPT_FILE, OPT_GLOBAL, L"f7", NULL, NULL, global_config.message_file[7]},
161 {OPT_FILE, OPT_GLOBAL, L"f8", NULL, NULL, global_config.message_file[8]},
162 {OPT_FILE, OPT_GLOBAL, L"f9", NULL, NULL, global_config.message_file[9]},
163 {OPT_FILE, OPT_GLOBAL, L"f10", NULL, NULL, global_config.message_file[10]},
164 {OPT_FILE, OPT_GLOBAL, L"f11", NULL, NULL, global_config.message_file[11]},
165 {OPT_FILE, OPT_GLOBAL, L"f12", NULL, NULL, global_config.message_file[12]}
168 static config_option_t image_common_options[]={
169 {OPT_FILE, OPT_IMAGE, L"root", NULL, NULL, opt_offsetof(root)},
170 {OPT_BOOL, OPT_IMAGE, L"read-only", NULL, NULL, opt_offsetof(readonly)},
171 {OPT_CMD, OPT_IMAGE, L"append", do_options, NULL, opt_offsetof(options)},
172 {OPT_CMD, OPT_IMAGE, L"literal", do_literal, NULL, NULL},
173 {OPT_FILE, OPT_IMAGE, L"initrd", NULL, NULL, opt_offsetof(initrd)},
174 {OPT_FILE, OPT_IMAGE, L"vmm", NULL, NULL, opt_offsetof(vmcode)},
175 {OPT_STR, OPT_IMAGE, L"label", NULL, NULL, opt_offsetof(label)},
176 {OPT_FILE, OPT_IMAGE, L"image", do_image, NULL, opt_offsetof(kname)},
177 {OPT_STR, OPT_IMAGE, L"description", NULL, NULL, opt_offsetof(description)},
180 #define OPTION_IS_GLOBAL(p) ((p)->scope == OPT_GLOBAL)
181 #define OPTION_IS_IMG_SYS(p) ((p)->scope == OPT_IMAGE_SYS)
183 #define CHAR_EOF (CHAR16)-1 /* Unicode version of EOF */
184 #define CHAR_NUM0 L'0'
185 #define CHAR_NUM9 L'9'
187 static UINTN line_num;
188 static INTN back; /* can go back by one char */
190 static config_option_group_t *global_option_list;
191 static config_option_group_t *image_option_list;
194 static config_option_group_t *current_options;
196 static boot_image_t *image_list, *first_image;
197 static boot_image_t *current_img;
199 static INT8 config_buf[CONFIG_BUFSIZE]; /* input buffer: file must be in ASCII! */
200 static UINTN buf_max, buf_pos;
202 static fops_fd_t config_fd;
205 config_error(CHAR16 *msg,...)
208 extern UINTN _IPrint (UINTN, UINTN, SIMPLE_TEXT_OUTPUT_INTERFACE *, CHAR16 *, CHAR8 *, va_list);
210 Print(L"near line %d: ",line_num);
213 _IPrint((UINTN)-1, (UINTN)-1, systab->ConOut, msg, NULL, ap);
219 * low level read routine
223 * - the next available unicode character
225 * - CHAR_EOF : indicating error or EOF
227 * XXX: we suppose that the file is in ASCII format!
234 if (buf_pos == 0 || buf_pos == buf_max) {
235 buf_max = CONFIG_BUFSIZE;
236 status = fops_read(config_fd, config_buf, &buf_max);
237 if (EFI_ERROR(status) || buf_max == 0) return CHAR_EOF;
241 return (CHAR16)config_buf[buf_pos++];
246 * get the next unicode character with a one character
263 * rewind by one character
268 if (back) { config_error(L"config: again invoked twice"); }
273 * Look for matching option in the current group
276 * - pointer to option if found
277 * - NULL if not found
279 static config_option_t *
280 find_option(config_option_group_t *grp, CHAR16 *str)
282 config_option_t *p = NULL;
283 config_option_t *end;
287 end = grp->options+grp->nentries;
290 if (!StrCmp(str, p->name)) return p;
299 * main parser function
301 * - a token code representing the kind of element found
302 * - TOK_EOF: end-of-file (or error) detected
303 * - TOK_STR: if string is found
304 * - TOK_EQUAL: for the '=' sign
305 * - TOK_ERR: in case of (parsing) error
308 get_token(CHAR16 *str, UINTN maxlen)
314 while ((ch = next()), ch == ' ' || ch == '\t' || ch == '\n') if (ch == '\n') line_num++;
316 if (ch == CHAR_EOF) return TOK_EOF;
318 if (ch != '#') break;
320 /* skip comment line */
321 while ((ch = next()), ch != '\n') if (ch == CHAR_EOF) return TOK_EOF;
324 if (ch == '=') return TOK_EQUAL;
328 while (here-str < maxlen) {
329 if ((ch = next()) == CHAR_EOF) {
330 config_error(L"EOF in quoted string");
339 if (ch != '"' && ch != '\\' && ch != '\n') {
340 config_error(L"Bad use of \\ in quoted string");
343 if (ch == '\n') continue;
345 while ((ch = next()), ch == ' ' || ch == '\t');
352 if (ch == '\n' || ch == '\t') {
353 config_error(L"\\n and \\t are not allowed in quoted strings");
358 config_error(L"Quoted string is too long");
365 while (here-str < maxlen) {
367 if (ch == CHAR_EOF) {
368 config_error(L"\\ precedes EOF");
371 if (ch == '\n') line_num++;
372 else *here++ = ch == '\t' ? ' ' : ch;
376 if (ch == ' ' || ch == '\t' || ch == '\n' || ch == '#' ||
377 ch == '=' || ch == CHAR_EOF) {
382 if (!(escaped = (ch == '\\'))) *here++ = ch;
386 config_error(L"Token is too long");
391 image_check(boot_image_t *img)
395 if (img == NULL) return -1;
397 /* do the obvious first */
398 if (img->label[0] == '\0') {
399 config_error(L"image has no label");
403 /* image_list points to the */
404 for(b=image_list; b; b = b->next) {
405 if (img == b) continue;
406 if (!StrCmp(img->label, b->label)) {
407 config_error(L"image with label %s already defined", img->label);
425 if (global_config.default_image_name[0]) {
426 for(b=image_list; b; b = b->next) {
427 if (!StrCmp(b->label, global_config.default_image_name)) goto found;
429 config_error(L"default image '%s' not defined ", global_config.default_image_name);
432 global_config.default_image = first_image;
435 global_config.default_image = b;
440 * depending on the active set of options
441 * adjust the option data pointer to:
442 * if global option set:
443 * - just the straight value from p->data
444 * if image option set:
445 * - adjust as offset to image
447 * - the adjusted pointer
450 adjust_pointer(config_option_t *p)
455 if (OPTION_IS_GLOBAL(p)) return p->data;
457 if (OPTION_IS_IMG_SYS(p)) return (VOID *)((UINTN)¤t_img->sys_img_opts + p->data);
459 return (VOID *)((UINTN)current_img + p->data);
463 * create a new image entry
466 do_image(config_option_t *p, VOID *str)
471 * if we move to a new image from the current one
472 * then we need to check for validity of current.
474 * if this is the first image, then check the global
478 if (image_check(current_img) == -1) return -1;
479 } else if (global_check() == -1) return -1;
481 img = (boot_image_t *)alloc(sizeof(boot_image_t), EfiLoaderData);
482 if (img == NULL) return -1;
484 Memset(img, 0, sizeof(boot_image_t));
486 DBG_PRT((L"must do image on %s", (CHAR16 *)str));
488 /* copy kernel file name */
489 StrCpy(img->kname, str);
491 /* switch to image mode */
492 current_options = image_option_list;
494 /* keep track of first image in case no default is defined */
495 if (image_list == NULL) first_image = img;
497 /* append to end of image list, so when a chooser asks for the list
498 * it gets them in the order they were in in the config file
500 if (image_list == NULL)
503 boot_image_t * p = image_list;
510 /* update current image */
517 * by default all boolean options are defined
518 * as false. This function sets the boolean
522 do_boolean(config_option_t *p)
526 buf = adjust_pointer(p);
528 if (p->action) return p->action(p, NULL);
530 /* set the field to true, overwrite if already defined */
537 * the image option 'literal' requires special handling
538 * because it overrides any defined option be it global or
539 * local. so we use the option field and record the fact that
540 * it should be interpreted as literal
543 do_literal(config_option_t *p, VOID *str)
546 * we know we have a valid current image at this point
548 StrCpy(current_img->options, str);
550 current_img->literal = 1;
556 do_options(config_option_t *p, VOID *str)
558 /* we ignore append if literal is already defined */
559 if (current_img->literal) return 0;
562 * we know we have a valid current image at this point
564 StrCpy(current_img->options, str);
570 do_numeric(config_option_t *p)
572 CHAR16 numstr[MAX_STRING];
581 tok = get_token(numstr, MAX_STRING);
582 if (tok != TOK_EQUAL) {
583 config_error(L"Option %s expects an equal signal + value", p->name);
589 * XXX: = lexer should return TOK_NUM (and we'd be done)
591 tok = get_token(numstr, MAX_STRING);
592 if (tok != TOK_STR) {
593 config_error(L"Option %s expects a value", p->name);
598 * if there is a customized way of doing the operation
599 * do it and bypass generic
601 if (p->action) return p->action(p, str);
606 if (p->data == NULL) return 0;
608 buf = (UINTN *)adjust_pointer(p);
610 while (*str && *str >= CHAR_NUM0 && *str <= CHAR_NUM9) str++;
612 config_error(L"%s is expecting a numeric decimal value", p->name);
618 if (p->check && p->check(&tmp) == -1) return -1;
621 * check for multiple definitions in the same context
622 * XXX: zero must not be a valid number !
625 config_error(L"option %s is already defined in this context", p->name);
635 check_verbosity(VOID *data)
637 UINTN *val = (UINTN *)data;
640 config_error(L"Verbosity level must be in [0-5] and not %d", *val);
648 * here we simply check if chooser is compiled in. At this point, the chooser
649 * initialization is not done, so we don't know if that chooser will even be
653 check_chooser(VOID *data)
655 CHAR16 *chooser = (CHAR16 *)data;
657 if (exist_chooser(chooser) == -1) {
658 config_error(L"chooser %s is unknown\n", chooser);
666 do_string_core(config_option_t *p, CHAR16 *str, UINTN maxlen, CHAR16 *msg)
674 tok = get_token(str, maxlen);
675 if (tok != TOK_EQUAL) {
676 config_error(L"Option %s expects an equal signal + %s", p->name, msg);
683 tok = get_token(str, maxlen);
684 if (tok != TOK_STR) {
685 config_error(L"Option %s expects %s", p->name, msg);
690 * if there is a customized way of doing the operation
691 * do it and bypass generic
693 if (p->action) return p->action(p, str);
698 if (p->data == NULL) return 0;
700 buf = adjust_pointer(p);
702 if (*buf != CHAR_NULL) {
703 config_error(L"'%s' already defined", p->name);
706 if (p->check && p->check(str) == -1) return -1;
717 do_string(config_option_t *p)
719 CHAR16 str[MAX_STRING];
721 return do_string_core(p, str, MAX_STRING, L"string");
725 do_file(config_option_t *p)
727 CHAR16 str[FILENAME_MAXLEN];
729 return do_string_core(p, str, FILENAME_MAXLEN, L"filename");
734 do_cmd(config_option_t *p)
736 CHAR16 str[CMDLINE_MAXLEN];
737 return do_string_core(p, str, CMDLINE_MAXLEN, L"kernel options");
744 CHAR16 str[MAX_STRING];
750 tok = get_token(str, MAX_STRING);
752 if (tok == TOK_EOF) break;
754 if (tok == TOK_ERR) return -1;
756 if ( (p = find_option(current_options, str)) == NULL) {
757 config_error(L"Unkown option %s", str);
761 /* make sure we trap in case of error */
781 config_error(L"Unkown option type %d", p->type);
783 if (ret == -1) goto error;
786 ret = image_check(current_img);
788 config_error(L"No image defined !");
790 if (ret == 0) ret = final_check();
796 update_elilo_opt(VOID)
799 * update boolean options first
800 * Rule: by default not set unless explcitely requested on command line
801 * therefore we can just update from global_config is set there.
803 if (global_config.alt_check) elilo_opt.alt_check = 1;
805 if (global_config.debug) elilo_opt.debug = 1;
806 if (global_config.prompt) elilo_opt.prompt = 1;
809 * update only if not set on command line
810 * XXX: rely on the existence of a non-valid value as a marker than
811 * the option was not specified on the command line
813 if (global_config.verbose && elilo_opt.verbose == 0)
814 elilo_opt.verbose = global_config.verbose;
816 if (global_config.chooser[0] && elilo_opt.chooser[0] == 0)
817 StrCpy(elilo_opt.chooser, global_config.chooser);
820 * if edd30_no_force not set by command line option but via config
821 * file, then propagate
823 if (global_config.edd30_no_force && elilo_opt.edd30_no_force == 0)
824 elilo_opt.edd30_no_force = 1;
827 * Difficult case of numeric where 0 can be a valid value
828 * XXX: find a better way of handling these options!
830 if (global_config.delay && elilo_opt.delay_set == 0)
831 elilo_opt.delay = global_config.delay;
833 /* readjusted by caller if necessary. 0 not a valid value here */
834 elilo_opt.timeout = global_config.timeout;
836 /* initrd is updated later when we have an image match */
840 * When called after read_config(), this function returns the config file
841 * used by the loader, or NULL if no file was found.
844 get_config_file(VOID)
846 return global_config.config_file[0] ? global_config.config_file : NULL;
850 read_config(CHAR16 *filename)
855 if (filename == NULL) return EFI_INVALID_PARAMETER;
857 VERB_PRT(3, Print(L"trying config file %s\n", filename));
859 StrCpy(global_config.config_file, filename);
861 status = fops_open(filename, &config_fd);
862 if (EFI_ERROR(status)) {
863 VERB_PRT(3, Print(L"cannot open config file %s\n", filename));
867 * start numbering at line 1
871 ret = config_parse();
873 fops_close(config_fd);
875 DBG_PRT((L"done parsing config file\n"));
877 if (ret != 0) return EFI_INVALID_PARAMETER;
885 print_label_list(VOID)
887 boot_image_t *img, *dfl = global_config.default_image;
889 if (dfl) Print(L"\t%s\n", dfl->label);
891 for (img = image_list; img; img = img->next) {
892 if (img != dfl) Print(L"\t%s\n", img->label);
896 /* Make labels and corresponding descriptions available to choosers. The
897 * idea is that the caller passes NULL for 'prev'; the first time, and
898 * passes the previously returned value on subsequent calls. The caller
899 * repeats until this fn returns NULL.
903 get_next_description(VOID *prev, CHAR16 **label, CHAR16 **description)
905 boot_image_t *img = (boot_image_t *)prev;
914 *description = img->description;
922 * find a description using the label name
923 * return NULL if label not found or no description defined
926 find_description(CHAR16 *label)
930 /* Attempt to find the image name now */
931 for (img = image_list; img; img = img->next) {
932 if (StriCmp(img->label, label) == 0) {
933 return img->description;
940 find_label(CHAR16 *label, CHAR16 *kname, CHAR16 *options, CHAR16 *initrd, CHAR16 *vmcode)
945 if (global_config.default_image == NULL) return -1;
946 img = global_config.default_image;
952 /* Attempt to find the image name now */
953 for (img = image_list; img; img = img->next) {
954 if (StriCmp(img->label, label) == 0) {
959 * when the label does not exist, we still propagate the global options
961 if (global_config.root[0]) {
962 StrCpy(options, L" root=");
963 StrCat(options, global_config.root);
966 if (global_config.options[0]) {
967 StrCat(options, L" ");
968 StrCat(options, global_config.options);
970 if (global_config.readonly) StrCat(options, L" ro");
972 if (global_config.initrd[0]) StrCpy(initrd, global_config.initrd);
973 if (global_config.vmcode[0]) StrCpy(vmcode, global_config.vmcode);
975 /* make sure we don't get garbage here */
976 elilo_opt.sys_img_opts = NULL;
980 StrCpy(kname, img->kname);
983 * literal option overrides any other image-based or global option
985 * In any case, the image option has priority over the global option
987 if (img->literal == 0) {
988 if (img->root[0] || global_config.root[0]) {
989 StrCat(options, L"root=");
990 StrCat(options, img->root[0] ? img->root : global_config.root);
992 /* XXX: check max length */
993 if (img->options[0] || global_config.options[0]) {
994 StrCat(options, L" ");
995 StrCat(options, img->options[0] ? img->options: global_config.options);
997 if (img->readonly || global_config.readonly) {
998 StrCat(options, L" ro");
1001 /* literal options replace everything */
1002 StrCpy(options, img->options);
1005 /* per image initrd has precedence over global initrd */
1007 StrCpy(initrd, img->initrd);
1008 else if (global_config.initrd[0])
1009 StrCpy(initrd, global_config.initrd);
1012 StrCpy(vmcode, img->vmcode);
1013 else if (global_config.vmcode[0])
1014 StrCpy(vmcode, global_config.vmcode);
1017 * point to architecture dependent options for this image
1019 elilo_opt.sys_img_opts = &img->sys_img_opts;
1021 DBG_PRT((L"label %s: kname=%s options=%s initrd=%s vmcode=%s", img->label, kname, options, initrd, vmcode));
1027 print_options(config_option_group_t *grp, BOOLEAN first)
1029 config_option_t *end, *p;
1034 end = grp->options+grp->nentries;
1045 str = L"%s=filename";
1048 str = L"%s=kernel_options";
1056 if (str && first == FALSE) Print(L", ");
1057 if (str) Print(str, p->name);
1067 print_config_options(VOID)
1069 Print(L"Global options supported:\n");
1071 print_options(global_option_list, TRUE);
1074 Print(L"Image options supported:\n");
1075 print_options(image_option_list, TRUE);
1081 * returns a pointer to filename used for message N (which). NULL if it does
1085 get_message_filename(INTN which)
1087 if (which < 0 || which >= MAX_MESSAGES) return NULL;
1088 return global_config.message_file[which];
1092 register_config_options(config_option_t *opt, UINTN n, config_option_group_scope_t group)
1094 config_option_group_t *newgrp, **grp;
1096 if (opt == NULL || n == 0 || (group != OPTIONS_GROUP_GLOBAL && group != OPTIONS_GROUP_IMAGE)) return -1;
1098 VERB_PRT(3, Print(L"registering %d options for group %s\n", n, group == OPTIONS_GROUP_GLOBAL ? L"global" : L"image"));
1100 newgrp = alloc(sizeof(config_option_group_t), EfiLoaderData);
1101 if (newgrp == NULL) return -1;
1103 grp = group == OPTIONS_GROUP_GLOBAL ? &global_option_list : &image_option_list;
1105 if (*grp) while ((*grp)->next) grp = &(*grp)->next;
1107 newgrp->options = opt;
1108 newgrp->next = NULL;
1109 newgrp->nentries = n;
1112 (*grp)->next = newgrp;
1120 * initialize config options: register global and per image options
1127 ret = register_config_options(global_common_options,
1128 sizeof(global_common_options)/sizeof(config_option_t),
1129 OPTIONS_GROUP_GLOBAL);
1130 if (ret == -1) return -1;
1132 ret = register_config_options(image_common_options,
1133 sizeof(image_common_options)/sizeof(config_option_t),
1134 OPTIONS_GROUP_IMAGE);
1136 current_options = global_option_list;