acl_get.c revision 56274
1238384Sjkim/*- 2238384Sjkim * Copyright (c) 1999 Robert N. M. Watson 3238384Sjkim * All rights reserved. 4238384Sjkim * 5238384Sjkim * Redistribution and use in source and binary forms, with or without 6238384Sjkim * modification, are permitted provided that the following conditions 7238384Sjkim * are met: 8238384Sjkim * 1. Redistributions of source code must retain the above copyright 9238384Sjkim * notice, this list of conditions and the following disclaimer. 10238384Sjkim * 2. Redistributions in binary form must reproduce the above copyright 11238384Sjkim * notice, this list of conditions and the following disclaimer in the 12238384Sjkim * documentation and/or other materials provided with the distribution. 13238384Sjkim * 14238384Sjkim * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15238384Sjkim * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16238384Sjkim * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17238384Sjkim * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18238384Sjkim * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19238384Sjkim * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20238384Sjkim * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21238384Sjkim * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22238384Sjkim * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23238384Sjkim * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24238384Sjkim * SUCH DAMAGE. 25238384Sjkim * 26238384Sjkim * $FreeBSD: head/lib/libc/posix1e/acl_get.c 56274 2000-01-19 06:13:59Z rwatson $ 27238384Sjkim */ 28238384Sjkim/* 29238384Sjkim * acl_get_file - syscall wrapper for retrieving ACL by filename 30238384Sjkim */ 31238384Sjkim 32238384Sjkim#include <sys/types.h> 33238384Sjkim#include <sys/acl.h> 34238384Sjkim#include <sys/errno.h> 35238384Sjkim#include <stdlib.h> 36238384Sjkim 37238384Sjkimacl_t 38238384Sjkimacl_get_file(const char *path_p, acl_type_t type) 39238384Sjkim{ 40238384Sjkim struct acl *aclp; 41238384Sjkim int error; 42238384Sjkim 43238384Sjkim aclp = acl_init(ACL_MAX_ENTRIES); 44238384Sjkim if (!aclp) { 45238384Sjkim return (0); 46238384Sjkim } 47238384Sjkim 48238384Sjkim error = __acl_get_file(path_p, type, aclp); 49238384Sjkim if (error) { 50238384Sjkim acl_free(aclp); 51238384Sjkim return (0); 52238384Sjkim } 53238384Sjkim 54238384Sjkim return (aclp); 55238384Sjkim} 56238384Sjkim 57238384Sjkim 58238384Sjkimacl_t 59238384Sjkimacl_get_fd(int fd, acl_type_t type) 60238384Sjkim{ 61238384Sjkim struct acl *aclp; 62238384Sjkim int error; 63238384Sjkim 64238384Sjkim aclp = acl_init(ACL_MAX_ENTRIES); 65238384Sjkim if (!aclp) { 66238384Sjkim return (0); 67238384Sjkim } 68238384Sjkim 69238384Sjkim error = __acl_get_fd(fd, type, aclp); 70238384Sjkim if (error) { 71238384Sjkim acl_free(aclp); 72238384Sjkim return (0); 73238384Sjkim } 74238384Sjkim 75238384Sjkim return (aclp); 76238384Sjkim} 77238384Sjkim