Permalink
Browse files

src/lib/ub.c: introduce is_vswap_config()

This function is to be used in places that need to determine if the
container' beancounter config is vswap-enabled or a standard UBC config.

Signed-off-by: Kir Kolyshkin <kir@openvz.org>
  • Loading branch information...
1 parent 8675d19 commit 5094cfa6aa9720ee7947d9fb93b133fbbea52eb2 @kolyshkin kolyshkin committed Sep 20, 2011
Showing with 10 additions and 0 deletions.
  1. +1 −0 include/ub.h
  2. +9 −0 src/lib/ub.c
View
1 include/ub.h
@@ -175,4 +175,5 @@ const char *get_ub_name(unsigned int res_id);
void add_ub_limit(struct ub_struct *ub, int res_id, unsigned long *limit);
void free_ub_param(ub_param *ub);
void merge_ub(ub_param *dst, ub_param *src);
+int is_vswap_config(const ub_param *param);
#endif
View
9 src/lib/ub.c
@@ -21,6 +21,7 @@
#include <unistd.h>
#include <fcntl.h>
#include <string.h>
+#include <limits.h>
#include "types.h"
#include "ub.h"
@@ -396,3 +397,11 @@ int vps_read_ubc(envid_t veid, ub_param *ub)
fclose(fd);
return !found;
}
+
+int is_vswap_config(const ub_param *param)
+{
+ return (param != NULL) &&
+ (param->physpages != NULL) &&
+ (param->physpages[1] != LONG_MAX);
+
+}

0 comments on commit 5094cfa

Please sign in to comment.