GDB (xrefs)
|
#include "gdbsupport/common-defs.h"
#include "nat/linux-namespaces.h"
#include "gdbsupport/filestuff.h"
#include <fcntl.h>
#include <sys/syscall.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/socket.h>
#include "gdbsupport/gdb_wait.h"
#include <signal.h>
#include <sched.h>
#include "gdbsupport/scope-exit.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 pid_t | do_fork (void) |
static int | do_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 | |
bool | debug_linux_namespaces |
static int | mnsh_creator_pid = 0 |
#define mnsh_return_fd | ( | sock, | |
fd, | |||
error ) |
Definition at line 497 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 494 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 503 of file linux-namespaces.c.
Referenced by mnsh_handle_readlink().
#define mnsh_send_open | ( | helper, | |
filename, | |||
flags, | |||
mode ) |
Definition at line 764 of file linux-namespaces.c.
Referenced by linux_mntns_open_cloexec().
#define mnsh_send_readlink | ( | helper, | |
filename ) |
Definition at line 772 of file linux-namespaces.c.
Referenced by linux_mntns_readlink().
#define mnsh_send_setns | ( | helper, | |
fd, | |||
nstype ) |
Definition at line 760 of file linux-namespaces.c.
Referenced by linux_mntns_access_fs().
#define mnsh_send_unlink | ( | helper, | |
filename ) |
Definition at line 768 of file linux-namespaces.c.
Referenced by linux_mntns_unlink().
#define MSG_CMSG_CLOEXEC 0 |
Definition at line 67 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 863 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 222 of file linux-namespaces.c.
|
inlinestatic |
Definition at line 39 of file linux-namespaces.c.
Referenced by linux_mntns_get_helper().
|
inlinestatic |
Definition at line 52 of file linux-namespaces.c.
Referenced by mnsh_handle_setns().
|
static |
Definition at line 881 of file linux-namespaces.c.
References linux_ns::id, linux_mntns_get_helper(), linux_ns_filename(), linux_ns_get_namespace(), LINUX_NS_MNT, MNSH_FS_DIRECT, MNSH_FS_ERROR, MNSH_FS_HELPER, mnsh_recv_int(), mnsh_send_setns, linux_mnsh::nsid, pid, and size.
Referenced by linux_mntns_open_cloexec(), linux_mntns_readlink(), and linux_mntns_unlink().
|
static |
Definition at line 638 of file linux-namespaces.c.
References debug_linux_namespaces, do_fork(), 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 951 of file linux-namespaces.c.
References flags, linux_mntns_access_fs(), linux_mntns_get_helper(), MNSH_FS_DIRECT, MNSH_FS_ERROR, MNSH_FS_HELPER, mnsh_recv_fd(), mnsh_send_open, pid, and size.
Referenced by linux_nat_target::fileio_open().
ssize_t linux_mntns_readlink | ( | pid_t | pid, |
const char * | filename, | ||
char * | buf, | ||
size_t | bufsiz ) |
Definition at line 1018 of file linux-namespaces.c.
References linux_mntns_access_fs(), linux_mntns_get_helper(), MNSH_FS_DIRECT, MNSH_FS_ERROR, MNSH_FS_HELPER, mnsh_recv_intstr(), mnsh_send_readlink, pid, and size.
Referenced by linux_nat_target::fileio_readlink().
int linux_mntns_unlink | ( | pid_t | pid, |
const char * | filename ) |
Definition at line 985 of file linux-namespaces.c.
References linux_mntns_access_fs(), linux_mntns_get_helper(), MNSH_FS_DIRECT, MNSH_FS_ERROR, MNSH_FS_HELPER, mnsh_recv_int(), mnsh_send_unlink, pid, and size.
Referenced by linux_nat_target::fileio_unlink().
|
static |
Definition at line 95 of file linux-namespaces.c.
References linux_ns::filename, and pid.
Referenced by linux_mntns_access_fs(), linux_ns_get_namespace(), and linux_ns_same().
|
static |
Definition at line 110 of file linux-namespaces.c.
References linux_ns::id, linux_ns::initialized, linux_ns_filename(), NUM_LINUX_NS_TYPES, linux_ns::supported, and type.
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 146 of file linux-namespaces.c.
References linux_ns::filename, linux_ns::id, linux_ns_filename(), linux_ns_get_namespace(), and pid.
Referenced by check_pid_namespace_match(), and linux_nat_target::filesystem_is_local().
|
static |
Definition at line 273 of file linux-namespaces.c.
References 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 520 of file linux-namespaces.c.
References flags, and mnsh_return_fd.
Referenced by mnsh_main().
|
static |
Definition at line 540 of file linux-namespaces.c.
References mnsh_return_intstr.
Referenced by mnsh_main().
|
static |
Definition at line 510 of file linux-namespaces.c.
References do_setns(), and mnsh_return_int.
Referenced by mnsh_main().
|
static |
Definition at line 530 of file linux-namespaces.c.
References mnsh_return_int.
Referenced by mnsh_main().
|
static |
Definition at line 555 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, mnsh_send_message(), size, and type.
Referenced by linux_mntns_get_helper().
|
static |
Definition at line 701 of file linux-namespaces.c.
References linux_mntns_get_helper(), mnsh_creator_pid, pid, linux_mnsh::pid, and status.
Referenced by mnsh_recv_message(), and mnsh_send_message().
|
static |
Definition at line 808 of file linux-namespaces.c.
References mnsh_recv_message(), MNSH_RET_FD, size, linux_mnsh::sock, and type.
Referenced by linux_mntns_open_cloexec().
|
static |
Definition at line 782 of file linux-namespaces.c.
References mnsh_recv_message(), MNSH_RET_INT, size, linux_mnsh::sock, and type.
Referenced by linux_mntns_access_fs(), and linux_mntns_unlink().
|
static |
Definition at line 840 of file linux-namespaces.c.
References mnsh_recv_message(), MNSH_RET_INTSTR, size, linux_mnsh::sock, and type.
Referenced by linux_mntns_readlink().
|
static |
Definition at line 412 of file linux-namespaces.c.
References debug_linux_namespaces, mnsh_debug_print_message(), mnsh_maybe_mourn_peer(), MSG_CMSG_CLOEXEC, size, and type.
Referenced by mnsh_main(), mnsh_recv_fd(), mnsh_recv_int(), and mnsh_recv_intstr().
|
static |
Definition at line 337 of file linux-namespaces.c.
References debug_linux_namespaces, mnsh_debug_print_message(), mnsh_maybe_mourn_peer(), size, and type.
Referenced by mnsh_main().
bool debug_linux_namespaces |
Definition at line 34 of file linux-namespaces.c.
Referenced by linux_mntns_get_helper(), mnsh_recv_message(), and mnsh_send_message().
|
static |
Definition at line 630 of file linux-namespaces.c.
Referenced by linux_mntns_get_helper(), and mnsh_maybe_mourn_peer().