/* sysinfo.c * Neal Nelson * * Display: * CPU type and model, * kernel version, * amount of time since system was last booted in the form dd:hh:mm:ss */ #include #include #define MAXLINE 80 main(int argc, char *argv[]) { char buf[MAXLINE+1]; /* room for the string terminator zero */ FILE *fp; if (argc != 1) { printf("usage: sysinfo\n"); exit(1); } /* 1. print the cpu type and model */ /* 2. print the system ostype and osrelease */ /* print the system ostype */ if ( (fp = fopen("/proc/sys/kernel/ostype","r")) == NULL) { printf( "Unable to open /proc/sys/kernel/ostype\n" ); exit(1); } fgets(buf,MAXLINE+1,fp); printf("%s",buf); /* print the osrelease */ if ( (fp = fopen("/proc/sys/kernel/osrelease","r")) == NULL) { printf( "Unable to open /proc/sys/kernel/osrelease\n" ); exit(1); } fgets(buf,MAXLINE+1,fp); printf("%s\n",buf); /* 3. print the amout of time since the last system boot */ }