hostid.c 579 B

1234567891011121314151617181920212223242526
  1. /* hostid.c - Print the numeric identifier for the current host.
  2. *
  3. * Copyright 2015 Ranjan Kumar <ranjankumar.bth@gmail.com>
  4. *
  5. * No Standard.
  6. *
  7. * This is still in coreutils and gethostid() in posix, but a "globally unique
  8. * 32 bit identifier" is a concept the Linux world has outgrown.
  9. USE_HOSTID(NEWTOY(hostid, ">0", TOYFLAG_USR|TOYFLAG_BIN))
  10. config HOSTID
  11. bool "hostid"
  12. default n
  13. help
  14. usage: hostid
  15. Print the numeric identifier for the current host.
  16. */
  17. #define FOR_hostid
  18. #include "toys.h"
  19. void hostid_main(void)
  20. {
  21. xprintf("%08lx\n", gethostid());
  22. }