3 // Copyright (C) 2003 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; version 2 of the License.
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License
15 // along with this program; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 #define KERN2USR(LIMIT) \
24 (((LIMIT)==CRLIM_INFINITY) ? VC_LIM_INFINITY : \
25 ((LIMIT)==CRLIM_KEEP) ? VC_LIM_KEEP : (LIMIT))
27 #define USR2KERN(LIMIT) \
28 (((LIMIT)==VC_LIM_INFINITY) ? CRLIM_INFINITY : \
29 ((LIMIT)==VC_LIM_KEEP) ? CRLIM_KEEP : (LIMIT))
31 static inline ALWAYSINLINE int
32 vc_get_rlimit_v11(ctx_t ctx, int resource, struct vc_rlimit *lim)
34 struct vcmd_ctx_rlimit_v0 vc_lim;
38 rc = sys_virtual_context(VC_CMD(RLIMIT, 1, 0), ctx, &vc_lim);
39 lim->min = KERN2USR(vc_lim.minimum);
40 lim->soft = KERN2USR(vc_lim.softlimit);
41 lim->hard = KERN2USR(vc_lim.maximum);
46 static inline ALWAYSINLINE int
47 vc_set_rlimit_v11(ctx_t ctx, int resource, struct vc_rlimit const *lim)
49 struct vcmd_ctx_rlimit_v0 vc_lim;
52 vc_lim.minimum = USR2KERN(lim->min);
53 vc_lim.softlimit = USR2KERN(lim->soft);
54 vc_lim.maximum = USR2KERN(lim->hard);
56 return sys_virtual_context(VC_CMD(RLIMIT, 2, 0), ctx, &vc_lim);
59 static inline ALWAYSINLINE int
60 vc_get_rlimit_mask_v11(ctx_t ctx, int tmp, struct vc_rlimit_mask *lim)
62 struct vcmd_ctx_rlimit_v0 vc_lim;
65 return sys_virtual_context(VC_CMD(RLIMIT, 3, 0), ctx, &vc_lim);