Print this page
bug fix
adding functionality and fixing bugs
adding functions to menuadm
menuadm to replace bootadm menu interaction
hypervisor + bug fix

Split Close
Expand all
Collapse all
          --- old/bootadm/bootadm_hyper.c
          +++ new/bootadm/bootadm_hyper.c
↓ open down ↓ 15 lines elided ↑ open up ↑
  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 (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
  24   24   */
  25   25  
       26 +/*
       27 + * Copyright 2012 Daniil Lunev. All rights reserved.
       28 + */
       29 +
  26   30  #include <stdio.h>
  27   31  #include <errno.h>
  28   32  #include <stdlib.h>
  29   33  #include <string.h>
  30   34  #include <unistd.h>
  31   35  #include <alloca.h>
  32   36  #include <ctype.h>
  33   37  #include <sys/types.h>
  34   38  
  35   39  #include "message.h"
  36   40  #include "bootadm.h"
  37   41  
  38   42  #define HYPER_KERNEL_DIR                "/platform/i86xpv/kernel"
  39   43  #define METAL_KERNEL_DIR                "/platform/i86pc/kernel"
  40   44  
  41   45  #define BOOTRC_FILE                     "/boot/solaris/bootenv.rc"
  42      -#define ZFS_BOOTSTR                     "$ZFS-BOOTFS"
       46 +#define ZFS_BOOTSTR                     "$ZFS_BOOTFS"
  43   47  
  44   48  #define BFLAG                           "-B"
  45   49  #define DEFAULT_SERIAL                  "9600,8,n,1"
  46   50  
  47   51  #define TTYXMODE_TO_COMNUM(ttyxmode)    ((int)(*((ttyxmode) + 3) - '`'))
  48   52  #define COMNAME_TO_COMNUM(comname)      ((int)(*((comname) + 3) - '0'))
  49   53  
  50   54  #define WHITESPC(x)                     (x)
  51   55  
  52   56  static char *serial_config[2] = { NULL, NULL };
↓ open down ↓ 703 lines elided ↑ open up ↑
 756  760          entry_t *ent;
 757  761          size_t len, zfslen;
 758  762  
 759  763          char *newstr;
 760  764          char *osdev;
 761  765  
 762  766          char *title = NULL;
 763  767          char *findroot = NULL;
 764  768          char *bootfs = NULL;
 765  769          char *kernel = NULL;
      770 +        char *opts = NULL;
 766  771          char *mod_kernel = NULL;
 767  772          char *module = NULL;
      773 +        char *tmp = NULL;
 768  774  
 769  775          char *kern_path = NULL;
 770  776          char *kern_bargs = NULL;
 771  777  
 772  778          int curdef, newdef;
 773  779          int kp_allocated = 0;
 774  780          int ret = BAM_ERROR;
 775  781  
 776  782          assert(osroot);
 777  783  
↓ open down ↓ 56 lines elided ↑ open up ↑
 834  840          /*
 835  841           * Now process the entry itself.
 836  842           */
 837  843          for (lp = ent->start; lp != NULL; lp = lp->next) {
 838  844                  /*
 839  845                   * Process important lines from menu.lst boot entry.
 840  846                   */
 841  847                  if (lp->flags == BAM_TITLE) {
 842  848                          title = strdupa(lp->arg);
 843  849                  } else if (lp->cmd != NULL) {
 844      -                        if (strcmp(lp->cmd, "findroot") == 0) {
      850 +                        if (strcmp(lp->cmd, "pool_label") == 0) {
 845  851                                  findroot = strdupa(lp->arg);
 846      -                        } else if (strcmp(lp->cmd, "bootfs") == 0) {
      852 +                        } else if (strcmp(lp->cmd, "data_set") == 0) {
 847  853                                  bootfs = strdupa(lp->arg);
      854 +                        } else if (strcmp(lp->cmd, "kernel_options") == 0) {
      855 +                                opts = strdupa(lp->arg);
 848  856                          } else if (strcmp(lp->cmd,
 849  857                              menu_cmds[MODULE_DOLLAR_CMD]) == 0) {
 850  858                                  module = strdupa(lp->arg);
 851  859                          } else if ((strcmp(lp->cmd,
 852  860                              menu_cmds[KERNEL_DOLLAR_CMD]) == 0) &&
 853  861                              (ret = cvt_metal_kernel(lp->arg,
 854  862                              &kern_path)) != 0) {
 855  863                                  if (ret < 0) {
 856  864                                          ret = BAM_ERROR;
 857  865                                          bam_error(KERNEL_NOT_PARSEABLE, curdef);
↓ open down ↓ 1 lines elided ↑ open up ↑
 859  867                                          ret = BAM_NOCHANGE;
 860  868  
 861  869                                  goto abort;
 862  870                          }
 863  871                  }
 864  872  
 865  873                  if (lp == ent->end)
 866  874                          break;
 867  875          }
 868  876  
      877 +        
 869  878          /*
 870  879           * If findroot, module or kern_path are NULL, the boot entry is
 871  880           * malformed.
 872  881           */
 873  882          if (findroot == NULL) {
 874  883                  bam_error(FINDROOT_NOT_FOUND, curdef);
 875  884                  goto abort;
 876  885          }
 877  886  
 878  887          if (module == NULL) {
↓ open down ↓ 62 lines elided ↑ open up ↑
 941  950  
 942  951          /*
 943  952           * We need to allocate space for the kernel path (twice) plus an
 944  953           * intervening space, possibly the ZFS boot string, and NULL,
 945  954           * of course.
 946  955           */
 947  956          len = (strlen(kern_path) * 2) + WHITESPC(1) + 1;
 948  957          zfslen = (zfs_boot ? (WHITESPC(1) + strlen(ZFS_BOOT)) : 0);
 949  958  
 950  959          mod_kernel = alloca(len + zfslen);
 951      -        (void) snprintf(mod_kernel, len, "%s %s", kern_path, kern_path);
      960 +        if (opts)
      961 +                (void) snprintf(mod_kernel, len + strlen(opts) + 1, "%s %s %s", kern_path, kern_path, opts);
      962 +        else
      963 +                (void) snprintf(mod_kernel, len, "%s %s", kern_path, kern_path);
 952  964  
 953  965          if (kp_allocated)
 954  966                  free(kern_path);
 955  967  
 956  968          if (zfs_boot) {
 957  969                  char *zfsstr = alloca(zfslen + 1);
 958  970  
 959  971                  (void) snprintf(zfsstr, zfslen + 1, " %s", ZFS_BOOT);
 960  972                  (void) strcat(mod_kernel, zfsstr);
 961  973          }
↓ open down ↓ 93 lines elided ↑ open up ↑
1055 1067          /*
1056 1068           * Now process the entry itself.
1057 1069           */
1058 1070          for (lp = ent->start; lp != NULL; lp = lp->next) {
1059 1071                  /*
1060 1072                   * Process important lines from menu.lst boot entry.
1061 1073                   */
1062 1074                  if (lp->flags == BAM_TITLE) {
1063 1075                          title = strdupa(lp->arg);
1064 1076                  } else if (lp->cmd != NULL) {
1065      -                        if (strcmp(lp->cmd, "findroot") == 0) {
     1077 +                        if (strcmp(lp->cmd, "pool_label") == 0) {
1066 1078                                  findroot = strdupa(lp->arg);
1067      -                        } else if (strcmp(lp->cmd, "bootfs") == 0) {
     1079 +                        } else if (strcmp(lp->cmd, "data_set") == 0) {
1068 1080                                  bootfs = strdupa(lp->arg);
1069 1081                          } else if (strcmp(lp->cmd,
1070 1082                              menu_cmds[MODULE_DOLLAR_CMD]) == 0) {
1071 1083                                  if (strstr(lp->arg, "boot_archive") == NULL) {
1072 1084                                          module = strdupa(lp->arg);
1073 1085                                          cvt_hyper_module(module, &kern_path);
1074 1086                                  } else {
1075 1087                                          barchive_path = strdupa(lp->arg);
1076 1088                                  }
1077 1089                          } else if ((strcmp(lp->cmd,
↓ open down ↓ 178 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX