1 /* uname.c - return system name 2 * 3 * Copyright 2008 Rob Landley <[email protected]> 4 * 5 * See http://opengroup.org/onlinepubs/9699919799/utilities/uname.html 6 7 USE_UNAME(NEWTOY(uname, "paomvrns", TOYFLAG_BIN)) 8 USE_ARCH(NEWTOY(arch, 0, TOYFLAG_USR|TOYFLAG_BIN)) 9 10 config ARCH 11 bool "arch" 12 default y 13 help 14 usage: arch 15 16 Print machine (hardware) name, same as uname -m. 17 18 config UNAME 19 bool "uname" 20 default y 21 help 22 usage: uname [-asnrvmo] 23 24 Print system information. 25 26 -s System name 27 -n Network (domain) name 28 -r Kernel Release number 29 -v Kernel Version 30 -m Machine (hardware) name 31 -a All of the above (in order) 32 33 -o Userspace type 34 */ 35 36 #define FOR_uname 37 #define FORCE_FLAGS 38 #include "toys.h" 39 uname_main(void)40void uname_main(void) 41 { 42 int i, needspace = 0; 43 char *c; 44 45 uname((void *)toybuf); 46 if (!toys.optflags) toys.optflags = FLAG_s; 47 for (i=0; i<6; i++) if (toys.optflags & ((1<<i)|FLAG_a)) { 48 if (i==5) c = " Toybox"+!needspace; 49 else { 50 c = toybuf+sizeof(((struct utsname *)0)->sysname)*i; 51 if (needspace++) *(--c)=' '; // Can't decrement first entry 52 } 53 xputsn(c); 54 } 55 if (FLAG(p)) xputsn(" unknown"+!needspace); 56 xputc('\n'); 57 } 58 arch_main(void)59void arch_main(void) 60 { 61 toys.optflags = FLAG_m; 62 uname_main(); 63 } 64