From: Ben Gras Date: Mon, 13 Mar 2006 14:41:54 +0000 (+0000) Subject: Create a ramdisk using 'ramdisk'. X-Git-Tag: v3.1.2a~249 X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/man.host.html?a=commitdiff_plain;h=34b1f1c738689dfcaf8b927ddc6a9391d5123e07;p=minix.git Create a ramdisk using 'ramdisk'. --- diff --git a/commands/simple/Makefile b/commands/simple/Makefile index 1239f1de2..a1649d6dd 100755 --- a/commands/simple/Makefile +++ b/commands/simple/Makefile @@ -147,6 +147,7 @@ ALL = \ proto \ pwd \ pwdauth \ + ramdisk \ rarpd \ rcp \ rawspeed \ @@ -643,6 +644,10 @@ pwdauth: pwdauth.c $(CCLD) -o $@ $? @install -S 4kw $@ +ramdisk: ramdisk.c + $(CCLD) -o $@ ramdisk.c + @install -S 4kw $@ + rarpd: rarpd.c $(CCLD) -o $@ rarpd.c @install -S 4kw $@ @@ -1029,6 +1034,7 @@ install: \ /usr/bin/proto \ /usr/bin/pwd \ /usr/lib/pwdauth \ + /usr/bin/ramdisk \ /usr/bin/rarpd \ /usr/bin/rcp \ /usr/bin/rawspeed \ @@ -1472,6 +1478,9 @@ install: \ /usr/lib/pwdauth: pwdauth install -cs -o root -m 4755 $? $@ +/usr/bin/ramdisk: ramdisk + install -cs -o bin $? $@ + /usr/bin/rarpd: rarpd install -cs -o bin $? $@ diff --git a/commands/simple/ramdisk.c b/commands/simple/ramdisk.c new file mode 100644 index 000000000..3210f3201 --- /dev/null +++ b/commands/simple/ramdisk.c @@ -0,0 +1,38 @@ + +#include + +#include +#include +#include +#include + +int +main(int argc, char *argv[]) +{ + int fd; + signed long size; + if((fd=open(_PATH_RAMDISK, O_RDONLY)) < 0) { + perror(_PATH_RAMDISK); + return 1; + } + + if(argc != 2) { + fprintf(stderr, "usage: %s \n", argv[0]); + return 1; + } + + size = atol(argv[1]); + + if(size <= 0) { + fprintf(stderr, "size should be positive.\n"); + return 1; + } + + if(ioctl(fd, MIOCRAMSIZE, &size) < 0) { + perror("MIOCRAMSIZE"); + return 1; + } + + return 0; +} +