source: trunk/minix/commands/simple/ramdisk.c@ 9

Last change on this file since 9 was 9, checked in by Mattia Monga, 13 years ago

Minix 3.1.2a

File size: 558 bytes
Line 
1
2#include <minix/paths.h>
3
4#include <sys/ioc_memory.h>
5#include <stdio.h>
6#include <fcntl.h>
7#include <stdlib.h>
8
9int
10main(int argc, char *argv[])
11{
12 int fd;
13 signed long size;
14 if((fd=open(_PATH_RAMDISK, O_RDONLY)) < 0) {
15 perror(_PATH_RAMDISK);
16 return 1;
17 }
18
19 if(argc != 2) {
20 fprintf(stderr, "usage: %s <size in bytes>\n", argv[0]);
21 return 1;
22 }
23
24 size = atol(argv[1]);
25
26 if(size <= 0) {
27 fprintf(stderr, "size should be positive.\n");
28 return 1;
29 }
30
31 if(ioctl(fd, MIOCRAMSIZE, &size) < 0) {
32 perror("MIOCRAMSIZE");
33 return 1;
34 }
35
36 return 0;
37}
38
Note: See TracBrowser for help on using the repository browser.