usr/src/uts/common/fs/zfs/sys/zfs_acl.h
author Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
Thu, 26 Mar 2009 13:13:24 -0600
changeset 9179 d8fbd96b79b3
parent 8053 271f44d3de11
child 9396 f41cf682d0d3
permissions -rw-r--r--
6790064 zfs needs to determine uid and gid earlier in create process
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
     1
/*
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
     2
 * CDDL HEADER START
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
     3
 *
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
     4
 * The contents of this file are subject to the terms of the
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 905
diff changeset
     5
 * Common Development and Distribution License (the "License").
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 905
diff changeset
     6
 * You may not use this file except in compliance with the License.
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
     7
 *
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
     8
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
     9
 * or http://www.opensolaris.org/os/licensing.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    10
 * See the License for the specific language governing permissions
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    11
 * and limitations under the License.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    12
 *
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    13
 * When distributing Covered Code, include this CDDL HEADER in each
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    14
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    15
 * If applicable, add the following below this CDDL HEADER, with the
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    16
 * fields enclosed by brackets "[]" replaced with your own identifying
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    17
 * information: Portions Copyright [yyyy] [name of copyright owner]
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    18
 *
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    19
 * CDDL HEADER END
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    20
 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    21
/*
9179
d8fbd96b79b3 6790064 zfs needs to determine uid and gid earlier in create process
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 8053
diff changeset
    22
 * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    23
 * Use is subject to license terms.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    24
 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    25
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    26
#ifndef	_SYS_FS_ZFS_ACL_H
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    27
#define	_SYS_FS_ZFS_ACL_H
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    28
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    29
#ifdef _KERNEL
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    30
#include <sys/isa_defs.h>
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    31
#include <sys/types32.h>
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    32
#endif
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    33
#include <sys/acl.h>
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    34
#include <sys/dmu.h>
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 2676
diff changeset
    35
#include <sys/zfs_fuid.h>
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    36
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    37
#ifdef	__cplusplus
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    38
extern "C" {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    39
#endif
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    40
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    41
struct znode_phys;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    42
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    43
#define	ACE_SLOT_CNT	6
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 2676
diff changeset
    44
#define	ZFS_ACL_VERSION_INITIAL 0ULL
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 2676
diff changeset
    45
#define	ZFS_ACL_VERSION_FUID	1ULL
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 2676
diff changeset
    46
#define	ZFS_ACL_VERSION		ZFS_ACL_VERSION_FUID
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    47
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 2676
diff changeset
    48
/*
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 2676
diff changeset
    49
 * ZFS ACLs are store in various forms.
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 2676
diff changeset
    50
 * Files created with ACL version ZFS_ACL_VERSION_INITIAL
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 2676
diff changeset
    51
 * will all be created with fixed length ACEs of type
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 2676
diff changeset
    52
 * zfs_oldace_t.
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 2676
diff changeset
    53
 *
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 2676
diff changeset
    54
 * Files with ACL version ZFS_ACL_VERSION_FUID will be created
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 2676
diff changeset
    55
 * with various sized ACEs.  The abstraction entries will utilize
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 2676
diff changeset
    56
 * zfs_ace_hdr_t, normal user/group entries will use zfs_ace_t
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 2676
diff changeset
    57
 * and some specialized CIFS ACEs will use zfs_object_ace_t.
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 2676
diff changeset
    58
 */
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    59
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 2676
diff changeset
    60
/*
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 2676
diff changeset
    61
 * All ACEs have a common hdr.  For
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 2676
diff changeset
    62
 * owner@, group@, and everyone@ this is all
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 2676
diff changeset
    63
 * thats needed.
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 2676
diff changeset
    64
 */
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 2676
diff changeset
    65
typedef struct zfs_ace_hdr {
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 2676
diff changeset
    66
	uint16_t z_type;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 2676
diff changeset
    67
	uint16_t z_flags;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 2676
diff changeset
    68
	uint32_t z_access_mask;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 2676
diff changeset
    69
} zfs_ace_hdr_t;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 2676
diff changeset
    70
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 2676
diff changeset
    71
typedef zfs_ace_hdr_t zfs_ace_abstract_t;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 2676
diff changeset
    72
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 2676
diff changeset
    73
/*
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 2676
diff changeset
    74
 * Standard ACE
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 2676
diff changeset
    75
 */
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 2676
diff changeset
    76
typedef struct zfs_ace {
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 2676
diff changeset
    77
	zfs_ace_hdr_t	z_hdr;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 2676
diff changeset
    78
	uint64_t	z_fuid;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 2676
diff changeset
    79
} zfs_ace_t;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    80
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    81
/*
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 2676
diff changeset
    82
 * The following type only applies to ACE_ACCESS_ALLOWED|DENIED_OBJECT_ACE_TYPE
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 2676
diff changeset
    83
 * and will only be set/retrieved in a CIFS context.
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    84
 */
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 2676
diff changeset
    85
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 2676
diff changeset
    86
typedef struct zfs_object_ace {
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 2676
diff changeset
    87
	zfs_ace_t	z_ace;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 2676
diff changeset
    88
	uint8_t		z_object_type[16]; /* object type */
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 2676
diff changeset
    89
	uint8_t		z_inherit_type[16]; /* inherited object type */
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 2676
diff changeset
    90
} zfs_object_ace_t;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 2676
diff changeset
    91
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 2676
diff changeset
    92
typedef struct zfs_oldace {
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 2676
diff changeset
    93
	uint32_t	z_fuid;		/* "who" */
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 2676
diff changeset
    94
	uint32_t	z_access_mask;  /* access mask */
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 2676
diff changeset
    95
	uint16_t	z_flags;	/* flags, i.e inheritance */
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 2676
diff changeset
    96
	uint16_t	z_type;		/* type of entry allow/deny */
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 2676
diff changeset
    97
} zfs_oldace_t;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 2676
diff changeset
    98
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 2676
diff changeset
    99
typedef struct zfs_acl_phys_v0 {
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 2676
diff changeset
   100
	uint64_t	z_acl_extern_obj;	/* ext acl pieces */
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 2676
diff changeset
   101
	uint32_t	z_acl_count;		/* Number of ACEs */
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 2676
diff changeset
   102
	uint16_t	z_acl_version;		/* acl version */
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 2676
diff changeset
   103
	uint16_t	z_acl_pad;		/* pad */
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 2676
diff changeset
   104
	zfs_oldace_t	z_ace_data[ACE_SLOT_CNT]; /* 6 standard ACEs */
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 2676
diff changeset
   105
} zfs_acl_phys_v0_t;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 2676
diff changeset
   106
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 2676
diff changeset
   107
#define	ZFS_ACE_SPACE	(sizeof (zfs_oldace_t) * ACE_SLOT_CNT)
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 2676
diff changeset
   108
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 2676
diff changeset
   109
typedef struct zfs_acl_phys {
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 2676
diff changeset
   110
	uint64_t	z_acl_extern_obj;	  /* ext acl pieces */
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 2676
diff changeset
   111
	uint32_t	z_acl_size;		  /* Number of bytes in ACL */
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 2676
diff changeset
   112
	uint16_t	z_acl_version;		  /* acl version */
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 2676
diff changeset
   113
	uint16_t	z_acl_count;		  /* ace count */
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 2676
diff changeset
   114
	uint8_t		z_ace_data[ZFS_ACE_SPACE]; /* space for embedded ACEs */
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 2676
diff changeset
   115
} zfs_acl_phys_t;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 2676
diff changeset
   116
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 2676
diff changeset
   117
typedef struct acl_ops {
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 2676
diff changeset
   118
	uint32_t	(*ace_mask_get) (void *acep); /* get  access mask */
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 2676
diff changeset
   119
	void 		(*ace_mask_set) (void *acep,
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 2676
diff changeset
   120
			    uint32_t mask); /* set access mask */
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 2676
diff changeset
   121
	uint16_t	(*ace_flags_get) (void *acep);	/* get flags */
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 2676
diff changeset
   122
	void		(*ace_flags_set) (void *acep,
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 2676
diff changeset
   123
			    uint16_t flags); /* set flags */
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 2676
diff changeset
   124
	uint16_t	(*ace_type_get)(void *acep); /* get type */
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 2676
diff changeset
   125
	void		(*ace_type_set)(void *acep,
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 2676
diff changeset
   126
			    uint16_t type); /* set type */
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 2676
diff changeset
   127
	uint64_t	(*ace_who_get)(void *acep); /* get who/fuid */
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 2676
diff changeset
   128
	void		(*ace_who_set)(void *acep,
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 2676
diff changeset
   129
			    uint64_t who); /* set who/fuid */
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 2676
diff changeset
   130
	size_t		(*ace_size)(void *acep); /* how big is this ace */
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 2676
diff changeset
   131
	size_t		(*ace_abstract_size)(void); /* sizeof abstract entry */
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 2676
diff changeset
   132
	int		(*ace_mask_off)(void); /* off of access mask in ace */
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 2676
diff changeset
   133
	int		(*ace_data)(void *acep, void **datap);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 2676
diff changeset
   134
			    /* ptr to data if any */
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 2676
diff changeset
   135
} acl_ops_t;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 2676
diff changeset
   136
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 2676
diff changeset
   137
/*
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 2676
diff changeset
   138
 * A zfs_acl_t structure is composed of a list of zfs_acl_node_t's.
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 2676
diff changeset
   139
 * Each node will have one or more ACEs associated with it.  You will
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 2676
diff changeset
   140
 * only have multiple nodes during a chmod operation.   Normally only
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 2676
diff changeset
   141
 * one node is required.
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 2676
diff changeset
   142
 */
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 2676
diff changeset
   143
typedef struct zfs_acl_node {
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 2676
diff changeset
   144
	list_node_t	z_next;		/* Next chunk of ACEs */
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 2676
diff changeset
   145
	void		*z_acldata;	/* pointer into actual ACE(s) */
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 2676
diff changeset
   146
	void		*z_allocdata;	/* pointer to kmem allocated memory */
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 2676
diff changeset
   147
	size_t		z_allocsize;	/* Size of blob in bytes */
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 2676
diff changeset
   148
	size_t		z_size;		/* length of ACL data */
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 2676
diff changeset
   149
	int		z_ace_count;	/* number of ACEs in this acl node */
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 2676
diff changeset
   150
	int		z_ace_idx;	/* ace iterator positioned on */
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 2676
diff changeset
   151
} zfs_acl_node_t;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   152
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   153
typedef struct zfs_acl {
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 2676
diff changeset
   154
	int		z_acl_count;	/* Number of ACEs */
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 2676
diff changeset
   155
	size_t		z_acl_bytes;	/* Number of bytes in ACL */
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 2676
diff changeset
   156
	uint_t		z_version;	/* version of ACL */
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 2676
diff changeset
   157
	void		*z_next_ace;	/* pointer to next ACE */
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 2676
diff changeset
   158
	int		z_hints;	/* ACL hints (ZFS_INHERIT_ACE ...) */
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 2676
diff changeset
   159
	zfs_acl_node_t	*z_curr_node;	/* current node iterator is handling */
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 2676
diff changeset
   160
	list_t		z_acl;		/* chunks of ACE data */
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 2676
diff changeset
   161
	acl_ops_t	z_ops;		/* ACL operations */
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   162
} zfs_acl_t;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   163
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 2676
diff changeset
   164
#define	ACL_DATA_ALLOCED	0x1
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   165
#define	ZFS_ACL_SIZE(aclcnt)	(sizeof (ace_t) * (aclcnt))
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   166
9179
d8fbd96b79b3 6790064 zfs needs to determine uid and gid earlier in create process
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 8053
diff changeset
   167
struct zfs_fuid_info;
d8fbd96b79b3 6790064 zfs needs to determine uid and gid earlier in create process
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 8053
diff changeset
   168
d8fbd96b79b3 6790064 zfs needs to determine uid and gid earlier in create process
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 8053
diff changeset
   169
typedef struct zfs_acl_ids_t {
d8fbd96b79b3 6790064 zfs needs to determine uid and gid earlier in create process
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 8053
diff changeset
   170
	uint64_t		z_fuid;		/* file owner fuid */
d8fbd96b79b3 6790064 zfs needs to determine uid and gid earlier in create process
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 8053
diff changeset
   171
	uint64_t		z_fgid;		/* file group owner fuid */
d8fbd96b79b3 6790064 zfs needs to determine uid and gid earlier in create process
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 8053
diff changeset
   172
	uint64_t		z_mode;		/* mode to set on create */
d8fbd96b79b3 6790064 zfs needs to determine uid and gid earlier in create process
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 8053
diff changeset
   173
	zfs_acl_t		*z_aclp;	/* ACL to create with file */
d8fbd96b79b3 6790064 zfs needs to determine uid and gid earlier in create process
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 8053
diff changeset
   174
	struct zfs_fuid_info 	*z_fuidp;	/* for tracking fuids for log */
d8fbd96b79b3 6790064 zfs needs to determine uid and gid earlier in create process
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 8053
diff changeset
   175
} zfs_acl_ids_t;
d8fbd96b79b3 6790064 zfs needs to determine uid and gid earlier in create process
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 8053
diff changeset
   176
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   177
/*
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   178
 * Property values for acl_mode and acl_inherit.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   179
 *
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   180
 * acl_mode can take discard, noallow, groupmask and passthrough.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   181
 * whereas acl_inherit has secure instead of groupmask.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   182
 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   183
2676
5cee47eddab6 PSARC 2006/486 ZFS canmount property
eschrock
parents: 1544
diff changeset
   184
#define	ZFS_ACL_DISCARD		0
5cee47eddab6 PSARC 2006/486 ZFS canmount property
eschrock
parents: 1544
diff changeset
   185
#define	ZFS_ACL_NOALLOW		1
5cee47eddab6 PSARC 2006/486 ZFS canmount property
eschrock
parents: 1544
diff changeset
   186
#define	ZFS_ACL_GROUPMASK	2
5cee47eddab6 PSARC 2006/486 ZFS canmount property
eschrock
parents: 1544
diff changeset
   187
#define	ZFS_ACL_PASSTHROUGH	3
6385
5437941ec5a1 PSARC/2008/231 New ZFS "passthrough" ACL inheritance rules
marks
parents: 6257
diff changeset
   188
#define	ZFS_ACL_RESTRICTED	4
8053
271f44d3de11 PSARC/2008/659 New ZFS "passthrough-x" ACL inheritance rules
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 6385
diff changeset
   189
#define	ZFS_ACL_PASSTHROUGH_X	5
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   190
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   191
struct znode;
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 2676
diff changeset
   192
struct zfsvfs;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   193
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   194
#ifdef _KERNEL
9179
d8fbd96b79b3 6790064 zfs needs to determine uid and gid earlier in create process
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 8053
diff changeset
   195
int zfs_acl_ids_create(struct znode *, int, vattr_t *,
d8fbd96b79b3 6790064 zfs needs to determine uid and gid earlier in create process
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 8053
diff changeset
   196
    cred_t *, vsecattr_t *, zfs_acl_ids_t *);
d8fbd96b79b3 6790064 zfs needs to determine uid and gid earlier in create process
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 8053
diff changeset
   197
void zfs_acl_ids_free(zfs_acl_ids_t *);
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 2676
diff changeset
   198
int zfs_getacl(struct znode *, vsecattr_t *, boolean_t, cred_t *);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 2676
diff changeset
   199
int zfs_setacl(struct znode *, vsecattr_t *, boolean_t, cred_t *);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   200
void zfs_acl_rele(void *);
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 2676
diff changeset
   201
void zfs_oldace_byteswap(ace_t *, int);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 2676
diff changeset
   202
void zfs_ace_byteswap(void *, size_t, boolean_t);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 2676
diff changeset
   203
extern int zfs_zaccess(struct znode *, int, int, boolean_t, cred_t *);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 2676
diff changeset
   204
extern int zfs_zaccess_rwx(struct znode *, mode_t, int, cred_t *);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 2676
diff changeset
   205
extern int zfs_zaccess_unix(struct znode *, mode_t, cred_t *);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   206
extern int zfs_acl_access(struct znode *, int, cred_t *);
5824
1d2d522d19b5 6603908 can't change mode if FS/dir is out of quota
marks
parents: 5771
diff changeset
   207
int zfs_acl_chmod_setattr(struct znode *, zfs_acl_t **, uint64_t);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   208
int zfs_zaccess_delete(struct znode *, struct znode *, cred_t *);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   209
int zfs_zaccess_rename(struct znode *, struct znode *,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   210
    struct znode *, struct znode *, cred_t *cr);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   211
void zfs_acl_free(zfs_acl_t *);
9179
d8fbd96b79b3 6790064 zfs needs to determine uid and gid earlier in create process
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 8053
diff changeset
   212
int zfs_vsec_2_aclp(struct zfsvfs *, vtype_t, vsecattr_t *, cred_t *,
d8fbd96b79b3 6790064 zfs needs to determine uid and gid earlier in create process
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 8053
diff changeset
   213
    struct zfs_fuid_info **, zfs_acl_t **);
d8fbd96b79b3 6790064 zfs needs to determine uid and gid earlier in create process
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 8053
diff changeset
   214
int zfs_aclset_common(struct znode *, zfs_acl_t *, cred_t *, dmu_tx_t *);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   215
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   216
#endif
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   217
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   218
#ifdef	__cplusplus
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   219
}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   220
#endif
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   221
#endif	/* _SYS_FS_ZFS_ACL_H */