Print this page
9696 add /etc/system.d support
Reviewed by: Dan Fields <dan.fields@nexenta.com>
Reviewed by: Roman Strashkin <roman.strashkin@nexenta.com>
Reviewed by: Cynthia Eastham <cynthia.eastham@nexenta.com>
Reviewed by: Toomas Soome <tsoome@me.com>
Reviewed by: Peter Tribble <peter.tribble@gmail.com>
Reviewed by: Andy Fiddaman <andy@omniosce.org>

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/os/modsysfile.c
          +++ new/usr/src/uts/common/os/modsysfile.c
↓ open down ↓ 14 lines elided ↑ open up ↑
  15   15   * If applicable, add the following below this CDDL HEADER, with the
  16   16   * fields enclosed by brackets "[]" replaced with your own identifying
  17   17   * information: Portions Copyright [yyyy] [name of copyright owner]
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
  21   21  
  22   22  /*
  23   23   * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
  24   24   * Use is subject to license terms.
  25      - * Copyright 2016 Nexenta Systems, Inc.
       25 + * Copyright 2017 Nexenta Systems, Inc.
  26   26   */
  27   27  
  28   28  #include <sys/types.h>
  29   29  #include <sys/inttypes.h>
  30   30  #include <sys/param.h>
  31   31  #include <sys/systm.h>
  32   32  #include <sys/user.h>
  33   33  #include <sys/disp.h>
  34   34  #include <sys/conf.h>
  35   35  #include <sys/bootconf.h>
↓ open down ↓ 21 lines elided ↑ open up ↑
  57   57  static kmutex_t hcl_lock;       /* for accessing list of classes */
  58   58  
  59   59  #define DAFILE          "/etc/driver_aliases"
  60   60  #define CLASSFILE       "/etc/driver_classes"
  61   61  #define DACFFILE        "/etc/dacf.conf"
  62   62  
  63   63  static char class_file[] = CLASSFILE;
  64   64  static char dafile[] = DAFILE;
  65   65  static char dacffile[] = DACFFILE;
  66   66  
       67 +char *self_assembly = "/etc/system.d/.self-assembly";
  67   68  char *systemfile = "/etc/system";       /* name of ascii system file */
  68   69  
  69   70  static struct sysparam *sysparam_hd;    /* head of parameters list */
  70   71  static struct sysparam *sysparam_tl;    /* tail of parameters list */
  71   72  static vmem_t *mod_sysfile_arena;       /* parser memory */
  72   73  
  73   74  char obp_bootpath[BO_MAXOBJNAME];       /* bootpath from obp */
  74   75  
  75   76  #if defined(_PSM_MODULES)
  76   77  
↓ open down ↓ 667 lines elided ↑ open up ↑
 744  745                  goto bad;
 745  746          }
 746  747  
 747  748          return (sysp);
 748  749  
 749  750  bad:
 750  751          kobj_find_eol(file);
 751  752          return (NULL);
 752  753  }
 753  754  
 754      -void
 755      -mod_read_system_file(int ask)
      755 +static void
      756 +read_system_file(char *name)
 756  757  {
 757  758          register struct sysparam *sp;
 758  759          register struct _buf *file;
 759  760          register token_t token, last_tok;
 760  761          char tokval[MAXLINESIZE];
 761  762  
 762      -        mod_sysfile_arena = vmem_create("mod_sysfile", NULL, 0, 8,
 763      -            segkmem_alloc, segkmem_free, heap_arena, 0, VM_SLEEP);
 764      -
 765      -        if (ask)
 766      -                mod_askparams();
 767      -
 768      -        if (systemfile != NULL) {
 769      -
 770      -                if ((file = kobj_open_file(systemfile)) ==
 771      -                    (struct _buf *)-1) {
      763 +        if ((file = kobj_open_file(name)) ==
      764 +            (struct _buf *)-1) {
      765 +                if (strcmp(name, systemfile) == 0)
 772  766                          cmn_err(CE_WARN, "cannot open system file: %s",
 773      -                            systemfile);
 774      -                } else {
      767 +                            name);
      768 +        } else {
      769 +                if (sysparam_tl == NULL)
 775  770                          sysparam_tl = (struct sysparam *)&sysparam_hd;
 776  771  
 777      -                        last_tok = NEWLINE;
 778      -                        while ((token = kobj_lex(file, tokval,
 779      -                            sizeof (tokval))) != EOF) {
 780      -                                switch (token) {
 781      -                                case STAR:
 782      -                                case POUND:
 783      -                                        /*
 784      -                                         * Skip comments.
 785      -                                         */
      772 +                last_tok = NEWLINE;
      773 +                while ((token = kobj_lex(file, tokval,
      774 +                    sizeof (tokval))) != EOF) {
      775 +                        switch (token) {
      776 +                        case STAR:
      777 +                        case POUND:
      778 +                                /*
      779 +                                 * Skip comments.
      780 +                                 */
      781 +                                kobj_find_eol(file);
      782 +                                break;
      783 +                        case NEWLINE:
      784 +                                kobj_newline(file);
      785 +                                last_tok = NEWLINE;
      786 +                                break;
      787 +                        case NAME:
      788 +                                if (last_tok != NEWLINE) {
      789 +                                        kobj_file_err(CE_WARN, file,
      790 +                                            extra_err, tokval);
 786  791                                          kobj_find_eol(file);
 787      -                                        break;
 788      -                                case NEWLINE:
 789      -                                        kobj_newline(file);
 790      -                                        last_tok = NEWLINE;
 791      -                                        break;
 792      -                                case NAME:
 793      -                                        if (last_tok != NEWLINE) {
 794      -                                                kobj_file_err(CE_WARN, file,
 795      -                                                    extra_err, tokval);
 796      -                                                kobj_find_eol(file);
 797      -                                        } else if ((sp = do_sysfile_cmd(file,
 798      -                                            tokval)) != NULL) {
 799      -                                                sp->sys_next = NULL;
 800      -                                                sysparam_tl->sys_next = sp;
 801      -                                                sysparam_tl = sp;
 802      -                                        }
 803      -                                        last_tok = NAME;
 804      -                                        break;
 805      -                                default:
 806      -                                        kobj_file_err(CE_WARN,
 807      -                                            file, tok_err, tokval);
 808      -                                        kobj_find_eol(file);
 809      -                                        break;
      792 +                                } else if ((sp = do_sysfile_cmd(file,
      793 +                                    tokval)) != NULL) {
      794 +                                        sp->sys_next = NULL;
      795 +                                        sysparam_tl->sys_next = sp;
      796 +                                        sysparam_tl = sp;
 810  797                                  }
      798 +                                last_tok = NAME;
      799 +                                break;
      800 +                        default:
      801 +                                kobj_file_err(CE_WARN,
      802 +                                    file, tok_err, tokval);
      803 +                                kobj_find_eol(file);
      804 +                                break;
 811  805                          }
 812      -                        kobj_close_file(file);
 813  806                  }
      807 +                kobj_close_file(file);
 814  808          }
      809 +}
 815  810  
      811 +void
      812 +mod_read_system_file(int ask)
      813 +{
      814 +        mod_sysfile_arena = vmem_create("mod_sysfile", NULL, 0, 8,
      815 +            segkmem_alloc, segkmem_free, heap_arena, 0, VM_SLEEP);
      816 +
      817 +        if (ask)
      818 +                mod_askparams();
      819 +
 816  820          /*
      821 +         * Read the user self-assembly file first
      822 +         * to preserve existing system settings.
      823 +         */
      824 +        if (self_assembly != NULL)
      825 +                read_system_file(self_assembly);
      826 +
      827 +        if (systemfile != NULL)
      828 +                read_system_file(systemfile);
      829 +
      830 +        /*
 817  831           * Sanity check of /etc/system.
 818  832           */
 819  833          check_system_file();
 820  834  
 821  835          param_preset();
 822  836          (void) mod_sysctl(SYS_SET_KVAR, NULL);
 823  837          param_check();
 824  838  
 825  839          if (ask == 0)
 826  840                  setparams();
↓ open down ↓ 2418 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX