19ddb49cbSWarner Losh /*-
243960f15SRobert Watson * Copyright (c) 2001 Chris D. Faulhaber
343960f15SRobert Watson * All rights reserved.
443960f15SRobert Watson *
543960f15SRobert Watson * Redistribution and use in source and binary forms, with or without
643960f15SRobert Watson * modification, are permitted provided that the following conditions
743960f15SRobert Watson * are met:
843960f15SRobert Watson * 1. Redistributions of source code must retain the above copyright
943960f15SRobert Watson * notice, this list of conditions and the following disclaimer.
1043960f15SRobert Watson * 2. Redistributions in binary form must reproduce the above copyright
1143960f15SRobert Watson * notice, this list of conditions and the following disclaimer in the
1243960f15SRobert Watson * documentation and/or other materials provided with the distribution.
1343960f15SRobert Watson *
1443960f15SRobert Watson * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
1543960f15SRobert Watson * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1643960f15SRobert Watson * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17a303eae7SJoel Dahl * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18a303eae7SJoel Dahl * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19a303eae7SJoel Dahl * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20a303eae7SJoel Dahl * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21a303eae7SJoel Dahl * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22a303eae7SJoel Dahl * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23a303eae7SJoel Dahl * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24a303eae7SJoel Dahl * SUCH DAMAGE.
2543960f15SRobert Watson */
2643960f15SRobert Watson
272749b141SDavid E. O'Brien #include <sys/cdefs.h>
2843960f15SRobert Watson #include <err.h>
2943960f15SRobert Watson #include <stdlib.h>
3043960f15SRobert Watson
3143960f15SRobert Watson #include "setfacl.h"
3243960f15SRobert Watson
3343960f15SRobert Watson void *
zmalloc(size_t size)3443960f15SRobert Watson zmalloc(size_t size)
3543960f15SRobert Watson {
3643960f15SRobert Watson void *ptr;
3743960f15SRobert Watson
38d0b8d0fdSChris D. Faulhaber ptr = calloc(1, size);
39405c5615SChris D. Faulhaber if (ptr == NULL)
40a043a09dSChris D. Faulhaber err(1, "calloc() failed");
41a043a09dSChris D. Faulhaber return (ptr);
4243960f15SRobert Watson }
43c93b62deSEdward Tomasz Napierala
44*0629b152SEd Maste void *
zrealloc(void * ptr,size_t size)45*0629b152SEd Maste zrealloc(void *ptr, size_t size)
46*0629b152SEd Maste {
47*0629b152SEd Maste void *newptr;
48*0629b152SEd Maste
49*0629b152SEd Maste newptr = realloc(ptr, size);
50*0629b152SEd Maste if (newptr == NULL)
51*0629b152SEd Maste err(1, "realloc() failed");
52*0629b152SEd Maste return (newptr);
53*0629b152SEd Maste }
54*0629b152SEd Maste
55c93b62deSEdward Tomasz Napierala const char *
brand_name(int brand)56c93b62deSEdward Tomasz Napierala brand_name(int brand)
57c93b62deSEdward Tomasz Napierala {
58c93b62deSEdward Tomasz Napierala switch (brand) {
59c93b62deSEdward Tomasz Napierala case ACL_BRAND_NFS4:
60c93b62deSEdward Tomasz Napierala return "NFSv4";
61c93b62deSEdward Tomasz Napierala case ACL_BRAND_POSIX:
62c93b62deSEdward Tomasz Napierala return "POSIX.1e";
63c93b62deSEdward Tomasz Napierala default:
64c93b62deSEdward Tomasz Napierala return "unknown";
65c93b62deSEdward Tomasz Napierala }
66c93b62deSEdward Tomasz Napierala }
67c93b62deSEdward Tomasz Napierala
68c93b62deSEdward Tomasz Napierala int
branding_mismatch(int brand1,int brand2)69c93b62deSEdward Tomasz Napierala branding_mismatch(int brand1, int brand2)
70c93b62deSEdward Tomasz Napierala {
71c93b62deSEdward Tomasz Napierala if (brand1 == ACL_BRAND_UNKNOWN || brand2 == ACL_BRAND_UNKNOWN)
72c93b62deSEdward Tomasz Napierala return (0);
73c93b62deSEdward Tomasz Napierala if (brand1 != brand2)
74c93b62deSEdward Tomasz Napierala return (1);
756c9c14c5SEdward Tomasz Napierala return (0);
76c93b62deSEdward Tomasz Napierala }
77