 		fid = createNewFile(name);
 	}
 	return fid;
+}
+__device__ void sortD() {
+	for (int i = 0; i < fileCt; i++) {
+		volume[LS_D_OFFSET+i*2] 	= (i & 0x0000FF00) >> 8;
+		volume[LS_D_OFFSET+i*2+1] 	= i & 0x000000FF;
+	}
+}
+__device__ void printD() {
+	for (int i = 0; i < fileCt; i++) {
+		int fid = ((int)(volume[LS_D_OFFSET+i*2]) << 8) | ((int)(volume[LS_D_OFFSET+i*2+1]));
+		printf("%s\n", volume[META_OFFSET+fid*META_SIZE]);
+	}
+}
+__device__ void sortS() {
+	for (int i = 0; i < fileCt; i++) {
+		volume[LS_S_OFFSET+i*2] 	= i & 0xFFFF0000;
+		volume[LS_S_OFFSET+i*2+1] 	= i & 0x0000FFFF;
+	}
+}
+__device__ void printS() {
+	for (int i = 0; i < fileCt; i++) {
+		int fid = ((int)(volume[LS_S_OFFSET+i*2]) << 8) | ((int)(volume[LS_S_OFFSET+i*2+1]));
+		printf("%s\n", volume[META_OFFSET+fid*META_SIZE]);
+	}
+}
+__device__ void deleteFileByName(const char *name) {
+	int target = DNE;
+	for (int i = 0; i < fileCt; i++) {
+		if(isNameMatched(i, name)) {
+			target = i;
+			break;
+		}
+	}
+	fileCt--;
+	if (target != fileCt) {
+		for (int i = 0; i < META_SIZE; i++) {
+			volume[META_OFFSET+target*META_SIZE+i] = volume[META_OFFSET+fileCt*META_SIZE+i];
+		}
+		for (int i = 0; i < volume[META_OFFSET+fileCt*META_OFFSET+SIZE_OFFSET]; i++) {
+			volume[DATA_OFFSET+target*DATA_SIZE+i] = volume[DATA_OFFSET+fileCt*DATA_SIZE+i];
+		}
+	}
 }
 // ******************************************************************
 

const int RM_RF     = 6;

// Declare variables
__device__ __managed__ uchar *volume;

// Function
// ******************************************************************

#define DATAFILE            "./data.bin"
#define OUTPUTFILE          "./snapshot.bin"
#define FILE_ENTRIES		1024
#define META_SIZE			31
#define DATA_SIZE			1024
#define LS_S_OFFSET			1024
#define LS_D_OFFSET			3072
#define META_OFFSET			5120
#define SIZE_OFFSET			21
#define CREATET_OFFSET		SIZE_OFFSET+2
#define MODIFYT_OFFSET		CREATET_OFFSET+4
#define DATA_OFFSET			36864
#define DNE					0xffffffff
typedef unsigned char uchar;
typedef uint32_t u32;
