int main(int argc, char *argv[]) { char *func = argv[1]; char *loc = argv[2]; int result; if(strstr(func, "create") != NULL) { int64_t size = (string_metric_parse(argv[3]) / 1024); result = disk_alloc_create(loc, size); if(result != 0) { printf("Could not create allocation.\n"); return -1; } printf("Allocation complete.\n"); return 0; } else if(strstr(func, "delete") != NULL) { result = disk_alloc_delete(loc); if(result != 0) { printf("Could not delete allocation.\n"); return -1; } printf("Deallocation complete.\n"); return 0; } else { printf("Invalid parameters defined.\n"); return -1; } }
struct work_queue_process *work_queue_process_create(struct work_queue_task *wq_task, int disk_allocation) { struct work_queue_process *p = malloc(sizeof(*p)); memset(p, 0, sizeof(*p)); p->task = wq_task; p->task->disk_allocation_exhausted = 0; //placeholder filesystem until permanent solution char *fs = "ext2"; if(disk_allocation == 1) { work_queue_process_compute_disk_needed(p); if(p->task->resources_requested->disk > 0) { int64_t size = (p->task->resources_requested->disk) * 1024; p->sandbox = string_format("t.%d", p->task->taskid); if(disk_alloc_create(p->sandbox, fs, size) == 0) { p->loop_mount = 1; debug(D_WQ, "disk_alloc: %"PRId64"MB\n", size); return p; } } if(!create_task_directories(p)) { work_queue_process_delete(p); return 0; } p->loop_mount = 0; return p; } else { if(!create_task_directories(p)) { work_queue_process_delete(p); return 0; } p->loop_mount = 0; return p; } }