2006-03-13 15:41:54 +01:00
|
|
|
|
2010-11-06 21:40:15 +01:00
|
|
|
#include <paths.h>
|
2006-03-13 15:41:54 +01:00
|
|
|
|
|
|
|
#include <sys/ioc_memory.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
int
|
|
|
|
main(int argc, char *argv[])
|
|
|
|
{
|
|
|
|
int fd;
|
|
|
|
signed long size;
|
2009-03-19 14:48:19 +01:00
|
|
|
char *d;
|
|
|
|
|
|
|
|
if(argc < 2 || argc > 3) {
|
|
|
|
fprintf(stderr, "usage: %s <size in kB> [device]\n",
|
|
|
|
argv[0]);
|
2006-03-13 15:41:54 +01:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2009-03-19 14:48:19 +01:00
|
|
|
d = argc == 2 ? _PATH_RAMDISK : argv[2];
|
|
|
|
if((fd=open(d, O_RDONLY)) < 0) {
|
|
|
|
perror(d);
|
2006-03-13 15:41:54 +01:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2009-03-19 14:48:19 +01:00
|
|
|
#define KFACTOR 1024
|
|
|
|
size = atol(argv[1])*KFACTOR;
|
2006-03-13 15:41:54 +01:00
|
|
|
|
2012-09-18 13:17:52 +02:00
|
|
|
if(size < 0) {
|
|
|
|
fprintf(stderr, "size should be non-negative.\n");
|
2006-03-13 15:41:54 +01:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(ioctl(fd, MIOCRAMSIZE, &size) < 0) {
|
|
|
|
perror("MIOCRAMSIZE");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2009-03-19 14:48:19 +01:00
|
|
|
fprintf(stderr, "size on %s set to %dkB\n", d, size/KFACTOR);
|
|
|
|
|
2006-03-13 15:41:54 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|