GDBserver

Classes | Macros | Functions | Variables
hostio.c File Reference
`#include "server.h"`
`#include "gdb/fileio.h"`
`#include "hostio.h"`
`#include <fcntl.h>`
`#include <limits.h>`
`#include <unistd.h>`
`#include <sys/types.h>`
`#include <sys/stat.h>`
`#include "fileio.h"`

Go to the source code of this file.

## Classes
struct | fd_list

## Macros
#define | HOSTIO_PATH_MAX (PBUFSIZ / 2 + 1)

## Functions
static int | safe_fromhex (char a, int *nibble)
static int | require_filename (char **pp, char *filename)
static int | require_int (char **pp, int *value)
static int | require_data (char *p, int p_len, char **data, int *data_len)
static int | require_comma (char **pp)
static int | require_end (char *p)
static int | require_valid_fd (int fd)
static void | hostio_error (char *own_buf)
static void | hostio_packet_error (char *own_buf)
static void | hostio_reply (char *own_buf, int result)
static int | hostio_reply_with_data (char *own_buf, char *buffer, int len, int *new_packet_len)
void | hostio_handle_new_gdb_connection (void)
static void | handle_setfs (char *own_buf)
static void | handle_open (char *own_buf)
static void | handle_pread (char *own_buf, int *new_packet_len)
static void | handle_pwrite (char *own_buf, int packet_len)
static void | handle_fstat (char *own_buf, int *new_packet_len)
static void | handle_close (char *own_buf)
static void | handle_unlink (char *own_buf)
static void | handle_readlink (char *own_buf, int *new_packet_len)
int | handle_vFile (char *own_buf, int packet_len, int *new_packet_len)

## Variables
int | remote_debug
static struct fd_list * | open_fds
static int | hostio_fs_pid

## Macro Definition Documentation

## ◆ HOSTIO_PATH_MAX

#define HOSTIO_PATH_MAX (PBUFSIZ / 2 + 1)

Definition at line 60 of file hostio.c.

Referenced by handle_open(), handle_readlink(), handle_unlink(), and require_filename().

## Function Documentation

## ◆ handle_close()

static void handle_close | ( | char * | own_buf | ) |
| static

Definition at line 489 of file hostio.c.

References fd_list::fd, free(), hostio_error(), hostio_packet_error(), hostio_reply(), fd_list::next, open_fds, own_buf, require_end(), require_int(), and require_valid_fd().

Referenced by handle_vFile().

## ◆ handle_fstat()

static void handle_fstat | ( | char * | own_buf,
|  | int * | new_packet_len
| ) |  |
| static

Definition at line 453 of file hostio.c.

References fd_list::fd, host_to_fileio_stat(), hostio_error(), hostio_packet_error(), hostio_reply_with_data(), own_buf, require_end(), require_int(), require_valid_fd(), and write_enn().

Referenced by handle_vFile().

## ◆ handle_open()

static void handle_open | ( | char * | own_buf | ) |
| static

Definition at line 296 of file hostio.c.

References fd_list::fd, fileio_to_host_mode(), fileio_to_host_openflags(), hostio_error(), hostio_fs_pid, hostio_packet_error(), HOSTIO_PATH_MAX, hostio_reply(), target_ops::multifs_open, fd_list::next, open_fds, own_buf, require_comma(), require_end(), require_filename(), require_int(), the_target, and XNEW.

Referenced by handle_vFile().

## ◆ handle_pread()

static void handle_pread | ( | char * | own_buf,
|  | int * | new_packet_len
| ) |  |
| static

Definition at line 343 of file hostio.c.

References fd_list::fd, free(), hostio_error(), hostio_packet_error(), hostio_reply_with_data(), offset, own_buf, PBUFSIZ, require_comma(), require_end(), require_int(), require_valid_fd(), and xmalloc().

Referenced by handle_vFile().

## ◆ handle_pwrite()

static void handle_pwrite | ( | char * | own_buf,
|  | int | packet_len
| ) |  |
| static

Definition at line 410 of file hostio.c.

References fd_list::fd, free(), hostio_error(), hostio_packet_error(), hostio_reply(), offset, own_buf, require_comma(), require_data(), require_int(), and require_valid_fd().

Referenced by handle_vFile().

## ◆ handle_readlink()

static void handle_readlink | ( | char * | own_buf,
|  | int * | new_packet_len
| ) |  |
| static

Definition at line 556 of file hostio.c.

References hostio_error(), hostio_fs_pid, hostio_packet_error(), HOSTIO_PATH_MAX, hostio_reply_with_data(), target_ops::multifs_readlink, own_buf, require_end(), require_filename(), and the_target.

Referenced by handle_vFile().

## ◆ handle_setfs()

static void handle_setfs | ( | char * | own_buf | ) |
| static

Definition at line 263 of file hostio.c.

References hostio_fs_pid, hostio_packet_error(), hostio_reply(), target_ops::multifs_open, target_ops::multifs_readlink, target_ops::multifs_unlink, own_buf, require_end(), require_int(), and the_target.

Referenced by handle_vFile().

## ◆ handle_unlink()

static void handle_unlink | ( | char * | own_buf | ) |
| static

Definition at line 526 of file hostio.c.

References hostio_error(), hostio_fs_pid, hostio_packet_error(), HOSTIO_PATH_MAX, hostio_reply(), target_ops::multifs_unlink, own_buf, require_end(), require_filename(), and the_target.

Referenced by handle_vFile().

## ◆ handle_vFile()

int handle_vFile | ( | char * | own_buf,
|  | int | packet_len,
|  | int * | new_packet_len
| ) |  |

Definition at line 595 of file hostio.c.

References handle_close(), handle_fstat(), handle_open(), handle_pread(), handle_pwrite(), handle_readlink(), handle_setfs(), handle_unlink(), own_buf, and startswith().

Referenced by handle_v_requests().

## ◆ hostio_error()

static void hostio_error | ( | char * | own_buf | ) |
| static

Definition at line 194 of file hostio.c.

References target_ops::hostio_last_error, own_buf, and the_target.

Referenced by handle_close(), handle_fstat(), handle_open(), handle_pread(), handle_pwrite(), handle_readlink(), and handle_unlink().

## ◆ hostio_handle_new_gdb_connection()

void hostio_handle_new_gdb_connection | ( | void |  | ) |

Definition at line 255 of file hostio.c.

References hostio_fs_pid.

Referenced by handle_query().

## ◆ hostio_packet_error()

static void hostio_packet_error | ( | char * | own_buf | ) |
| static

Definition at line 200 of file hostio.c.

References own_buf.

Referenced by handle_close(), handle_fstat(), handle_open(), handle_pread(), handle_pwrite(), handle_readlink(), handle_setfs(), and handle_unlink().

## ◆ hostio_reply()

static void hostio_reply | ( | char * | own_buf,
|  | int | result
| ) |  |
| static

Definition at line 206 of file hostio.c.

References own_buf.

Referenced by handle_close(), handle_open(), handle_pwrite(), handle_setfs(), and handle_unlink().

## ◆ hostio_reply_with_data()

static int hostio_reply_with_data | ( | char * | own_buf,
|  | char * | buffer,
|  | int | len,
|  | int * | new_packet_len
| ) |  |
| static

Definition at line 212 of file hostio.c.

References own_buf, and PBUFSIZ.

Referenced by handle_fstat(), handle_pread(), and handle_readlink().

## ◆ require_comma()

static int require_comma | ( | char ** | pp | ) |
| static

Definition at line 159 of file hostio.c.

Referenced by handle_open(), handle_pread(), and handle_pwrite().

## ◆ require_data()

static int require_data | ( | char * | p,
|  | int | p_len,
|  | char ** | data,
|  | int * | data_len
| ) |  |
| static

Definition at line 125 of file hostio.c.

References free(), and xmalloc().

Referenced by handle_pwrite().

## ◆ require_end()

static int require_end | ( | char * | p | ) |
| static

Definition at line 171 of file hostio.c.

Referenced by handle_close(), handle_fstat(), handle_open(), handle_pread(), handle_readlink(), handle_setfs(), and handle_unlink().

## ◆ require_filename()

static int require_filename | ( | char ** | pp,
|  | char * | filename
| ) |  |
| static

Definition at line 66 of file hostio.c.

References HOSTIO_PATH_MAX, and safe_fromhex().

Referenced by handle_open(), handle_readlink(), and handle_unlink().

## ◆ require_int()

static int require_int | ( | char ** | pp,
|  | int * | value
| ) |  |
| static

Definition at line 96 of file hostio.c.

References safe_fromhex().

Referenced by handle_close(), handle_fstat(), handle_open(), handle_pread(), handle_pwrite(), and handle_setfs().

## ◆ require_valid_fd()

static int require_valid_fd | ( | int | fd | ) |
| static

Definition at line 180 of file hostio.c.

References fd_list::fd, fd_list::next, and open_fds.

Referenced by handle_close(), handle_fstat(), handle_pread(), and handle_pwrite().

## ◆ safe_fromhex()

static int safe_fromhex | ( | char | a,
|  | int * | nibble
| ) |  |
| static

Definition at line 43 of file hostio.c.

Referenced by require_filename(), and require_int().

## Variable Documentation

## ◆ hostio_fs_pid

int hostio_fs_pid
| static

Definition at line 250 of file hostio.c.

Referenced by handle_open(), handle_readlink(), handle_setfs(), handle_unlink(), and hostio_handle_new_gdb_connection().

## ◆ open_fds

struct fd_list* open_fds
| static

Definition at line 40 of file hostio.c.

Referenced by handle_close(), handle_open(), and require_valid_fd().

## ◆ remote_debug

int remote_debug

Definition at line 106 of file remote-utils.c.

Referenced by handle_notif_ack(), and notif_event_enque().