 
 int main() {
     cudaMallocManaged(&volume, STORAGE_SIZE);
+	printf("B init\n");
     init_volume();
 
     uchar *input, *output;

// ******************************************************************
// Initialize
void init_volume() {
    memset(volume, 0, STORAGE_SIZE*sizeof(uchar));
}

// ******************************************************************

// ******************************************************************
// File I/O
int loadBinaryFile(char *fileName, uchar *input, int fileSize) {
    FILE *fptr = fopen(fileName, "rb");
    // Get size
    fseek(fptr, 0, SEEK_END);

// ******************************************************************

// ******************************************************************
// FS Helper function
__device__ u32 getFid(const char *name) {
	u32 fid = DNE;
	for (u32 i = 0; i < FILE_ENTRIES; i++) {
		if (isNameMatched(i, name)) {
			fid = i;
			break;
		}
	}
	if (fid == DNE) {
		fid = createNewFile(name);
	}
	return fid;
}
// ******************************************************************

// ******************************************************************
// FS Operation
__device__ u32 open(const char *name, int type) {
    printf("Open %s %d\n", name, type);
	u32 fid = getFid(name);
    return fid;
}

__device__ void write(uchar *src, int len, u32 fid) {
	updateFileSize(fid, len);
	updateFileModifyTime(fid);
	u32 entry = getFileDataAddress(fid);
	for (u32 i = 0; i < len; i++) {
		updateData(entry+i,src[i]);
	}
    printf("Write %s %d %d\n", src, len, fid);
}

__device__ void read(uchar *dst, int len, u32 fid) {
	u32 entry = getFileDataAddress(fid);
	for (u32 i = 0; i < len; i++) {
		dst[i] = getData(entry+i);
	}
    printf("Read %s %d %d\n", dst, len, fid);
}

__device__ void gsys(int type) {
	switch (type) {
		case LS_D:
			sortD();
			printD();
			break;
		case LS_S:
			sortS();
			printS();
			break;
		default:
			sortS();
			printS();
			break;
	}
    printf("Gsys %d\n", type);
}

__device__ void gsys(int type, const char *name) {
	switch (type) {
		case RM:
			deleteFileByName(name);
			break;
		default:
			deleteFileByName(name);
			break;
	}
    printf("Gsys %d %s\n", type, name);
}

