~ubuntu-branches/ubuntu/lucid/loadlin/lucid

« back to all changes in this revision

Viewing changes to initrd/freeramdisk.c

  • Committer: Bazaar Package Importer
  • Author(s): Martin Mitchell
  • Date: 2001-04-08 21:11:58 UTC
  • Revision ID: james.westby@ubuntu.com-20010408211158-js9q3jnoon2l5qve
Tags: 1.6a-6
Set priority to optional.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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 <errno.h>
 
9
 
 
10
main(int argc, char **argv)
 
11
{
 
12
  char rname[256]="/dev/ram";
 
13
  char b[256];
 
14
  int f;
 
15
  if (argv[1]) strcpy(rname,argv[1]);
 
16
 
 
17
#if 0  /* don't use on a living system, /etc/mtab is not updated */ 
 
18
  if (umount(rname) && (errno != ENOENT)) {
 
19
    sprintf(b,"freeramdisk: cannot umount %s %d",rname,errno);
 
20
    perror(b);
 
21
    exit(1);
 
22
  }
 
23
#endif
 
24
 
 
25
  if ((f=open(rname,O_RDWR)) == -1) {
 
26
    sprintf(b,"freeramdisk: cannot open %s",rname);
 
27
    perror(b);
 
28
    exit(1);
 
29
  }
 
30
  ioctl(f,BLKFLSBUF);
 
31
  close(f);
 
32
}