xref: /freebsd/sys/contrib/openzfs/include/zfs_deleg.h (revision eda14cbc264d6969b02f2b1994cef11148e914f1)
1*eda14cbcSMatt Macy /*
2*eda14cbcSMatt Macy  * CDDL HEADER START
3*eda14cbcSMatt Macy  *
4*eda14cbcSMatt Macy  * The contents of this file are subject to the terms of the
5*eda14cbcSMatt Macy  * Common Development and Distribution License (the "License").
6*eda14cbcSMatt Macy  * You may not use this file except in compliance with the License.
7*eda14cbcSMatt Macy  *
8*eda14cbcSMatt Macy  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*eda14cbcSMatt Macy  * or http://www.opensolaris.org/os/licensing.
10*eda14cbcSMatt Macy  * See the License for the specific language governing permissions
11*eda14cbcSMatt Macy  * and limitations under the License.
12*eda14cbcSMatt Macy  *
13*eda14cbcSMatt Macy  * When distributing Covered Code, include this CDDL HEADER in each
14*eda14cbcSMatt Macy  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*eda14cbcSMatt Macy  * If applicable, add the following below this CDDL HEADER, with the
16*eda14cbcSMatt Macy  * fields enclosed by brackets "[]" replaced with your own identifying
17*eda14cbcSMatt Macy  * information: Portions Copyright [yyyy] [name of copyright owner]
18*eda14cbcSMatt Macy  *
19*eda14cbcSMatt Macy  * CDDL HEADER END
20*eda14cbcSMatt Macy  */
21*eda14cbcSMatt Macy /*
22*eda14cbcSMatt Macy  * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
23*eda14cbcSMatt Macy  * Copyright 2010 Nexenta Systems, Inc. All rights reserved.
24*eda14cbcSMatt Macy  * Copyright (c) 2013, 2015 by Delphix. All rights reserved.
25*eda14cbcSMatt Macy  */
26*eda14cbcSMatt Macy 
27*eda14cbcSMatt Macy #ifndef	_ZFS_DELEG_H
28*eda14cbcSMatt Macy #define	_ZFS_DELEG_H
29*eda14cbcSMatt Macy 
30*eda14cbcSMatt Macy #include <sys/fs/zfs.h>
31*eda14cbcSMatt Macy 
32*eda14cbcSMatt Macy #ifdef	__cplusplus
33*eda14cbcSMatt Macy extern "C" {
34*eda14cbcSMatt Macy #endif
35*eda14cbcSMatt Macy 
36*eda14cbcSMatt Macy #define	ZFS_DELEG_SET_NAME_CHR		'@'		/* set name lead char */
37*eda14cbcSMatt Macy #define	ZFS_DELEG_FIELD_SEP_CHR		'$'		/* field separator */
38*eda14cbcSMatt Macy 
39*eda14cbcSMatt Macy /*
40*eda14cbcSMatt Macy  * Max name length for a delegation attribute
41*eda14cbcSMatt Macy  */
42*eda14cbcSMatt Macy #define	ZFS_MAX_DELEG_NAME	128
43*eda14cbcSMatt Macy 
44*eda14cbcSMatt Macy #define	ZFS_DELEG_LOCAL		'l'
45*eda14cbcSMatt Macy #define	ZFS_DELEG_DESCENDENT	'd'
46*eda14cbcSMatt Macy #define	ZFS_DELEG_NA		'-'
47*eda14cbcSMatt Macy 
48*eda14cbcSMatt Macy typedef enum {
49*eda14cbcSMatt Macy 	ZFS_DELEG_NOTE_CREATE,
50*eda14cbcSMatt Macy 	ZFS_DELEG_NOTE_DESTROY,
51*eda14cbcSMatt Macy 	ZFS_DELEG_NOTE_SNAPSHOT,
52*eda14cbcSMatt Macy 	ZFS_DELEG_NOTE_ROLLBACK,
53*eda14cbcSMatt Macy 	ZFS_DELEG_NOTE_CLONE,
54*eda14cbcSMatt Macy 	ZFS_DELEG_NOTE_PROMOTE,
55*eda14cbcSMatt Macy 	ZFS_DELEG_NOTE_RENAME,
56*eda14cbcSMatt Macy 	ZFS_DELEG_NOTE_SEND,
57*eda14cbcSMatt Macy 	ZFS_DELEG_NOTE_RECEIVE,
58*eda14cbcSMatt Macy 	ZFS_DELEG_NOTE_ALLOW,
59*eda14cbcSMatt Macy 	ZFS_DELEG_NOTE_USERPROP,
60*eda14cbcSMatt Macy 	ZFS_DELEG_NOTE_MOUNT,
61*eda14cbcSMatt Macy 	ZFS_DELEG_NOTE_SHARE,
62*eda14cbcSMatt Macy 	ZFS_DELEG_NOTE_USERQUOTA,
63*eda14cbcSMatt Macy 	ZFS_DELEG_NOTE_GROUPQUOTA,
64*eda14cbcSMatt Macy 	ZFS_DELEG_NOTE_USERUSED,
65*eda14cbcSMatt Macy 	ZFS_DELEG_NOTE_GROUPUSED,
66*eda14cbcSMatt Macy 	ZFS_DELEG_NOTE_USEROBJQUOTA,
67*eda14cbcSMatt Macy 	ZFS_DELEG_NOTE_GROUPOBJQUOTA,
68*eda14cbcSMatt Macy 	ZFS_DELEG_NOTE_USEROBJUSED,
69*eda14cbcSMatt Macy 	ZFS_DELEG_NOTE_GROUPOBJUSED,
70*eda14cbcSMatt Macy 	ZFS_DELEG_NOTE_HOLD,
71*eda14cbcSMatt Macy 	ZFS_DELEG_NOTE_RELEASE,
72*eda14cbcSMatt Macy 	ZFS_DELEG_NOTE_DIFF,
73*eda14cbcSMatt Macy 	ZFS_DELEG_NOTE_BOOKMARK,
74*eda14cbcSMatt Macy 	ZFS_DELEG_NOTE_LOAD_KEY,
75*eda14cbcSMatt Macy 	ZFS_DELEG_NOTE_CHANGE_KEY,
76*eda14cbcSMatt Macy 	ZFS_DELEG_NOTE_PROJECTUSED,
77*eda14cbcSMatt Macy 	ZFS_DELEG_NOTE_PROJECTQUOTA,
78*eda14cbcSMatt Macy 	ZFS_DELEG_NOTE_PROJECTOBJUSED,
79*eda14cbcSMatt Macy 	ZFS_DELEG_NOTE_PROJECTOBJQUOTA,
80*eda14cbcSMatt Macy 	ZFS_DELEG_NOTE_NONE
81*eda14cbcSMatt Macy } zfs_deleg_note_t;
82*eda14cbcSMatt Macy 
83*eda14cbcSMatt Macy typedef struct zfs_deleg_perm_tab {
84*eda14cbcSMatt Macy 	char *z_perm;
85*eda14cbcSMatt Macy 	zfs_deleg_note_t z_note;
86*eda14cbcSMatt Macy } zfs_deleg_perm_tab_t;
87*eda14cbcSMatt Macy 
88*eda14cbcSMatt Macy extern zfs_deleg_perm_tab_t zfs_deleg_perm_tab[];
89*eda14cbcSMatt Macy 
90*eda14cbcSMatt Macy int zfs_deleg_verify_nvlist(nvlist_t *nvlist);
91*eda14cbcSMatt Macy void zfs_deleg_whokey(char *attr, zfs_deleg_who_type_t type,
92*eda14cbcSMatt Macy     char checkflag, void *data);
93*eda14cbcSMatt Macy const char *zfs_deleg_canonicalize_perm(const char *perm);
94*eda14cbcSMatt Macy 
95*eda14cbcSMatt Macy #ifdef	__cplusplus
96*eda14cbcSMatt Macy }
97*eda14cbcSMatt Macy #endif
98*eda14cbcSMatt Macy 
99*eda14cbcSMatt Macy #endif	/* _ZFS_DELEG_H */
100