-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtester.c
More file actions
64 lines (51 loc) · 1.09 KB
/
Copy pathtester.c
File metadata and controls
64 lines (51 loc) · 1.09 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#include<stdio.h>
#include<stdlib.h>
#include<fcntl.h>
#include<unistd.h>
#include<sys/types.h>
#include<sys/stat.h>
#include<limits.h>
#include<string.h>
#include "hashtable.h"
// to test if a C/Python program can write into the FS
// unmount from the file system first , and then run tester.c
// mount the file system back to see the changes
int main(int argc, char* argv[])
{
#if 1 //to write into a file from 0 to 512
int fd=ht_open("/root/TestFile3");
char buf[9];
strcpy(buf,"hellowor");
int i=0;
for(i=0;i<64;i++)//write from 0 to 512
{
write(fd,&buf,strlen(buf));
}
ht_close(fd);
#endif
#if 0 //to remove lines 101 and beyond
int fd=ht_open("/root/TestFile3");
lseek(fd,0,101);
char buf[9];
strcpy(buf,"");
int i=0;
for(i=0;i<52;i++)//write from 101 to 512
{
write(fd,&buf,strlen(buf));
}
ht_close(fd);
#endif
#if 0 //to write from 101 to 1024
int fd=ht_open("/root/TestFile3");
lseek(fd,101,SEEK_CUR);
char buf[8];
strcpy(buf,"");
int i=0;
for(i=0;i<116;i++)//write from 101 to 1024
{
write(fd,&buf,strlen(buf));
}
ht_close(fd);
#endif
return 0;
}