acl_copy.c revision 194955
1176730Sjeff/*
2176730Sjeff * Copyright (c) 2001-2002 Chris D. Faulhaber
3176730Sjeff * All rights reserved.
4177904Sjeff *
5177904Sjeff * Redistribution and use in source and binary forms, with or without
6177904Sjeff * modification, are permitted provided that the following conditions
7176730Sjeff * are met:
8176730Sjeff * 1. Redistributions of source code must retain the above copyright
9176730Sjeff *    notice, this list of conditions and the following disclaimer.
10176730Sjeff * 2. Redistributions in binary form must reproduce the above copyright
11176730Sjeff *    notice, this list of conditions and the following disclaimer in the
12176730Sjeff *    documentation and/or other materials provided with the distribution.
13176730Sjeff *
14176730Sjeff * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15176730Sjeff * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16176730Sjeff * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17176730Sjeff * ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
18176730Sjeff * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19176730Sjeff * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20176730Sjeff * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21176730Sjeff * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22176730Sjeff * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23176730Sjeff * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24176730Sjeff * SUCH DAMAGE.
25176730Sjeff */
26176730Sjeff
27176730Sjeff#include <sys/cdefs.h>
28176730Sjeff__FBSDID("$FreeBSD: head/lib/libc/posix1e/acl_copy.c 194955 2009-06-25 12:46:59Z trasz $");
29176730Sjeff
30176730Sjeff#include <sys/types.h>
31176730Sjeff#include "namespace.h"
32176730Sjeff#include <sys/acl.h>
33176730Sjeff#include "un-namespace.h"
34180358Sbz
35180358Sbz#include <errno.h>
36176730Sjeff#include <string.h>
37176730Sjeff
38176730Sjeff#include "acl_support.h"
39192895Sjamie
40176730Sjeff/*
41176730Sjeff * acl_copy_entry() (23.4.4): copy the contents of ACL entry src_d to
42176730Sjeff * ACL entry dest_d
43176730Sjeff */
44176730Sjeffint
45176730Sjeffacl_copy_entry(acl_entry_t dest_d, acl_entry_t src_d)
46176730Sjeff{
47176730Sjeff
48176730Sjeff	if (src_d == NULL || dest_d == NULL || src_d == dest_d) {
49176730Sjeff		errno = EINVAL;
50176730Sjeff		return (-1);
51176730Sjeff	}
52176730Sjeff
53222813Sattilio	/*
54176730Sjeff	 * Can we brand the new entry the same as the source entry?
55177738Sjeff	 */
56177738Sjeff	if (!_entry_brand_may_be(dest_d, _entry_brand(src_d))) {
57176730Sjeff		errno = EINVAL;
58176730Sjeff		return (-1);
59176730Sjeff	}
60180358Sbz
61180358Sbz	_entry_brand_as(dest_d, _entry_brand(src_d));
62180358Sbz
63180358Sbz	dest_d->ae_tag = src_d->ae_tag;
64176730Sjeff	dest_d->ae_id = src_d->ae_id;
65176730Sjeff	dest_d->ae_perm = src_d->ae_perm;
66176730Sjeff	dest_d->ae_entry_type = src_d->ae_entry_type;
67176730Sjeff	dest_d->ae_flags = src_d->ae_flags;
68176730Sjeff
69176730Sjeff	return (0);
70176730Sjeff}
71176730Sjeff
72176730Sjeffssize_t
73176730Sjeffacl_copy_ext(void *buf_p, acl_t acl, ssize_t size)
74176730Sjeff{
75176730Sjeff
76176730Sjeff	errno = ENOSYS;
77176730Sjeff	return (-1);
78176730Sjeff}
79176730Sjeff
80176730Sjeffacl_t
81176730Sjeffacl_copy_int(const void *buf_p)
82176730Sjeff{
83198493Sjhb
84176730Sjeff	errno = ENOSYS;
85176730Sjeff	return (NULL);
86176730Sjeff}
87176730Sjeff