home *** CD-ROM | disk | FTP | other *** search
/ Boot Disc 15 / boot-disc-1997-11.iso / Debian / Tools / LODLIN16.ZIP / LODLIN16 / INITRD / FREERAMD.C next >
C/C++ Source or Header  |  1996-02-17  |  688b  |  34 lines

  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <sys/mount.h>
  4. #include <sys/types.h>
  5. #include <sys/stat.h>
  6. #include <fcntl.h>
  7. #include <sys/ioctl.h>
  8. #include <linux/fs.h>
  9. #include <errno.h>
  10.  
  11. main(int argc, char **argv)
  12. {
  13.   char rname[256]="/dev/ram";
  14.   char b[256];
  15.   int f;
  16.   if (argv[1]) strcpy(rname,argv[1]);
  17.  
  18. #if 0  /* don't use on a living system, /etc/mtab is not updated */ 
  19.   if (umount(rname) && (errno != ENOENT)) {
  20.     sprintf(b,"freeramdisk: cannot umount %s %d",rname,errno);
  21.     perror(b);
  22.     exit(1);
  23.   }
  24. #endif
  25.  
  26.   if ((f=open(rname,O_RDWR)) == -1) {
  27.     sprintf(b,"freeramdisk: cannot open %s",rname);
  28.     perror(b);
  29.     exit(1);
  30.   }
  31.   ioctl(f,BLKFLSBUF);
  32.   close(f);
  33. }
  34.