-
Notifications
You must be signed in to change notification settings - Fork 0
/
comm_create.c
53 lines (44 loc) · 1.07 KB
/
comm_create.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <ctype.h>
#include <unistd.h>
#include <getopt.h>
#include <sys/time.h>
#include <math.h>
//#include "dbench.h"
#include "nfs.h"
#include "mount.h"
#include "libnfs.h"
#include "comm.h"
int main(int argc, char **argv) {
char *hostname, *directory, *filename;
nfsstat3 nfs_status;
struct nfsio * nfsio;
/* hostname directory pathname */
if (argc < 4) {
printf("Not enough arguments to %s\n", argv[0]);
printf("Usage: %s hostname exportdir filename\n", argv[0]);
exit(1);
}
hostname = argv[1];
directory = argv[2];
filename = argv[3];
/* Connect */
nfsio = nfs_connect(hostname, directory);
if (nfsio == NULL) {
printf("FAIL: Could not connect to server\n");
return -1;
}
nfs_status = nfsio_create(nfsio, filename);
if (nfs_status != NFS3_OK) {
printf ("FAIL: Could not create file: %d\n", nfs_status);
print_nfs_status(nfs_status);
return -1;
}
/* Disconnect */
if (nfsio != NULL)
nfsio_disconnect(nfsio);
return 0;
}