Project

General

Profile

Bug #6770 ยป gidschng.c

Marcel Telka, 2016-03-20 01:35 PM

 
1
#include <rpc/rpc.h>
2
#include <nfs/nfs4.h>
3
#include <strings.h>
4

    
5
int nfs4_skip_bytes;
6

    
7
int
8
main(void)
9
{
10
	AUTH *auth0;
11
	AUTH *auth1;
12
	gid_t gid = 0;
13
	rpcvers_t vers;
14
	CLIENT *clnt;
15
	enum clnt_stat stat;
16

    
17
	COMPOUND4args args;
18
	COMPOUND4res res;
19
	nfs_argop4 arg[1];
20

    
21
	struct timeval t = {10, 0};
22

    
23
	auth0 = authsys_create("localhost", 0, 0, 0, NULL);
24
	if (auth0 == NULL) {
25
		printf("authsys_create for auth0 failed\n");
26
		return -1;
27
	}
28

    
29
	auth1 = authsys_create("localhost", 0, 0, 1, &gid);
30
	if (auth1 == NULL) {
31
		printf("authsys_create for auth1 failed\n");
32
		return -1;
33
	}
34

    
35
	clnt = clnt_create_vers("localhost", NFS4_PROGRAM, &vers, NFS_V4,
36
	    NFS_V4, "tcp");
37
	if (clnt == NULL) {
38
		printf("clnt_create_vers failed\n");
39
		return -1;
40
	}
41

    
42
	args.minorversion = 0;
43
	args.tag.utf8string_len = 0;
44
	args.tag.utf8string_val = NULL;
45
	args.argarray.argarray_len = 1;
46
	args.argarray.argarray_val = arg;
47

    
48
	arg[0].argop = OP_PUTROOTFH;
49

    
50

    
51
	for (;;) {
52
		bzero(&res, sizeof res);
53
		clnt->cl_auth = auth0;
54
		stat = clnt_call(clnt, NFSPROC4_COMPOUND, xdr_COMPOUND4args,
55
		    (caddr_t)&args, xdr_COMPOUND4res, (caddr_t)&res, t);
56
		if (stat != RPC_SUCCESS) {
57
			printf("clnt_call failed\n");
58
			return -1;
59
		}
60
		xdr_free(xdr_COMPOUND4res, (char *)&res);
61

    
62
		bzero(&res, sizeof res);
63
		clnt->cl_auth = auth1;
64
		stat = clnt_call(clnt, NFSPROC4_COMPOUND, xdr_COMPOUND4args,
65
		    (caddr_t)&args, xdr_COMPOUND4res, (caddr_t)&res, t);
66
		if (stat != RPC_SUCCESS) {
67
			printf("clnt_call failed\n");
68
			return -1;
69
		}
70
		xdr_free(xdr_COMPOUND4res, (char *)&res);
71
	}
72

    
73
	return 0;
74
}
    (1-1/1)