Print this page
9696 add /etc/system.d support
Portions contributed by: Andy Fiddaman <andy@omniosce.org>
Reviewed by: Hans Rosenfeld <hans.rosenfeld@joyent.com>
Reviewed by: Peter Tribble <peter.tribble@gmail.com>
Reviewed by: C Fraire <cfraire@me.com>
Reviewed by: Toomas Soome <tsoome@me.com>

*** 20,30 **** */ /* * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. ! * Copyright 2016 Nexenta Systems, Inc. */ #include <sys/types.h> #include <sys/inttypes.h> #include <sys/param.h> --- 20,30 ---- */ /* * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. ! * Copyright 2017 Nexenta Systems, Inc. */ #include <sys/types.h> #include <sys/inttypes.h> #include <sys/param.h>
*** 62,71 **** --- 62,72 ---- static char class_file[] = CLASSFILE; static char dafile[] = DAFILE; static char dacffile[] = DACFFILE; + char *self_assembly = "/etc/system.d/.self-assembly"; char *systemfile = "/etc/system"; /* name of ascii system file */ static struct sysparam *sysparam_hd; /* head of parameters list */ static struct sysparam *sysparam_tl; /* tail of parameters list */ static vmem_t *mod_sysfile_arena; /* parser memory */
*** 749,779 **** bad: kobj_find_eol(file); return (NULL); } ! void ! mod_read_system_file(int ask) { register struct sysparam *sp; register struct _buf *file; register token_t token, last_tok; char tokval[MAXLINESIZE]; ! mod_sysfile_arena = vmem_create("mod_sysfile", NULL, 0, 8, ! segkmem_alloc, segkmem_free, heap_arena, 0, VM_SLEEP); ! ! if (ask) ! mod_askparams(); ! ! if (systemfile != NULL) { ! ! if ((file = kobj_open_file(systemfile)) == (struct _buf *)-1) { cmn_err(CE_WARN, "cannot open system file: %s", ! systemfile); } else { sysparam_tl = (struct sysparam *)&sysparam_hd; last_tok = NEWLINE; while ((token = kobj_lex(file, tokval, sizeof (tokval))) != EOF) { --- 750,774 ---- bad: kobj_find_eol(file); return (NULL); } ! static void ! read_system_file(char *name) { register struct sysparam *sp; register struct _buf *file; register token_t token, last_tok; char tokval[MAXLINESIZE]; ! if ((file = kobj_open_file(name)) == (struct _buf *)-1) { + if (strcmp(name, systemfile) == 0) cmn_err(CE_WARN, "cannot open system file: %s", ! name); } else { + if (sysparam_tl == NULL) sysparam_tl = (struct sysparam *)&sysparam_hd; last_tok = NEWLINE; while ((token = kobj_lex(file, tokval, sizeof (tokval))) != EOF) {
*** 809,821 **** break; } } kobj_close_file(file); } ! } /* * Sanity check of /etc/system. */ check_system_file(); param_preset(); --- 804,835 ---- break; } } kobj_close_file(file); } ! } + void + mod_read_system_file(int ask) + { + mod_sysfile_arena = vmem_create("mod_sysfile", NULL, 0, 8, + segkmem_alloc, segkmem_free, heap_arena, 0, VM_SLEEP); + + if (ask) + mod_askparams(); + /* + * Read the user self-assembly file first + * to preserve existing system settings. + */ + if (self_assembly != NULL) + read_system_file(self_assembly); + + if (systemfile != NULL) + read_system_file(systemfile); + + /* * Sanity check of /etc/system. */ check_system_file(); param_preset();