1 /*
2  *  Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC.
3  *  Copyright (C) 2007 The Regents of the University of California.
4  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
5  *  Written by Brian Behlendorf <behlendorf1@llnl.gov>.
6  *  UCRL-CODE-235197
7  *
8  *  This file is part of the SPL, Solaris Porting Layer.
9  *
10  *  The SPL is free software; you can redistribute it and/or modify it
11  *  under the terms of the GNU General Public License as published by the
12  *  Free Software Foundation; either version 2 of the License, or (at your
13  *  option) any later version.
14  *
15  *  The SPL is distributed in the hope that it will be useful, but WITHOUT
16  *  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
17  *  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
18  *  for more details.
19  *
20  *  You should have received a copy of the GNU General Public License along
21  *  with the SPL.  If not, see <http://www.gnu.org/licenses/>.
22  */
23 
24 #ifndef _SPL_ZONE_H
25 #define	_SPL_ZONE_H
26 
27 #include <sys/byteorder.h>
28 #include <sys/cred.h>
29 
30 #include <linux/cred.h>
31 #include <linux/user_namespace.h>
32 
33 /*
34  * Attach the given dataset to the given user namespace.
35  */
36 extern int zone_dataset_attach(cred_t *, const char *, int);
37 
38 /*
39  * Detach the given dataset from the given user namespace.
40  */
41 extern int zone_dataset_detach(cred_t *, const char *, int);
42 
43 /*
44  * Returns true if the named pool/dataset is visible in the current zone.
45  */
46 extern int zone_dataset_visible(const char *dataset, int *write);
47 
48 int spl_zone_init(void);
49 void spl_zone_fini(void);
50 
51 extern unsigned int crgetzoneid(const cred_t *);
52 extern unsigned int global_zoneid(void);
53 extern boolean_t inglobalzone(proc_t *);
54 
55 #define	INGLOBALZONE(x) inglobalzone(x)
56 #define	GLOBAL_ZONEID	global_zoneid()
57 
58 #endif /* SPL_ZONE_H */
59