limit.c

Go to the documentation of this file.
00001 // Copyright 2005-2006 Benedikt Böhm <hollow@gentoo.org>
00002 //
00003 // This program is free software; you can redistribute it and/or modify
00004 // it under the terms of the GNU General Public License as published by
00005 // the Free Software Foundation; either version 2 of the License, or
00006 // (at your option) any later version.
00007 //
00008 // This program is distributed in the hope that it will be useful,
00009 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00011 // GNU General Public License for more details.
00012 //
00013 // You should have received a copy of the GNU General Public License
00014 // along with this program; if not, write to the
00015 // Free Software Foundation, Inc.,
00016 // 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00017 
00018 #include <stdint.h>
00019 #include <errno.h>
00020 
00021 #include "linux/vserver/switch.h"
00022 #include "linux/vserver/limit_cmd.h"
00023 
00024 #include "vserver.h"
00025 
00026 int vx_limit_mask_get(vx_limit_t *data)
00027 {
00028         int rc;
00029         struct vcmd_ctx_rlimit_mask_v0 kdata;
00030 
00031         if (!data)
00032                 return errno = EINVAL, -1;
00033 
00034         rc = vserver(VCMD_get_rlimit_mask, 0, &kdata);
00035 
00036         if (rc == -1)
00037                 return rc;
00038 
00039         data->minimum   = kdata.minimum;
00040         data->softlimit = kdata.softlimit;
00041         data->maximum   = kdata.maximum;
00042 
00043         return rc;
00044 }
00045 
00046 int vx_limit_set(xid_t xid, vx_limit_t *data)
00047 {
00048         struct vcmd_ctx_rlimit_v0 kdata;
00049 
00050         if (!data)
00051                 return errno = EINVAL, -1;
00052 
00053         kdata.id        = data->id;
00054         kdata.minimum   = data->minimum;
00055         kdata.softlimit = data->softlimit;
00056         kdata.maximum   = data->maximum;
00057 
00058         return vserver(VCMD_set_rlimit, xid, &kdata);
00059 }
00060 
00061 int vx_limit_get(xid_t xid, vx_limit_t *data)
00062 {
00063         int rc;
00064         struct vcmd_ctx_rlimit_v0 kdata;
00065 
00066         if (!data)
00067                 return errno = EINVAL, -1;
00068 
00069         kdata.id = data->id;
00070 
00071         rc = vserver(VCMD_get_rlimit, xid, &kdata);
00072 
00073         if (rc == -1)
00074                 return rc;
00075 
00076         data->minimum   = kdata.minimum;
00077         data->softlimit = kdata.softlimit;
00078         data->maximum   = kdata.maximum;
00079 
00080         return rc;
00081 }
00082 
00083 int vx_limit_stat(xid_t xid, vx_limit_stat_t *data)
00084 {
00085         int rc;
00086         struct vcmd_rlimit_stat_v0 kdata;
00087 
00088         if (!data)
00089                 return errno = EINVAL, -1;
00090 
00091         kdata.id = data->id;
00092 
00093         rc = vserver(VCMD_rlimit_stat, xid, &kdata);
00094 
00095         if (rc == -1)
00096                 return rc;
00097 
00098         data->hits    = kdata.hits;
00099         data->value   = kdata.value;
00100         data->minimum = kdata.minimum;
00101         data->maximum = kdata.maximum;
00102 
00103         return rc;
00104 }
00105 
00106 int vx_limit_reset(xid_t xid)
00107 {
00108         return vserver(VCMD_reset_minmax, xid, NULL);
00109 }

Generated on Wed Jun 20 19:50:08 2007 for libvserver by  doxygen 1.5.2