Example #1
0
/*
 * Return the version string (dynamic buffer)
 */
char *
get_version_string(void)
{
    static char *vers = NULL;
    char tmpbuf[1024];
    char *wire_buf;
    int wire_buf_len = 0;

    /* first get dynamic string listing all known networks */
    wire_buf = print_wires();
    if (wire_buf)
        wire_buf_len = strlen(wire_buf);

    vers = xmalloc(2048 + wire_buf_len);
    sprintf(vers, "%s\n%s\n%s\n%s\n",
            "Copyright (c) 1997-2002 Erez Zadok",
            "Copyright (c) 1990 Jan-Simon Pendry",
            "Copyright (c) 1990 Imperial College of Science, Technology & Medicine",
            "Copyright (c) 1990 The Regents of the University of California.");
    sprintf(tmpbuf, "%s version %s (build %d).\n",
            PACKAGE_NAME, PACKAGE_VERSION, AMU_BUILD_VERSION);
    strcat(vers, tmpbuf);
    sprintf(tmpbuf, "Report bugs to %s.\n", PACKAGE_BUGREPORT);
    strcat(vers, tmpbuf);
    sprintf(tmpbuf, "Built by %s@%s on date %s.\n",
            USER_NAME, HOST_NAME, CONFIG_DATE);
    strcat(vers, tmpbuf);
    sprintf(tmpbuf, "cpu=%s (%s-endian), arch=%s, karch=%s.\n",
            cpu, endian, gopt.arch, gopt.karch);
    strcat(vers, tmpbuf);
    sprintf(tmpbuf, "full_os=%s, os=%s, osver=%s, vendor=%s.\n",
            gopt.op_sys_full, gopt.op_sys, gopt.op_sys_ver, gopt.op_sys_vendor);
    strcat(vers, tmpbuf);

    strcat(vers, "Map support for: ");
    mapc_showtypes(tmpbuf);
    strcat(vers, tmpbuf);
    strcat(vers, ".\nAMFS: ");
    ops_showamfstypes(tmpbuf);
    strcat(vers, tmpbuf);
    strcat(vers, ".\nFS: ");
    ops_showfstypes(tmpbuf);
    strcat(vers, tmpbuf);

    /* append list of networks if available */
    if (wire_buf) {
        strcat(vers, wire_buf);
        XFREE(wire_buf);
    }

    return vers;
}
Example #2
0
/*
 * Return the version string (dynamic buffer)
 */
char *
get_version_string(void)
{
  char *vers = NULL;
  char tmpbuf[1024];
  char *wire_buf;
  int wire_buf_len = 0;
  size_t len;		  /* max allocated length (to avoid buf overflow) */

  /*
   * First get dynamic string listing all known networks.
   * This could be a long list, if host has lots of interfaces.
   */
  wire_buf = print_wires();
  if (wire_buf)
    wire_buf_len = strlen(wire_buf);

  len = 2048 + wire_buf_len;
  vers = xmalloc(len);
  xsnprintf(vers, len, "%s\n%s\n%s\n%s\n",
	    "Copyright (c) 1997-2006 Erez Zadok",
	    "Copyright (c) 1990 Jan-Simon Pendry",
	    "Copyright (c) 1990 Imperial College of Science, Technology & Medicine",
	    "Copyright (c) 1990 The Regents of the University of California.");
  xsnprintf(tmpbuf, sizeof(tmpbuf), "%s version %s (build %d).\n",
	    PACKAGE_NAME, PACKAGE_VERSION, AMU_BUILD_VERSION);
  strlcat(vers, tmpbuf, len);
  xsnprintf(tmpbuf, sizeof(tmpbuf), "Report bugs to %s.\n", PACKAGE_BUGREPORT);
  strlcat(vers, tmpbuf, len);
  xsnprintf(tmpbuf, sizeof(tmpbuf), "Configured by %s@%s on date %s.\n",
	    USER_NAME, HOST_NAME, CONFIG_DATE);
  strlcat(vers, tmpbuf, len);
  xsnprintf(tmpbuf, sizeof(tmpbuf), "Built by %s@%s.\n",
	    BUILD_USER, BUILD_HOST);
  strlcat(vers, tmpbuf, len);
  xsnprintf(tmpbuf, sizeof(tmpbuf), "cpu=%s (%s-endian), arch=%s, karch=%s.\n",
	    cpu, endian, gopt.arch, gopt.karch);
  strlcat(vers, tmpbuf, len);
  xsnprintf(tmpbuf, sizeof(tmpbuf), "full_os=%s, os=%s, osver=%s, vendor=%s, distro=%s.\n",
	    gopt.op_sys_full, gopt.op_sys, gopt.op_sys_ver, gopt.op_sys_vendor, DISTRO_NAME);
  strlcat(vers, tmpbuf, len);
  xsnprintf(tmpbuf, sizeof(tmpbuf), "domain=%s, host=%s, hostd=%s.\n",
	    hostdomain, am_get_hostname(), hostd);
  strlcat(vers, tmpbuf, len);

  strlcat(vers, "Map support for: ", len);
  mapc_showtypes(tmpbuf, sizeof(tmpbuf));
  strlcat(vers, tmpbuf, len);
  strlcat(vers, ".\nAMFS: ", len);
  ops_showamfstypes(tmpbuf, sizeof(tmpbuf));
  strlcat(vers, tmpbuf, len);
  strlcat(vers, ", inherit.\nFS: ", len); /* hack: "show" that we support type:=inherit */
  ops_showfstypes(tmpbuf, sizeof(tmpbuf));
  strlcat(vers, tmpbuf, len);

  /* append list of networks if available */
  if (wire_buf) {
    strlcat(vers, wire_buf, len);
    XFREE(wire_buf);
  }

  return vers;
}
Example #3
0
int
main(int argc, char **argv)
{
  char *networkName1, *networkNumber1;
  struct in_addr myipaddr;	/* (An) IP address of this host */
  char *testhost, *proto, *tmp_buf;
  int nv, ret;
  struct sockaddr_in *ip;
  struct hostent *hp = NULL;

  am_set_progname(argv[0]);

  if (gethostname(hostname, sizeof(hostname)) < 0) {
    perror(argv[0]);
    exit(1);
  }
  hostname[sizeof(hostname) - 1] = '\0';

  /* get list of networks */
  getwire(&networkName1, &networkNumber1);
  tmp_buf = print_wires();
  if (tmp_buf) {
    fprintf(stderr, "%s", tmp_buf);
    XFREE(tmp_buf);
  }

  /* also print my IP address */
  amu_get_myaddress(&myipaddr, NULL);
  fprintf(stderr, "My IP address is 0x%x.\n", (unsigned int) htonl(myipaddr.s_addr));

  /*
   * NFS VERSION/PROTOCOL TESTS:
   * If argv[1] is specified  perform nfs tests to that host, else use
   * localhost.
   */
  if (argc > 1)
    testhost = argv[1];
  else
    testhost = "localhost";
  hp = gethostbyname(testhost);
  if (!hp) {
    fprintf(stderr, "NFS vers/proto failed: no such hostname \"%s\"\n", testhost);
    exit(1);
  }
  ip = (struct sockaddr_in *) xmalloc(sizeof(struct sockaddr_in));
  memset((voidp) ip, 0, sizeof(*ip));
  /* as per POSIX, sin_len need not be set (used internally by kernel) */
  ip->sin_family = AF_INET;
  memmove((voidp) &ip->sin_addr, (voidp) hp->h_addr, sizeof(ip->sin_addr));
  ip->sin_port = htons(NFS_PORT);

  fprintf(stderr, "NFS Version and protocol tests to host \"%s\"...\n", testhost);
  proto = "udp";
  for (nv=2; nv<=3; ++nv) {
    fprintf(stderr, "\ttesting vers=%d, proto=\"%s\" -> ", nv, proto);
    ret = get_nfs_version(testhost, ip, nv, proto, 0);
    if (ret == 0)
      fprintf(stderr, "failed!\n");
    else
      fprintf(stderr, "found version %d.\n", ret);
  }

  proto = "tcp";
  for (nv=2; nv<=3; ++nv) {
    fprintf(stderr, "\ttesting vers=%d, proto=\"%s\" -> ", nv, proto);
    ret = get_nfs_version(testhost, ip, nv, proto, 0);
    if (ret == 0)
      fprintf(stderr, "failed!\n");
    else
      fprintf(stderr, "found version %d.\n", ret);
  }

  exit(0);
  return 0; /* should never reach here */
}