-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvfs_load.c
36 lines (27 loc) · 823 Bytes
/
vfs_load.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "vfs.h"
//extern struct Vfs vfs;
int open_vfs(){
//FILE *fp;
//char a[MAXLEN];
//struct Vfs vfs;
printf("Loading VFS %s....\n",vfs.header.vfs_info.vfs_name);
//Open the VFS file
if( (vfs.vfs_fp=fopen("VFS.txt","rb+"))==NULL){
printf("Unable to load the filesystem\n");
exit(1);
}
//Load header info into struct
rewind(vfs.vfs_fp);
fread(&vfs,sizeof(struct Vfs),1,vfs.vfs_fp);
//sort the vfs_files
qsort(vfs.header.vfs_files,vfs.header.vfs_info.num_files, sizeof(struct Vfs_File_Info), cmp_vfsfile);
//Initialize struct vfs
vfs.vfs_status=VFS_OPEN;
printf("VFS Name:%s\n",vfs.header.vfs_info.vfs_name);
printf("VFS Status:%d VFS_OPEN\n",vfs.vfs_status);
printf("No of Files:%d\n",vfs.header.vfs_info.num_files);
return 0;
}