#include <sys/times.h> main(int argc, char **argv) { struct tms tm; if (fork()) { wait (0); times (&tm); printf("User CPU time = %d.%d secs\n", tm.tms_cutime/10O, tm.tms_cutime%100); printf("System CPU time = %d.%d secs\n", tm.tms_cstime/100, tm.tms_cstime%iOO); } else { execvp (argv [1], &argv [1]); exit(1) } }
/* mountfd0 command - must be setuid root to work */ main() { setuid(0); if (mount("/dev/fd0", /floppy", "ext2", 0, 0)) puts("moumtfdo failed! ! !\n"); } /* umountfd0 command - must be setuid root to work */ main() { setuid(0) if (umount ("/dev/fd0")) puts ("umountfd0 failed!! !\n"); }
The call to setuid(0) is needed to set the real uid of the process to 0, as the mount system call tests the real uid rather than the effective uid when it looks to make sure it is being run by root.