X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/143464d58d2bd6378e74eec636961ceb0d32fb91..fe8ab488e9161c46dd9885d58fc52996dc0249ff:/tools/tests/perf_index/ramdisk.c diff --git a/tools/tests/perf_index/ramdisk.c b/tools/tests/perf_index/ramdisk.c new file mode 100644 index 000000000..357fbf463 --- /dev/null +++ b/tools/tests/perf_index/ramdisk.c @@ -0,0 +1,38 @@ +#include "ramdisk.h" +#include "fail.h" +#include +#include +#include +#include + +int setup_ram_volume(const char* name, char* path) { + char *cmd; + int retval; + + retval = asprintf(&cmd, "diskutil erasevolume HFS+ '%s' `hdiutil attach -nomount ram://1500000` >/dev/null", name); + VERIFY(retval > 0, "asprintf failed"); + + retval = system(cmd); + VERIFY(retval == 0, "diskutil command failed"); + + snprintf(path, MAXPATHLEN, "/Volumes/%s", name); + + free(cmd); + + return PERFINDEX_SUCCESS; +} + +int cleanup_ram_volume(char* path) { + char *cmd; + int retval; + + retval = asprintf(&cmd, "umount -f '%s' >/dev/null", path); + VERIFY(retval > 0, "asprintf failed"); + + retval = system(cmd); + VERIFY(retval == 0, "diskutil command failed"); + + free(cmd); + + return PERFINDEX_SUCCESS; +}