arch_to_personality removed (lxc_config_parse_arch is not provided in API). lxc_wait_for_pid_status implementation added (not provided in API)

This commit is contained in:
Denis Knauf 2023-10-10 15:31:34 +02:00
parent cf94855c8e
commit 2902c02478

View file

@ -41,8 +41,28 @@ extern void *rb_thread_call_without_gvl(void *(*func)(void *), void *data1,
#define RELEASING_GVL2(func, arg, killfunc, killarg) func(arg) #define RELEASING_GVL2(func, arg, killfunc, killarg) func(arg)
#endif #endif
extern int lxc_wait_for_pid_status(pid_t pid); //extern int lxc_wait_for_pid_status(pid_t pid);
extern long lxc_config_parse_arch(const char *arch); #include <sys/types.h>
#include <sys/wait.h>
int lxc_wait_for_pid_status(pid_t pid)
{
int status, ret;
again:
ret = waitpid(pid, &status, 0);
if (ret == -1) {
if (errno == EINTR)
goto again;
return -1;
}
if (ret != pid)
goto again;
return status;
}
//extern long lxc_config_parse_arch(const char *arch);
static VALUE Container; static VALUE Container;
static VALUE Error; static VALUE Error;
@ -98,24 +118,24 @@ free_c_string_array(char **arr)
* "personality", either +:linux32+ or +:linux+, for the 32-bit and 64-bit * "personality", either +:linux32+ or +:linux+, for the 32-bit and 64-bit
* architectures, respectively. * architectures, respectively.
*/ */
static VALUE //static VALUE
lxc_arch_to_personality(VALUE self, VALUE rb_arch) //lxc_arch_to_personality(VALUE self, VALUE rb_arch)
{ //{
int ret; // int ret;
char *arch; // char *arch;
//
arch = StringValuePtr(rb_arch); // arch = StringValuePtr(rb_arch);
ret = lxc_config_parse_arch(arch); // ret = lxc_config_parse_arch(arch);
//
switch (ret) { // switch (ret) {
case PER_LINUX32: // case PER_LINUX32:
return SYMBOL("linux32"); // return SYMBOL("linux32");
case PER_LINUX: // case PER_LINUX:
return SYMBOL("linux"); // return SYMBOL("linux");
default: // default:
rb_raise(Error, "unknown personality"); // rb_raise(Error, "unknown personality");
} // }
} //}
/* /*
* call-seq: * call-seq:
@ -2127,8 +2147,8 @@ Init_lxc(void)
{ {
VALUE LXC = rb_define_module("LXC"); VALUE LXC = rb_define_module("LXC");
rb_define_singleton_method(LXC, "arch_to_personality", //rb_define_singleton_method(LXC, "arch_to_personality",
lxc_arch_to_personality, 1); // lxc_arch_to_personality, 1);
rb_define_singleton_method(LXC, "run_command", lxc_run_command, 1); rb_define_singleton_method(LXC, "run_command", lxc_run_command, 1);
rb_define_singleton_method(LXC, "run_shell", lxc_run_shell, 0); rb_define_singleton_method(LXC, "run_shell", lxc_run_shell, 0);
rb_define_singleton_method(LXC, "global_config_item", rb_define_singleton_method(LXC, "global_config_item",