]> git.proxmox.com Git - mirror_lxc.git/blame - src/lxc/caps.h
tty.h: Ship our own minimal openpty.h
[mirror_lxc.git] / src / lxc / caps.h
CommitLineData
b3357a6f
DL
1/*
2 * lxc: linux Container library
3 *
4 * (C) Copyright IBM Corp. 2007, 2008
5 *
6 * Authors:
7 * Daniel Lezcano <dlezcano at fr.ibm.com>
8 *
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
13 *
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
18 *
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 */
23#ifndef _caps_h
24#define _caps_h
7d40e69b 25
05cda563 26extern int lxc_caps_reset(void);
7d40e69b
DL
27extern int lxc_caps_down(void);
28extern int lxc_caps_up(void);
29extern int lxc_caps_init(void);
4a2ca8b2 30extern int lxc_caps_check(void);
7d40e69b 31
20d81659
CS
32extern int lxc_caps_last_cap(void);
33
7d40e69b
DL
34#define lxc_priv(__lxc_function) \
35 ({ \
596a818d 36 __label__ out; \
7d40e69b
DL
37 int __ret, __ret2, __errno = 0; \
38 __ret = lxc_caps_up(); \
39 if (__ret) \
596a818d 40 goto out; \
7d40e69b
DL
41 __ret = __lxc_function; \
42 if (__ret) \
43 __errno = errno; \
44 __ret2 = lxc_caps_down(); \
596a818d 45 out: __ret ? errno = __errno,__ret : __ret2; \
7d40e69b
DL
46 })
47
596a818d 48#define lxc_unpriv(__lxc_function) \
7d40e69b 49 ({ \
596a818d 50 __label__ out; \
7d40e69b
DL
51 int __ret, __ret2, __errno = 0; \
52 __ret = lxc_caps_down(); \
53 if (__ret) \
596a818d 54 goto out; \
7d40e69b
DL
55 __ret = __lxc_function; \
56 if (__ret) \
57 __errno = errno; \
58 __ret2 = lxc_caps_up(); \
596a818d 59 out: __ret ? errno = __errno,__ret : __ret2; \
7d40e69b 60 })
b3357a6f 61#endif