Print this page
halt

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/halt/halt.c
          +++ new/usr/src/cmd/halt/halt.c
↓ open down ↓ 110 lines elided ↑ open up ↑
 111  111          struct ctidlist_struct *next;
 112  112  } ctidlist_t;
 113  113  
 114  114  static ctidlist_t *ctidlist = NULL;
 115  115  static ctid_t startdct = -1;
 116  116  
 117  117  #define FMRI_STARTD_CONTRACT \
 118  118          "svc:/system/svc/restarter:default/:properties/restarter/contract"
 119  119  
 120  120  #define BEADM_PROG      "/usr/sbin/beadm"
 121      -#define BOOTADM_PROG    "/sbin/bootadm"
      121 +#define GRUBADM_PROG    "/sbin/grubadm"
 122  122  #define ZONEADM_PROG    "/usr/sbin/zoneadm"
 123  123  
 124  124  /*
 125  125   * The length of FASTBOOT_MOUNTPOINT must be less than MAXPATHLEN.
 126  126   */
 127  127  #define FASTBOOT_MOUNTPOINT     "/tmp/.fastboot.root"
 128  128  
 129  129  /*
 130  130   * Fast Reboot related variables
 131  131   */
↓ open down ↓ 804 lines elided ↑ open up ↑
 936  936          } else {
 937  937                  if (waitpid(pid, &st, 0) == pid &&
 938  938                      !WIFSIGNALED(st) && WIFEXITED(st))
 939  939                          st = WEXITSTATUS(st);
 940  940                  else
 941  941                          st = -1;
 942  942          }
 943  943          return (st);
 944  944  }
 945  945  
      946 +static int
      947 +exec_cmd(char * invoke, char * output)
      948 +{
      949 +        FILE * cmd = popen(invoke, "r");
      950 +        if (! cmd) 
      951 +                return 0;
      952 +        fgets(output, 512, cmd);
      953 +        if (! *output) {
      954 +                pclose(cmd);
      955 +                return 0;
      956 +        }
      957 +        output[strlen(output) - 2] = '\0';
      958 +        pclose(cmd);
      959 +        return 1;
      960 +}
      961 +
 946  962  /*
 947  963   * Mount the specified BE.
 948  964   *
 949  965   * Upon success returns zero and copies bename string to mountpoint[]
 950  966   */
 951  967  static int
 952  968  fastboot_bename(const char *bename, char *mountpoint, size_t mpsz)
 953  969  {
 954  970          int rc;
 955  971  
↓ open down ↓ 95 lines elided ↑ open up ↑
1051 1067                   */
1052 1068                  int entnum;
1053 1069                  if (bootargs_buf[0] == 0)
1054 1070                          entnum = GRUB_ENTRY_DEFAULT;
1055 1071                  else {
1056 1072                          errno = 0;
1057 1073                          entnum = strtoul(bootargs_buf, NULL, 10);
1058 1074                          rc = errno;
1059 1075                  }
1060 1076  
1061      -                if (rc == 0 && (rc = grub_get_boot_args(&fbarg, NULL,
1062      -                    entnum)) == 0) {
     1077 +                if (rc == 0 && (rc = exec_cmd("/sbin/grubadm --number -1 --get-opts",
     1078 +                                fbarg.gba_bootargs)) == 0) {
1063 1079                          if (strlcpy(bootargs_buf, fbarg.gba_bootargs,
1064 1080                              buf_size) >= buf_size) {
1065 1081                                  grub_cleanup_boot_args(&fbarg);
1066 1082                                  bcopy(bootargs_saved, bootargs_buf, buf_size);
1067 1083                                  rc = E2BIG;
1068 1084                          }
1069 1085                  }
1070 1086                  /* Failed to read GRUB menu, fall back to normal reboot */
1071 1087                  if (rc != 0) {
1072 1088                          (void) fprintf(stderr,
↓ open down ↓ 430 lines elided ↑ open up ↑
1503 1519           * check_zone_haltedness later on.
1504 1520           */
1505 1521          if (zoneid == GLOBAL_ZONEID && cmd != A_DUMP) {
1506 1522                  need_check_zones = halt_zones();
1507 1523          }
1508 1524  
1509 1525  #if defined(__i386)
1510 1526          /* set new default entry in the GRUB entry */
1511 1527          if (fbarg_entnum != GRUB_ENTRY_DEFAULT) {
1512 1528                  char buf[32];
1513      -                (void) snprintf(buf, sizeof (buf), "default=%u", fbarg_entnum);
1514      -                (void) halt_exec(BOOTADM_PROG, "set-menu", buf, NULL);
     1529 +                (void) snprintf(buf, sizeof (buf), "--set-default %u", fbarg_entnum);
     1530 +                (void) halt_exec(GRUBADM_PROG, " ", buf, NULL);
1515 1531          }
1516 1532  #endif  /* __i386 */
1517 1533  
1518 1534          /* if we're dumping, do the archive update here and don't defer it */
1519 1535          if (cmd == A_DUMP && zoneid == GLOBAL_ZONEID && !nosync)
1520 1536                  do_archives_update(fast_reboot);
1521 1537  
1522 1538          /*
1523 1539           * If we're not forcing a crash dump, mark the system as quiescing for
1524 1540           * smf(5)'s benefit, and idle the init process.
↓ open down ↓ 154 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX