Exemplo n.º 1
0
static unsigned long
_get_host_id()
{
#ifdef _SC_BSD_NETWORK
    if (sysconf(_SC_BSD_NETWORK) >= 0)
	return gethostid();
    else
	return 0;
#else /* _SC_BSD_NETWORK */
    return gethostid();
#endif /* _SC_BSD_NETWORK */
}
Exemplo n.º 2
0
/*
 * Return random unsigned 32-bit quantity. Use 'type' argument if you
 * need to generate several different values in close succession.
 */
guint32
random32(int type)
{
  struct {
    int     type;
    struct  timeval tv;
    clock_t cpu;
    pid_t   pid;
    guint32  hid;
    uid_t   uid;
    gid_t   gid;
    struct  utsname name;
  } s;
  
  gettimeofday(&s.tv, 0);
  uname(&s.name);
  s.type = type;
  s.cpu  = clock();
  s.pid  = getpid();
  s.hid  = gethostid();
  s.uid  = getuid();
  s.gid  = getgid();
  
  return md_32((char *)&s, sizeof(s));
}
Exemplo n.º 3
0
int
main(int argc, char *argv[])
{
	unsigned int hid_input;
	int rv;

	if (argc == 1) {
		hid_input = (unsigned int) gethostid();
	} else if (argc == 2) {
		sscanf(argv[1], "%x", &hid_input);
	} else {
		fprintf(stderr, "Usage: jsethid [hex-value]\n");
		exit(1);
	}

	rv = job_sethid(hid_input);
	if (rv == -1) {
		if (errno == ENOENT) {
			if (hid_input == 0xffffffff) {
				/* Tried to disable job, but 
				 * job is already disabled. 
				 * Not an error. */
				exit(0);
			} else {
				fprintf(stderr, "jobd does not appear to be running.\n");
				exit(1);
			}
		} else {
			perror("job_sethid");
			exit(1);
		}
	}

	exit(0);
}
Exemplo n.º 4
0
/*
 * magic_init - Initialize the magic number generator.
 *
 * Attempts to compute a random number seed which will not repeat.
 */
static void
tac_magic_init()
{
    struct stat statbuf;
    long seed;
    struct timeval t;

    if (magic_initialised)
        return;

    // try to initialise seed from urandom
    if (!lstat("/dev/urandom", &statbuf) && S_ISCHR(statbuf.st_mode)) {
        int rfd = open("/dev/urandom", O_RDONLY);
        if(rfd >= 0) {
            if (read(rfd, &seed, sizeof(seed)) < 0)
                seed = 0;
            close(rfd);
        }
        else
            seed = 0;
    }

    // fallback
    gettimeofday(&t, NULL);
    seed ^= gethostid() ^ t.tv_sec ^ t.tv_usec ^ getpid();

    // finally seed the PRNG
    srandom(seed);
    magic_initialised = 1;
}
Exemplo n.º 5
0
int main() {
  char host[256] = "--------------------------";

  printf("gethostid: %d\n", gethostid());
  printf("errno: %d\n\n", errno);
  errno = 0;

  printf("gethostname/2 ret: %d\n", gethostname(host, 2));
  printf("gethostname/2: %s\n", host);
  printf("errno: %d\n\n", errno);
  errno = 0;

  printf("gethostname/256 ret: %d\n", gethostname(host, 256));
  printf("gethostname/256: %s\n", host);
  printf("errno: %d\n\n", errno);
  errno = 0;

  char login[256] = "--------------------------";

  printf("login: %s\n", getlogin());
  printf("errno: %d\n\n", errno);
  errno = 0;

  printf("login_r/2 ret: %d\n", getlogin_r(login, 2));
  printf("login_r/2: %s\n", login);
  printf("errno: %d\n\n", errno);
  errno = 0;

  printf("login_r/256 ret: %d\n", getlogin_r(login, 256));
  printf("login_r/256: %s\n", login);
  printf("errno: %d\n", errno);
  errno = 0;

  return 0;
}
Exemplo n.º 6
0
int32_t qad_unique_name(unsigned char *str, int32_t *sz){
  uint32_t hid = gethostid();
  uint32_t pid = getpid();
  int32_t t1, nc, i;
  uint64_t ts;
  struct timeval t;
  size_t szt = *sz;
  unsigned char lsz[33];

  t1 = gettimeofday(&t, NULL);
  ts = t.tv_sec ;
  ts = ts * 10000000 ;       // convert seconds to microseconds
  ts = ts + t.tv_usec ;      // 32 bits for seconds, 20 bits for microseconds, we will encode 9*6 =  54 bits
  for(i=0 ; i<9 ; i++) {lsz[i] = b64[ts & 0x3F] ; ts = ts >> 6; } ;  // encode 6 bits at a time (9 chars)

  ts = pid ;
  ts = ts << 32;
  ts = ts | hid;
  for(i=0 ; i<11 ; i++) {lsz[i+9] = b64[ts & 0x3F] ; ts = ts >> 6; } ;  // encode 6 bits at a time (11 chars)

  lsz[20] = '\0' ;
  t1 = 20 ; // need 20 chars to encode the whole thing

  nc = t1 > szt - 1 ? szt - 1 : t1;                 // there is room for at most szt - 1 characters
  for(i=0 ; i<nc ; i++) { str[i] = lsz[i] ; } ;     // copy nc characters
  str[nc] = '\0';                                   // make sure the string is NULL terminated
  return nc;
}
Exemplo n.º 7
0
int
main (int argc, char **argv)
{
  long int id;

  initialize_main (&argc, &argv);
  program_name = argv[0];
  setlocale (LC_ALL, "");
  bindtextdomain (PACKAGE, LOCALEDIR);
  textdomain (PACKAGE);

  atexit (close_stdout);

  parse_long_options (argc, argv, PROGRAM_NAME, GNU_PACKAGE, VERSION,
		      usage, AUTHORS, (char const *) NULL);

  if (argc > 1)
    {
      error (0, 0, _("too many arguments"));
      usage (EXIT_FAILURE);
    }

  id = gethostid ();
  printf ("%lx\n", id);

  exit (EXIT_SUCCESS);
}
Exemplo n.º 8
0
/* platform specific initialization */
void vt_pform_init() {
  int  pid = getpid();
  char exec_proc[512];
  int  hostid_retries;

#if TIMER == TIMER_SWITCH_CLOCK
  int i;
  for (i=0; i<NUMRETRY; i++) {
    if ( (vt_swclk = swclockInit()) != 0 ) break;
  }
#elif TIMER == TIMER_POWER_REALTIME
  timebasestruct_t t;
  read_real_time(&t, TIMEBASE_SZ);
  time_base_to_time(&t, TIMEBASE_SZ);
  vt_time_base = t.tb_high - (t.tb_high & 0xFFFF);
#elif TIMER == TIMER_PAPI_REAL_USEC
  vt_time_base = vt_metric_real_usec();
#endif

  /* get full path of executable */
  snprintf(exec_proc, sizeof (exec_proc), VT_PROCDIR"%d/object/a.out", pid);
  vt_exec = strdup(exec_proc);

  /* get unique numeric SMP-node identifier */
  hostid_retries = 0;
  while( !vt_node_id && (hostid_retries++ < VT_MAX_GETHOSTID_RETRIES) ) {
    vt_node_id = gethostid();
  }
  if (!vt_node_id)
    vt_error_msg("Maximum retries (%i) for gethostid exceeded!",
		 VT_MAX_GETHOSTID_RETRIES);
}
Exemplo n.º 9
0
long
_tt_gethostid(void)
{
	long _hostid;
#if defined(OPT_SYSINFO)
	{
		char		serial_num[40];

		if (sysinfo(SI_HW_SERIAL, serial_num, 40) > 0) {
			sscanf(serial_num, "%12lx", &_hostid);
		}
	}
#elif defined(hpux) || defined(_AIX) || defined(__osf__)
	struct utsname uts_name;
	
	uname(&uts_name);
#	if defined(_AIX) || defined(__osf__)
		_hostid = atol(uts_name.machine);
#	else
		_hostid = atol(uts_name.idnumber);
#	endif
#else
	_hostid = gethostid();
#endif
	return _hostid;
}
Exemplo n.º 10
0
int main(int argc, char **argv)
{
    unsigned int length = 0, new_hostid;
    long old_hostid = gethostid();

    if (argc != 2)
        goto err;

    length = strlen(argv[1]);

    if (length != 8 || sscanf(argv[1], "%x", &new_hostid) != 1)
        goto err;

    if ((long) new_hostid == old_hostid)
        return EXIT_SUCCESS;

#ifdef __APPLE__
    sethostid(new_hostid);
#else
    if (sethostid(new_hostid) < 0) {
        fprintf(stderr, "Failed with %u (%s)\n", errno, strerror(errno));
        return EXIT_FAILURE;
    }
#endif

    return EXIT_SUCCESS;

  err:
    errx(EXIT_FAILURE, "Usage: %s id\n"
         "id is an 8-char hexadecimal representation, "
         "as in the output of 'hostid'.\n", argv[0]);
}
Exemplo n.º 11
0
Arquivo: main.c Projeto: codlab/ftpony
void drawFrame()
{
	u8* bufAdr=gfxGetFramebuffer(GFX_TOP, GFX_LEFT, NULL, NULL);

	int i, j;
	for(i=1;i<400;i++)
	{
		for(j=1;j<240;j++)
		{
			u32 v=(j+i*240)*3;
			bufAdr[v]=(pcCos(i+cnt)+4096)/32;
			bufAdr[v+1]=(pcCos(j-256+cnt)+4096)/64;
			bufAdr[v+2]=(pcCos(i+128-cnt)+4096)/32;
		}
	}
	gfxDrawText(GFX_TOP, GFX_LEFT, NULL, "ftPONY v0.0003 gamma\n", 240-fontDefault.height*1, 10);
	u32 ip = gethostid();
	char bof[256];
	sprintf(bof, "IP: %lu.%lu.%lu.%lu\n", ip & 0xFF, (ip>>8)&0xFF, (ip>>16)&0xFF, (ip>>24)&0xFF);
	gfxDrawText(GFX_TOP, GFX_LEFT, NULL, bof, 240-fontDefault.height*2, 10);

	gfxDrawText(GFX_TOP, GFX_LEFT, NULL, quotes[curQuote], 240-fontDefault.height*3, 10);
	i = countLines(superStr);
	while(i>240/fontDefault.height-3){cutLine(superStr);i--;}
	gfxDrawText(GFX_TOP, GFX_LEFT, NULL, superStr, 240-fontDefault.height*4, 20);
	cnt++;

	gfxFlushBuffers();
	gfxSwapBuffers();
}
Exemplo n.º 12
0
static unsigned int gen_challenge(void)
{
    struct {
	struct timeval tv;
	clock_t cpu;
	pid_t pid;
	u_long hid;
	uid_t uid;
	gid_t gid;
	struct utsname name;
    } s;

    memset(&s, 0, sizeof(s));
    gettimeofday(&s.tv, 0);
    uname(&s.name);
    s.cpu  = clock();
    s.pid  = getpid();
#ifndef __ANDROID__
    s.hid  = gethostid();
#else
    s.hid  = 0;
#endif
    s.uid  = getuid();
    s.gid  = getgid();

    return md_32((char*) &s, sizeof(s));
}
Exemplo n.º 13
0
static int Phostid(lua_State *L)		/** hostid() */
{
	char b[32];
	sprintf(b,"%ld",gethostid());
	lua_pushstring(L, b);
	return 1;
}
Exemplo n.º 14
0
int gethostname( char* machname, size_t buflen)
{
	OSStatus          theErr = kOTNoError;
	InetHost		  addr;
	struct hostent   *host;
	char* firstDot;

	if( (machname == NULL) || (buflen < 31)){
		ncbi_SetErrno( EINVAL);
		return( -1);
	}

	addr = gethostid();

	host = gethostbyaddr( &addr, INADDRSZ, AF_INET);
	if(host == NULL){
		ncbi_SetErrno( EINVAL);
		return( -1);
	}
  
	firstDot = strchr(host->h_name, '.');
	if(firstDot != NULL && *firstDot == '.'){
		*firstDot = '\0';
	}

	strncpy( machname, host->h_name, buflen);
	machname[buflen-1] = '\0';  // strncpy doesn't always null terminate
    
	if(theErr != kOTNoError)
		return(-1);
	else
		return(0);
}
Exemplo n.º 15
0
int FClient::requestID(const char *desc)
{
	int socketfd;
	unsigned char buf[128];
	int i;
	unsigned int uret;
	FILE *f;
	int hid;

	hid = gethostid();

	/* connect to the server */
	socketfd = connectServer();
	if (socketfd<0) {
		return 0;
	}
	
	/* send the request */
	sendMessage(socketfd,"",FGETMACHINEID);

	/* read the id */
	uret = readU32(socketfd);

	/* close the socket */
	close(socketfd);

	return uret;
}
Exemplo n.º 16
0
static YAP_Bool host_id(void) {
#if HAVE_GETHOSTID
  return (YAP_Unify(YAP_ARG1, YAP_MkIntTerm(gethostid())));
#else
  return (YAP_Unify(YAP_ARG1, YAP_MkIntTerm(0)));
#endif
}
Exemplo n.º 17
0
int IdResolve::getHostId()
{
	char query[2048];
	int idx;
	string a;
	unsigned int hostid;

	hostid = gethostid();
	
	// set an initial id 
	idx = -1;

	// create a new working variable
	work *wv = new work(*conn);

	// create the query 
	sprintf(query,"SELECT id FROM machine WHERE mainuserid = '%d'",hostid);

	// perform a query
	result R = wv->exec(query);

	if (R.size()==1) {
		result::const_iterator r = R.begin();
		a = string(r[0].c_str());
	
		idx = atoi(a.c_str());
	}

	// delete the working variable
	delete wv;

	return idx;
}
Exemplo n.º 18
0
/*
 * magic_init - Initialize the magic number generator.
 *
 * Attempts to compute a random number seed which will not repeat.
 * The current method uses the current hostid, current process ID
 * and current time, currently.
 */
void
magic_init()
{
    struct stat statbuf;
    long seed;
    struct timeval t;

    if (magic_inited)
        return;

    magic_inited = 1;

    /*
        try using /dev/urandom
        also check that it's a character device
        If it doesn't exist, fallback to other method
    */

    if (!lstat("/dev/urandom", &statbuf) && S_ISCHR(statbuf.st_mode)) {
        rfd = open("/dev/urandom", O_RDONLY);
        if (rfd >= 0)
            return;
    } 

    gettimeofday(&t, NULL);
    seed = gethostid() ^ t.tv_sec ^ t.tv_usec ^ getpid();
    srandom(seed);
}
Exemplo n.º 19
0
Arquivo: main.c Projeto: wgc1212/pimd
static void do_randomize(void)
{
#define rol32(data,shift) ((data) >> (shift)) | ((data) << (32 - (shift)))
   int fd;
   unsigned int seed;

   /* Setup a fallback seed based on quasi random. */
#ifdef SYSV
   seed = time(NULL);
#else
   seed = time(NULL) ^ gethostid();
#endif
   seed = rol32(seed, seed);

   fd = open("/dev/urandom", O_RDONLY);
   if (fd >= 0) {
       if (-1 == read(fd, &seed, sizeof(seed)))
	   warn("Failed reading entropy from /dev/urandom");
       close(fd);
  }

#ifdef SYSV
   srand48(seed);
#else
   srandom(seed);
#endif
}
Exemplo n.º 20
0
void libsolkerncompat_init()
{
	/* LINUX */
	ncpus = sysconf(_SC_NPROCESSORS_CONF);
#ifdef __native_client__
	/*temp fix while migrating to new memory manager*/
#define MMAP_PSEUDO_HEAP_SIZE     0xE0000000
	physmem = MMAP_PSEUDO_HEAP_SIZE / sysconf(_SC_PAGESIZE);
#else
	physmem = sysconf(_SC_PHYS_PAGES);
#endif
	_pagesize = sysconf(_SC_PAGESIZE);
	_pageshift = ffs(_pagesize) - 1;
	pwd_buflen = sysconf(_SC_GETPW_R_SIZE_MAX);
	grp_buflen = sysconf(_SC_GETGR_R_SIZE_MAX);

	uname(&utsname);
	snprintf(hw_serial, sizeof(hw_serial), "%ld", gethostid());

	VERIFY(ncpus > 0 && physmem > 0);

#ifdef DEBUG
	printf("hostname = %s\n", utsname.nodename);
	printf("hw_serial = %s\n", hw_serial);
	printf("ncpus = %i\n", ncpus);
	printf("physmem = %llu pages (%.2f GB)\n", (unsigned long long) physmem, (double) physmem * sysconf(_SC_PAGE_SIZE) / (1ULL << 30));
	printf("pagesize = %li, pageshift: %i\n", _pagesize, _pageshift);
	printf("pwd_buflen = %li, grp_buflen = %li\n\n", pwd_buflen, grp_buflen);
#endif

	vnode_cache = kmem_cache_create("vnode_t", sizeof(vnode_t), 0, NULL, NULL, NULL, NULL, NULL, 0);
	VERIFY(vnode_cache != NULL);

	vfs_init();
}
Exemplo n.º 21
0
long
OSUtil_hostid()
{
  static long hostid = OSUtil_hostid_NULL;
  struct sigaction act, old_act;

  if (hostid == OSUtil_hostid_NULL) {
    memset(&act, 0, sizeof(act));
    memset(&old_act, 0, sizeof(old_act));
    act.sa_handler = hostid_fpe_handler;
    act.sa_flags = 0;
    sigemptyset(&act.sa_mask);

    hostid_jbuf_active = 0;
    sigaction(SIGFPE, &act, &old_act);

    if (sigsetjmp(hostid_jbuf, 1) == 0) {
      // normal return
      hostid_jbuf_active = 1;

      // gethostid returns long, but only 32 bits
      hostid = (uint32_t) gethostid();
    }
    else {
      // error return from signal handler
      hostid = OSUtil_hostid_fail;
    }
    hostid_jbuf_active = 0;

    // reset the handler so we don't get called again
    sigaction(SIGFPE, &old_act, NULL);
  }

  return hostid;
}
Exemplo n.º 22
0
// ------------------------------------------------------------------------
// getConfig
// Purpose : read the configuration from the env.  Will soon change...
//
// ------------------------------------------------------------------------
int spConfig::getConfig()
{
     // will be changing depending on config model
     char * spDisabledEnv = getenv("SQ_SEAPILOT_SUSPENDED");
     char   spIpBuf[MAX_SP_BUFFER];
 //    uid_t  spUserId;

     if (spDisabledEnv)
     {
        spDisabled = atoi(spDisabledEnv);
        if (spDisabled)
        {
           // to avoid coming in here every time
           activeConfig = true;
           return SP_SUCCESS;
        }
     }

     if (iPAddress[0] == 0)
     {
         char * iPAddressEnv = getenv("QPID_IP_ADDRESS");
         if(iPAddressEnv)
             strcpy (iPAddress,iPAddressEnv);
         else
             strcpy (iPAddress,"127.0.0.1");
     }

     if (portNumber == -1)
     {
         char * portNumberEnv = getenv("QPID_NODE_PORT");
         if(portNumberEnv)
            portNumber = atoi(portNumberEnv);
         else
            return SP_CONFIG_NOT_AVAILABLE;
     }


    // get ip address
    if (sp_addrs (spIpBuf))
       sIpaddress = spIpBuf;
    else
       sIpaddress = "0.0.0.0"; //return SP_CONFIG_NOT_AVAILABLE;
#ifndef WIN32
    host_id = (unsigned int) gethostid(); // Get unique identifier for the host
#else
	host_id = 0;
#endif

    // apparently this function is always successful....
  //  spUserId = getuid();
  //  instanceId = spUserId;
   
    //Compatibility joins in Repos ineffective if instanceId=userid; setting to 0 until this gets resolved
     instanceId = 0;

    activeConfig = true;
    return SP_SUCCESS;
}
Exemplo n.º 23
0
/*--------------------------------------------------------------------------------------
    Name: OS_NetworkGetID
    
    Purpose: Gets the ID of the current Network 

    Returns: OS_ERROR if the  host id could not be found
             a 32 bit host id if success
---------------------------------------------------------------------------------------*/
int32 OS_NetworkGetID             (void)
{
   long    host_id = 0;

   host_id = gethostid();

   return (host_id);
    
}/* end OS_NetworkGetID */
Exemplo n.º 24
0
/*
Hostid via gethostid(3)
@function hostid
@return hostid (STRING)
*/
static int
Fhostid(lua_State *L)
{
	char hostid[9] = {0};
	errno = 0;
	if (0 > snprintf(hostid, sizeof(hostid), "%08lx", gethostid())) return luaX_pusherror(L, "snprintf(3) error.");
	lua_pushstring(L, hostid);
	return 1;
}
Exemplo n.º 25
0
static int lua_ipaddr(lua_State *L){
	int argc = lua_gettop(L);
	if (argc != 0) return luaL_error(L, "wrong number of arguments");
	u32 ip=(u32)gethostid();
	char ip_address[64];
	sprintf(ip_address,"%lu.%lu.%lu.%lu", ip & 0xFF, (ip>>8)&0xFF, (ip>>16)&0xFF, (ip>>24)&0xFF);
	lua_pushstring(L,ip_address);
	return 1;
}
Exemplo n.º 26
0
/*------------------------------------------------------------------
 *  gethostid()
 *------------------------------------------------------------------*/
RexxRoutine0(RexxStringObject, SockGetHostId)
{
    in_addr ia;
#ifdef WIN32
    char     pszBuff[64];                    // buffer for ip address
    PHOSTENT pHostEnt;                       // ptr to hostent structure
    /*
     *   Retrieve my ip address.  Assuming the hosts file in
     *   in %systemroot%/system/drivers/etc/hosts contains my computer name.
     */                                      //get our name
    if (gethostname(pszBuff, sizeof(pszBuff)))
    {
        // set the errno information
        cleanup(context);
        return context->String("0.0.0.0");
    }
    pHostEnt = gethostbyname(pszBuff);       // get our ip address
    if (!pHostEnt)
    {
        // set the errno information
        cleanup(context);
        return context->String("0.0.0.0");
    }
    ia.s_addr = (*(uint32_t *)pHostEnt->h_addr);// in network byte order already
    return context->String(inet_ntoa(ia));
#else
#if defined(OPSYS_AIX) || defined(OPSYS_LINUX)
#define h_addr h_addr_list[0]

    char     pszBuff[64];                    /* buffer for ip address*/
    struct hostent * pHostEnt;               /* ptr to hostent structure*/

    /*get our name*/
    if (gethostname(pszBuff, sizeof(pszBuff)))
    {
        // set the errno information
        cleanup(context);
        return context->String("0.0.0.0");
    }
    pHostEnt = gethostbyname(pszBuff);     /* get our ip address */
    // set the errno information
    cleanup(context);
    if (!pHostEnt)
    {
        return context->String("0.0.0.0");
    }
    ia.s_addr = (*(uint32_t *)pHostEnt->h_addr);// in network byte order already
    return context->String(inet_ntoa(ia));
#else
    ia.s_addr = htonl(gethostid());
    // set the errno information
    cleanup(context);
    return context->String(inet_ntoa(ia));
#endif
#endif
}
Exemplo n.º 27
0
/* platform specific initialization */
void vt_pform_init() {
  int  pid = getpid();
  char exec_proc[VT_PATH_MAX];
  char exec[VT_PATH_MAX];
  int  exec_len;
  int  hostid_retries;

#if TIMER == TIMER_MMTIMER
  int fd;
  unsigned long femtosecs_per_tick = 0;
  int offset;

  if((fd = open(MMTIMER_FULLNAME, O_RDONLY)) == -1) {
    vt_error_msg("Failed to open " MMTIMER_FULLNAME);
  }

  if ((offset = ioctl(fd, MMTIMER_GETOFFSET, 0)) == -ENOSYS) {
    vt_error_msg("Cannot get mmtimer offset");
  }

  if ((mmdev_timer_addr = mmap(0, getpagesize(), PROT_READ, MAP_SHARED, fd, 0))
       == MAP_FAILED) {
    vt_error_msg("Cannot mmap mmtimer");
  }
  mmdev_timer_addr += offset;

  ioctl(fd, MMTIMER_GETRES, &femtosecs_per_tick);
  mmdev_ticks_per_sec = (uint64_t)(1.0 / (1e-15 * femtosecs_per_tick));

  close(fd);
#elif TIMER == TIMER_CLOCK_GETTIME
  struct timespec tp;
  clock_gettime(CLOCK_REALTIME, &tp);
  vt_time_base = tp.tv_sec - (tp.tv_sec & 0xFF);
#elif TIMER == TIMER_PAPI_REAL_USEC
  vt_time_base = vt_metric_real_usec();
#endif

  /* get full path of executable */
  snprintf(exec_proc, sizeof (exec_proc), VT_PROCDIR"%d/exe", pid);
  exec_len = readlink(exec_proc, exec, sizeof (exec)-1);
  if(exec_len != -1)
  {
    exec[exec_len] = '\0';
    vt_exec = strdup(exec);
  }

  /* get unique numeric SMP-node identifier */
  hostid_retries = 0;
  while( !vt_node_id && (hostid_retries++ < VT_MAX_GETHOSTID_RETRIES) ) {
    vt_node_id = gethostid();
  }
  if (!vt_node_id)
    vt_error_msg("Maximum retries (%i) for gethostid exceeded!",
		 VT_MAX_GETHOSTID_RETRIES);
}
Exemplo n.º 28
0
int hostid_main(int argc, char ATTRIBUTE_UNUSED **argv)
{
	if (argc > 1) {
		bb_show_usage();
	}

	printf("%lx\n", gethostid());

	return fflush(stdout);
}
Exemplo n.º 29
0
/**
 * @brief
 * 		returning host id.
 *
 * @return      Host ID
 */
unsigned long
pbs_get_hostid(void)
{
	unsigned long hid;

	hid = (unsigned long)gethostid();
	if (hid == 0)
		hid = (unsigned long)pbs_server_addr;
	return hid;
}
Exemplo n.º 30
0
int hostid_main(int argc, char ATTRIBUTE_UNUSED **argv)
{
	if (argc > 1) {
		bb_show_usage();
	}

	printf("%lx\n", gethostid());

	fflush_stdout_and_exit(EXIT_SUCCESS);
}