next up previous contents
Next: Programming the User Interface Up: SYSTEMS PROGRAMMING LABORATORY X Previous: SYSTEMS PROGRAMMING LABORATORY X   Contents

Examples&Exercises:

  1. CPU's clock speed; http://siber.cankaya.edu.tr/SystemsProgramming/cfiles/clock-speed.cclock-speed.c
  2. /proc/self; http://siber.cankaya.edu.tr/SystemsProgramming/cfiles/get-pid.cget-pid.c
  3. Process Argument List; http://siber.cankaya.edu.tr/SystemsProgramming/cfiles/print-arg-list.cprint-arg-list.c
  4. Write a program that
  5. Process Environment; http://siber.cankaya.edu.tr/SystemsProgramming/cfiles/print-environment.cprint-environment.c
  6. Process Executable http://siber.cankaya.edu.tr/SystemsProgramming/cfiles/get-exe-path.cget-exe-path.c
  7. File descriptors; http://siber.cankaya.edu.tr/SystemsProgramming/cfiles/open-and-spin.copen-and-spin.c
  8. System Statistics; http://siber.cankaya.edu.tr/SystemsProgramming/cfiles/print-uptime.cprint-uptime.c
  9. Study the following commands;
    $ ls -l /proc/version
    $ cat /proc/version
    $ man 5 proc
    $ cat /proc/cpuinfo
    $ strings -f /proc/[0-9]*/cmdline
    $ cat /proc/version
    $ cat /proc/sys/kernel/ostype
    $ cat /proc/sys/kernel/osrelease
    $ cat /proc/sys/kernel/version
    $ cat /proc/meminfo
    $ cat /proc/ide/ide?/hd?/media
    $ cat /proc/ide/ide?/hd?/model
    $ cat /proc/scsi/scsi
    $ cat /proc/sys/dev/cdrom/info
    $ cat /proc/uptime
    $ cat /proc/devices
    $ cat /proc/pci
    $ cat /proc/dma
    $ cat /proc/interrupts
    $ cat /proc/ioports
    $ cat /proc/net
    $ cat /proc/kmsg
    $ cat /proc/ksyms
    $ cat /proc/modules
    $ cat /proc/filesystems
    $ cat /proc/partitions
    $ cat /proc/mounts
    $ cat /proc/loadavg
    $ cat /proc/uptime
    
    Which ones of these commands are for the process information, the hardware information and for the system statistics? These are not the all and try to see as much as possible entries in /proc file system.
  10. TO BE GRADED; write a program that produces information by using the /proc filesystem for the followings:
  1. Study the following commands;
    $ id
    $ man getuid
    $ man getgid
    $ man 2 stat (see the flags are defined for the st_mode field)
    $ ls -ld /tmp
    $ ls -la /tmp
    $ man whoami
    $ man su
    $ ls -l /bin/su
    
  2. Setuid Programs; http://siber.cankaya.edu.tr/SystemsProgramming/cfiles/setuid-test.c setuid-test.c
  3. Buffer Overruns;http://siber.cankaya.edu.tr/SystemsProgramming/cfiles/bufferoverflow.c bufferoverflow.c
  4. Race Conditions in /tmp; http://siber.cankaya.edu.tr/SystemsProgramming/cfiles/temp-file.c temp-file.c
  5. Some Safer I/O Functions; http://siber.cankaya.edu.tr/SystemsProgramming/cfiles/symlink1.c symlink1.c Program illustrates a safer replacement for the chroot() and open() system calls and the fopen() standard library function. This illustrates the usual workaround, and wrappers for other system calls can be patterned after these functions.

next up previous contents
Next: Programming the User Interface Up: SYSTEMS PROGRAMMING LABORATORY X Previous: SYSTEMS PROGRAMMING LABORATORY X   Contents
Cem Ozdogan 2007-05-16