Last active
March 30, 2020 17:10
-
-
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)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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