Skip to content

Instantly share code, notes, and snippets.

@Marc-Bender
Last active March 30, 2020 17:10
Show Gist options
  • Save Marc-Bender/7b86f3c56923f07808f5b17f904df4a4 to your computer and use it in GitHub Desktop.
Save Marc-Bender/7b86f3c56923f07808f5b17f904df4a4 to your computer and use it in GitHub Desktop.
[DEPRECATED] C Programm that creates a RAM-Disk of variable size using shell commands (linux only)
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#define __CMD__ "sudo mount -t tmpfs tmpfs /mnt/ramdisk/ -o size="
int main(const int argc, const char * argv[])
{
if(argc != 2)
{
fprintf(stderr,"\nArgumentezahl falsch\n");
return -1;
}
char * cmdToBeExecuted = (char *) malloc(strlen(__CMD__) + strlen(argv[1]) );
sprintf(cmdToBeExecuted,"%s%s",__CMD__,argv[1]);
system(cmdToBeExecuted);
printf("\n%s Ramdisk erstellt\n", argv[1]);
free(cmdToBeExecuted);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment