Remove building with NOCRYPTO option
[minix.git] / minix / commands / ramdisk / ramdisk.c
blob0a34ee59ee1decfcef57675ecbd893d83c9b42aa
2 #include <minix/paths.h>
4 #include <sys/ioctl.h>
5 #include <stdio.h>
6 #include <fcntl.h>
7 #include <stdlib.h>
9 int
10 main(int argc, char *argv[])
12 int fd;
13 signed long size;
14 char *d;
16 if(argc < 2 || argc > 3) {
17 fprintf(stderr, "usage: %s <size in kB> [device]\n",
18 argv[0]);
19 return 1;
22 d = argc == 2 ? _PATH_RAMDISK : argv[2];
23 if((fd=open(d, O_RDONLY)) < 0) {
24 perror(d);
25 return 1;
28 #define KFACTOR 1024
29 size = atol(argv[1])*KFACTOR;
31 if(size < 0) {
32 fprintf(stderr, "size should be non-negative.\n");
33 return 1;
36 if(ioctl(fd, MIOCRAMSIZE, &size) < 0) {
37 perror("MIOCRAMSIZE");
38 return 1;
41 fprintf(stdout, "size on %s set to %ldkB\n", d, size/KFACTOR);
43 return 0;