-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclient.c
More file actions
46 lines (33 loc) · 956 Bytes
/
client.c
File metadata and controls
46 lines (33 loc) · 956 Bytes
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
#include <stdio.h>
#include "udp.h"
#include "mfs.h"
// client code
int main(int argc, char *argv[])
{
char *hostname = "localhost";
int port = client_port;
int fd = MFS_Init(hostname, port);
if (fd == -1)
{
return 0;
}
char buffer[SIZE_BLOCK];
int inum = MFS_Lookup(0, "foo");
MFS_Read(inum, buffer, 0);
printf("foo before rewrite: %s\n", buffer);
MFS_Write(inum, "Jecris une nouvelle version de foo", 0);
inum = MFS_Lookup(0, "foo");
MFS_Read(inum, buffer, 0);
printf("foo after rewrite : %s\n", buffer);
MFS_Creat(0, MFS_DIRECTORY, "myDir");
inum = MFS_Lookup(0, "myDir");
MFS_Stat_t m;
MFS_Stat(inum, &m);
int pinum = MFS_Lookup(inum, "..");
printf("myDyr inum : %d, pinum : %d\n", inum, pinum);
MFS_Unlink(pinum, "myDir");
inum = MFS_Lookup(0, "myDir");
printf("after Unlink myDyr inum : %d\n", inum);
MFS_Shutdown();
return 0;
}