NFSACL: Add support for SETACL3
[deb_libnfs.git] / nfs / nfsacl.c
index 01e26c302d1a0f2d386c02fd28eced2dc63b26ea..4561589d1ca9e9f1a8fb616be8f8b131d3c8f35e 100644 (file)
    You should have received a copy of the GNU Lesser General Public License
    along with this program; if not, see <http://www.gnu.org/licenses/>.
 */
-
-#if defined(WIN32)
-#include <winsock2.h>
-#endif
+#ifdef WIN32
+#include "win32_compat.h"
+#else
+#include <sys/stat.h>
+#endif/*WIN32*/
 
 #include <stdio.h>
 #include <errno.h>
-#include <sys/stat.h>
 #include <string.h>
 #include <rpc/rpc.h>
 #include <rpc/xdr.h>
@@ -80,3 +80,28 @@ int rpc_nfsacl_getacl_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *
 
        return 0;
 }
+
+int rpc_nfsacl_setacl_async(struct rpc_context *rpc, rpc_cb cb, struct SETACL3args *args, void *private_data)
+{
+       struct rpc_pdu *pdu;
+
+       pdu = rpc_allocate_pdu(rpc, NFSACL_PROGRAM, NFSACL_V3, NFSACL3_SETACL, cb, private_data, (xdrproc_t)xdr_SETACL3res, sizeof(SETACL3res));
+       if (pdu == NULL) {
+               rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for nfsacl/setacl call");
+               return -1;
+       }
+
+       if (xdr_SETACL3args(&pdu->xdr, args) == 0) {
+               rpc_set_error(rpc, "XDR error: Failed to encode SETACL3args");
+               rpc_free_pdu(rpc, pdu);
+               return -2;
+       }
+
+       if (rpc_queue_pdu(rpc, pdu) != 0) {
+               rpc_set_error(rpc, "Out of memory. Failed to queue pdu for nfsacl/setacl call");
+               rpc_free_pdu(rpc, pdu);
+               return -2;
+       }
+
+       return 0;
+}