Print this page
sysinfo emulation

Split Close
Expand all
Collapse all
          --- old/usr/src/lib/brand/solaris10/s10_brand/common/s10_brand.c
          +++ new/usr/src/lib/brand/solaris10/s10_brand/common/s10_brand.c
↓ open down ↓ 29 lines elided ↑ open up ↑
  30   30  #include <strings.h>
  31   31  #include <unistd.h>
  32   32  #include <sys/auxv.h>
  33   33  #include <sys/bitmap.h>
  34   34  #include <sys/brand.h>
  35   35  #include <sys/inttypes.h>
  36   36  #include <sys/lwp.h>
  37   37  #include <sys/syscall.h>
  38   38  #include <sys/systm.h>
  39   39  #include <sys/utsname.h>
       40 +#include <sys/systeminfo.h>
  40   41  #include <sys/zone.h>
  41   42  #include <sys/stat.h>
  42   43  #include <sys/mntent.h>
  43   44  #include <sys/ctfs.h>
  44   45  #include <sys/priv.h>
  45   46  #include <sys/acctctl.h>
  46   47  #include <libgen.h>
  47   48  
  48   49  #include <s10_brand.h>
  49   50  #include <s10_misc.h>
↓ open down ↓ 588 lines elided ↑ open up ↑
 638  639          bzero(un.version, _SYS_NMLN);
 639  640          (void) strlcpy(un.version, S10_UTS_VERSION, _SYS_NMLN);
 640  641  
 641  642          /* copy out the modified uname info */
 642  643          if (s10_uucopy(&un, unp, sizeof (un)) != 0)
 643  644                  return (EFAULT);
 644  645  
 645  646          return (0);
 646  647  }
 647  648  
      649 +int
      650 +s10_sysinfo(sysret_t *rv, int command, char *buf, long count)
      651 +{
      652 +        char *value;
      653 +        int err, len;
      654 +
      655 +        /*
      656 +         * We must interpose on the sysinfo(2) commands SI_RELEASE and
      657 +         * SI_VERSION; all others get passed to the native sysinfo(2)
      658 +         * command.
      659 +         */
      660 +        switch (command) {
      661 +                case SI_RELEASE:
      662 +                        value = S10_UTS_RELEASE;
      663 +                        break;
      664 +
      665 +                case SI_VERSION:
      666 +                        value = S10_UTS_VERSION;
      667 +                        break;
      668 +
      669 +                default:
      670 +                        /*
      671 +                         * The default action is to pass the command to the
      672 +                         * native sysinfo(2) syscall.
      673 +                         */
      674 +                        if ((err = __systemcall(rv, SYS_systeminfo + 1024,
      675 +                            command, buf, count)) != 0)
      676 +                                return (err);
      677 +
      678 +                        return (0);
      679 +        }
      680 +
      681 +        len = strlen(value) + 1;
      682 +        if (count > 0) {
      683 +                if (s10_uucopystr(value, buf, count) != 0)
      684 +                        return (EFAULT);
      685 +
      686 +                /* Assure NULL termination of buf as s10_uucopystr() doesn't. */
      687 +                if (len > count && s10_uucopy("\0", buf + (count - 1), 1) != 0)
      688 +                        return (EFAULT);
      689 +        }
      690 +
      691 +        /*
      692 +         * On success, sysinfo(2) returns the size of buffer required to hold
      693 +         * the complete value plus its terminating NULL byte.
      694 +         */
      695 +        rv->sys_rval1 = len;
      696 +        rv->sys_rval2 = 0;
      697 +        S10_TRUSS_POINT_3(rv, SYS_systeminfo, 0, command, buf, count);
      698 +        return (0);
      699 +}
      700 +
 648  701  /*
 649  702   * If the emul_global_zone flag is set then emulate some aspects of the
 650  703   * zone system call.  In particular, emulate the global zone ID on the
 651  704   * ZONE_LOOKUP subcommand and emulate some of the global zone attributes
 652  705   * on the ZONE_GETATTR subcommand.  If the flag is not set or we're performing
 653  706   * some other operation, simply pass the calls through.
 654  707   */
 655  708  int
 656  709  s10_zone(sysret_t *rval, int cmd, void *arg1, void *arg2, void *arg3,
 657  710      void *arg4)
↓ open down ↓ 466 lines elided ↑ open up ↑
1124 1177          NOSYS,                                  /* 129 */
1125 1178          NOSYS,                                  /* 130 */
1126 1179          NOSYS,                                  /* 131 */
1127 1180          NOSYS,                                  /* 132 */
1128 1181          NOSYS,                                  /* 133 */
1129 1182          NOSYS,                                  /* 134 */
1130 1183          EMULATE(s10_uname, 1 | RV_DEFAULT),     /* 135 */
1131 1184          NOSYS,                                  /* 136 */
1132 1185          NOSYS,                                  /* 137 */
1133 1186          NOSYS,                                  /* 138 */
1134      -        NOSYS,                                  /* 139 */
     1187 +        EMULATE(s10_sysinfo, 3 | RV_DEFAULT),   /* 139 */
1135 1188          NOSYS,                                  /* 140 */
1136 1189          NOSYS,                                  /* 141 */
1137 1190          NOSYS,                                  /* 142 */
1138 1191          NOSYS,                                  /* 143 */
1139 1192          NOSYS,                                  /* 144 */
1140 1193          NOSYS,                                  /* 145 */
1141 1194          NOSYS,                                  /* 146 */
1142 1195          NOSYS,                                  /* 147 */
1143 1196          NOSYS,                                  /* 148 */
1144 1197          NOSYS,                                  /* 149 */
↓ open down ↓ 111 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX