We have to include config.h when testing for precense of sockaddr sa_len
[deb_libnfs.git] / nfs / nfsacl.c
... / ...
CommitLineData
1/*
2 Copyright (C) 2010 by Ronnie Sahlberg <ronniesahlberg@gmail.com>
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as published by
6 the Free Software Foundation; either version 2.1 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program; if not, see <http://www.gnu.org/licenses/>.
16*/
17
18#include <stdio.h>
19#include <errno.h>
20#include <sys/stat.h>
21#include <string.h>
22#include <rpc/rpc.h>
23#include <rpc/xdr.h>
24#include "libnfs.h"
25#include "libnfs-raw.h"
26#include "libnfs-private.h"
27#include "libnfs-raw-nfs.h"
28
29
30int rpc_nfsacl_null_async(struct rpc_context *rpc, rpc_cb cb, void *private_data)
31{
32 struct rpc_pdu *pdu;
33
34 pdu = rpc_allocate_pdu(rpc, NFSACL_PROGRAM, NFSACL_V3, NFSACL3_NULL, cb, private_data, (xdrproc_t)xdr_void, 0);
35 if (pdu == NULL) {
36 rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for nfsacl/null call");
37 return -1;
38 }
39
40 if (rpc_queue_pdu(rpc, pdu) != 0) {
41 rpc_set_error(rpc, "Out of memory. Failed to queue pdu for nfsacl/null call");
42 rpc_free_pdu(rpc, pdu);
43 return -2;
44 }
45
46 return 0;
47}
48
49
50int rpc_nfsacl_getacl_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh, uint32_t mask, void *private_data)
51{
52 struct rpc_pdu *pdu;
53 GETACL3args args;
54
55 pdu = rpc_allocate_pdu(rpc, NFSACL_PROGRAM, NFSACL_V3, NFSACL3_GETACL, cb, private_data, (xdrproc_t)xdr_GETACL3res, sizeof(GETACL3res));
56 if (pdu == NULL) {
57 rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for nfsacl/getacl call");
58 return -1;
59 }
60
61 args.dir.data.data_len = fh->data.data_len;
62 args.dir.data.data_val = fh->data.data_val;
63 args.mask = mask;
64
65 if (xdr_GETACL3args(&pdu->xdr, &args) == 0) {
66 rpc_set_error(rpc, "XDR error: Failed to encode GETACL3args");
67 rpc_free_pdu(rpc, pdu);
68 return -2;
69 }
70
71 if (rpc_queue_pdu(rpc, pdu) != 0) {
72 rpc_set_error(rpc, "Out of memory. Failed to queue pdu for nfsacl/getacl call");
73 rpc_free_pdu(rpc, pdu);
74 return -2;
75 }
76
77 return 0;
78}