GDBserver
|
#include "common-defs.h"
#include "nat/linux-namespaces.h"
#include "filestuff.h"
#include <fcntl.h>
#include <sys/syscall.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/socket.h>
#include "gdb_wait.h"
#include <signal.h>
#include <sched.h>
Go to the source code of this file.
Classes | |
struct | linux_ns |
struct | linux_mnsh |
Macros | |
#define | MSG_CMSG_CLOEXEC 0 |
#define | mnsh_return_int(sock, result, error) mnsh_send_message (sock, MNSH_RET_INT, -1, result, error, NULL, 0) |
#define | mnsh_return_fd(sock, fd, error) |
#define | mnsh_return_intstr(sock, result, buf, bufsiz, error) |
#define | mnsh_send_setns(helper, fd, nstype) |
#define | mnsh_send_open(helper, filename, flags, mode) |
#define | mnsh_send_unlink(helper, filename) |
#define | mnsh_send_readlink(helper, filename) |
Enumerations | |
enum | mnsh_msg_type { MNSH_MSG_ERROR, MNSH_REQ_SETNS, MNSH_REQ_OPEN, MNSH_REQ_UNLINK, MNSH_REQ_READLINK, MNSH_RET_INT, MNSH_RET_FD, MNSH_RET_INTSTR } |
enum | mnsh_fs_code { MNSH_FS_ERROR = -1, MNSH_FS_DIRECT, MNSH_FS_HELPER } |
Functions | |
static int | setns (int fd, int nstype) |
static const char * | linux_ns_filename (struct linux_ns *ns, int pid) |
static struct linux_ns * | linux_ns_get_namespace (enum linux_ns_type type) |
int | linux_ns_same (pid_t pid, enum linux_ns_type type) |
static void | mnsh_debug_print_message (enum mnsh_msg_type type, int fd, int int1, int int2, const void *buf, int bufsiz) |
static void | mnsh_maybe_mourn_peer (void) |
static ssize_t | mnsh_send_message (int sock, enum mnsh_msg_type type, int fd, int int1, int int2, const void *buf, int bufsiz) |
static ssize_t | mnsh_recv_message (int sock, enum mnsh_msg_type *type, int *fd, int *int1, int *int2, void *buf, int bufsiz) |
static ssize_t | mnsh_handle_setns (int sock, int fd, int nstype) |
static ssize_t | mnsh_handle_open (int sock, const char *filename, int flags, mode_t mode) |
static ssize_t | mnsh_handle_unlink (int sock, const char *filename) |
static ssize_t | mnsh_handle_readlink (int sock, const char *filename) |
static void | mnsh_main (int sock) ATTRIBUTE_NORETURN |
static struct linux_mnsh * | linux_mntns_get_helper (void) |
static int | mnsh_recv_int (struct linux_mnsh *helper, int *result, int *error) |
static int | mnsh_recv_fd (struct linux_mnsh *helper, int *fd, int *error) |
static ssize_t | mnsh_recv_intstr (struct linux_mnsh *helper, int *result, int *error, void *buf, int bufsiz) |
static enum mnsh_fs_code | linux_mntns_access_fs (pid_t pid) |
int | linux_mntns_open_cloexec (pid_t pid, const char *filename, int flags, mode_t mode) |
int | linux_mntns_unlink (pid_t pid, const char *filename) |
ssize_t | linux_mntns_readlink (pid_t pid, const char *filename, char *buf, size_t bufsiz) |
Variables | |
int | debug_linux_namespaces |
static int | mnsh_creator_pid = 0 |
#define mnsh_return_fd | ( | sock, | |
fd, | |||
error | |||
) |
Definition at line 483 of file linux-namespaces.c.
Referenced by mnsh_handle_open().
#define mnsh_return_int | ( | sock, | |
result, | |||
error | |||
) | mnsh_send_message (sock, MNSH_RET_INT, -1, result, error, NULL, 0) |
Definition at line 480 of file linux-namespaces.c.
Referenced by mnsh_handle_setns(), and mnsh_handle_unlink().
#define mnsh_return_intstr | ( | sock, | |
result, | |||
buf, | |||
bufsiz, | |||
error | |||
) |
Definition at line 489 of file linux-namespaces.c.
Referenced by mnsh_handle_readlink().
#define mnsh_send_open | ( | helper, | |
filename, | |||
flags, | |||
mode | |||
) |
Definition at line 758 of file linux-namespaces.c.
Referenced by linux_mntns_open_cloexec().
#define mnsh_send_readlink | ( | helper, | |
filename | |||
) |
Definition at line 766 of file linux-namespaces.c.
Referenced by linux_mntns_readlink().
#define mnsh_send_setns | ( | helper, | |
fd, | |||
nstype | |||
) |
Definition at line 754 of file linux-namespaces.c.
Referenced by linux_mntns_access_fs().
#define mnsh_send_unlink | ( | helper, | |
filename | |||
) |
Definition at line 762 of file linux-namespaces.c.
Referenced by linux_mntns_unlink().
#define MSG_CMSG_CLOEXEC 0 |
Definition at line 53 of file linux-namespaces.c.
Referenced by mnsh_recv_message().
enum mnsh_fs_code |
Enumerator | |
---|---|
MNSH_FS_ERROR | |
MNSH_FS_DIRECT | |
MNSH_FS_HELPER |
Definition at line 857 of file linux-namespaces.c.
enum mnsh_msg_type |
Enumerator | |
---|---|
MNSH_MSG_ERROR | |
MNSH_REQ_SETNS | |
MNSH_REQ_OPEN | |
MNSH_REQ_UNLINK | |
MNSH_REQ_READLINK | |
MNSH_RET_INT | |
MNSH_RET_FD | |
MNSH_RET_INTSTR |
Definition at line 208 of file linux-namespaces.c.
|
static |
Definition at line 875 of file linux-namespaces.c.
References do_cleanups(), errno, error(), gdb_open_cloexec(), linux_ns::id, linux_mntns_get_helper(), linux_ns_filename(), linux_ns_get_namespace(), LINUX_NS_MNT, make_cleanup(), make_cleanup_close(), MNSH_FS_DIRECT, MNSH_FS_ERROR, MNSH_FS_HELPER, mnsh_recv_int(), mnsh_send_setns, linux_mnsh::nsid, and null_cleanup().
Referenced by linux_mntns_open_cloexec(), linux_mntns_readlink(), and linux_mntns_unlink().
|
static |
Definition at line 629 of file linux-namespaces.c.
References debug_linux_namespaces, debug_printf(), errno, gdb_socketpair_cloexec(), linux_ns::id, linux_ns_get_namespace(), LINUX_NS_MNT, mnsh_creator_pid, mnsh_main(), linux_mnsh::nsid, linux_mnsh::pid, and linux_mnsh::sock.
Referenced by linux_mntns_access_fs(), linux_mntns_open_cloexec(), linux_mntns_readlink(), linux_mntns_unlink(), and mnsh_maybe_mourn_peer().
int linux_mntns_open_cloexec | ( | pid_t | pid, |
const char * | filename, | ||
int | flags, | ||
mode_t | mode | ||
) |
Definition at line 957 of file linux-namespaces.c.
References errno, error(), gdb_assert, gdb_open_cloexec(), linux_mntns_access_fs(), linux_mntns_get_helper(), MNSH_FS_DIRECT, MNSH_FS_ERROR, MNSH_FS_HELPER, mnsh_recv_fd(), and mnsh_send_open.
ssize_t linux_mntns_readlink | ( | pid_t | pid, |
const char * | filename, | ||
char * | buf, | ||
size_t | bufsiz | ||
) |
Definition at line 1024 of file linux-namespaces.c.
References errno, error(), gdb_assert, linux_mntns_access_fs(), linux_mntns_get_helper(), MNSH_FS_DIRECT, MNSH_FS_ERROR, MNSH_FS_HELPER, mnsh_recv_intstr(), and mnsh_send_readlink.
int linux_mntns_unlink | ( | pid_t | pid, |
const char * | filename | ||
) |
Definition at line 991 of file linux-namespaces.c.
References errno, error(), gdb_assert, linux_mntns_access_fs(), linux_mntns_get_helper(), MNSH_FS_DIRECT, MNSH_FS_ERROR, MNSH_FS_HELPER, mnsh_recv_int(), and mnsh_send_unlink.
|
static |
Definition at line 81 of file linux-namespaces.c.
References linux_ns::filename, gdb_assert, and xsnprintf().
Referenced by linux_mntns_access_fs(), linux_ns_get_namespace(), and linux_ns_same().
|
static |
Definition at line 96 of file linux-namespaces.c.
References gdb_assert, linux_ns::id, linux_ns::initialized, linux_ns_filename(), and linux_ns::supported.
Referenced by linux_mntns_access_fs(), linux_mntns_get_helper(), and linux_ns_same().
int linux_ns_same | ( | pid_t | pid, |
enum linux_ns_type | type | ||
) |
Definition at line 132 of file linux-namespaces.c.
References linux_ns::filename, linux_ns::id, linux_ns_filename(), linux_ns_get_namespace(), and perror_with_name().
|
static |
Definition at line 259 of file linux-namespaces.c.
References debug_printf(), MNSH_MSG_ERROR, MNSH_REQ_OPEN, MNSH_REQ_READLINK, MNSH_REQ_SETNS, MNSH_REQ_UNLINK, MNSH_RET_FD, MNSH_RET_INT, and MNSH_RET_INTSTR.
Referenced by mnsh_recv_message(), and mnsh_send_message().
|
static |
Definition at line 506 of file linux-namespaces.c.
References errno, gdb_open_cloexec(), and mnsh_return_fd.
Referenced by mnsh_main().
|
static |
Definition at line 531 of file linux-namespaces.c.
References errno, and mnsh_return_intstr.
Referenced by mnsh_main().
|
static |
Definition at line 496 of file linux-namespaces.c.
References errno, mnsh_return_int, and setns().
Referenced by mnsh_main().
|
static |
Definition at line 521 of file linux-namespaces.c.
References errno, and mnsh_return_int.
Referenced by mnsh_main().
|
static |
Definition at line 546 of file linux-namespaces.c.
References mnsh_handle_open(), mnsh_handle_readlink(), mnsh_handle_setns(), mnsh_handle_unlink(), MNSH_MSG_ERROR, mnsh_recv_message(), MNSH_REQ_OPEN, MNSH_REQ_READLINK, MNSH_REQ_SETNS, MNSH_REQ_UNLINK, and mnsh_send_message().
Referenced by linux_mntns_get_helper().
|
static |
Definition at line 692 of file linux-namespaces.c.
References _, errno, internal_warning(), linux_mntns_get_helper(), mnsh_creator_pid, linux_mnsh::pid, warning(), WEXITSTATUS, WIFEXITED, WIFSIGNALED, WNOHANG, and WTERMSIG.
Referenced by mnsh_recv_message(), and mnsh_send_message().
|
static |
Definition at line 802 of file linux-namespaces.c.
References gdb_assert, mnsh_recv_message(), MNSH_RET_FD, and linux_mnsh::sock.
Referenced by linux_mntns_open_cloexec().
|
static |
Definition at line 776 of file linux-namespaces.c.
References gdb_assert, mnsh_recv_message(), MNSH_RET_INT, and linux_mnsh::sock.
Referenced by linux_mntns_access_fs(), and linux_mntns_unlink().
|
static |
Definition at line 834 of file linux-namespaces.c.
References gdb_assert, mnsh_recv_message(), MNSH_RET_INTSTR, and linux_mnsh::sock.
Referenced by linux_mntns_readlink().
|
static |
Definition at line 398 of file linux-namespaces.c.
References debug_linux_namespaces, debug_printf(), errno, mnsh_debug_print_message(), mnsh_maybe_mourn_peer(), MSG_CMSG_CLOEXEC, and pulongest().
Referenced by mnsh_main(), mnsh_recv_fd(), mnsh_recv_int(), and mnsh_recv_intstr().
|
static |
Definition at line 323 of file linux-namespaces.c.
References alloca(), debug_linux_namespaces, debug_printf(), mnsh_debug_print_message(), mnsh_maybe_mourn_peer(), and pulongest().
Referenced by mnsh_main().
|
static |
Definition at line 39 of file linux-namespaces.c.
References errno.
Referenced by mnsh_handle_setns().
int debug_linux_namespaces |
Definition at line 33 of file linux-namespaces.c.
Referenced by linux_mntns_get_helper(), mnsh_recv_message(), and mnsh_send_message().
|
static |
Definition at line 621 of file linux-namespaces.c.
Referenced by linux_mntns_get_helper(), and mnsh_maybe_mourn_peer().