Rizin
unix-like reverse engineering framework and cli tools
|
I/O types and functions. More...
Go to the source code of this file.
Classes | |
union | io_buf |
struct | file_pair |
Macros | |
#define | IO_BUFFER_SIZE 8192 |
Functions | |
void | io_init (void) |
Initialize the I/O module. More... | |
void | io_write_to_user_abort_pipe (void) |
Write a byte to user_abort_pipe[1]. More... | |
void | io_no_sparse (void) |
Disable creation of sparse files when decompressing. More... | |
file_pair * | io_open_src (const char *src_name) |
Open the source file. More... | |
bool | io_open_dest (file_pair *pair) |
Open the destination file. More... | |
void | io_close (file_pair *pair, bool success) |
Closes the file descriptors and frees possible allocated memory. More... | |
size_t | io_read (file_pair *pair, io_buf *buf, size_t size) |
Reads from the source file to a buffer. More... | |
void | io_fix_src_pos (file_pair *pair, size_t rewind_size) |
Fix the position in src_fd. More... | |
bool | io_pread (file_pair *pair, io_buf *buf, size_t size, off_t pos) |
Read from source file from given offset to a buffer. More... | |
bool | io_write (file_pair *pair, const io_buf *buf, size_t size) |
Writes a buffer to the destination file. More... | |
I/O types and functions.
Definition in file file_io.h.
Closes the file descriptors and frees possible allocated memory.
The success argument determines if source or destination file gets unlinked:
Definition at line 1052 of file file_io.c.
References _, file_pair::dest_fd, file_pair::dest_name, file_pair::dest_pending_sparse, file_pair::dest_try_sparse, io_close_dest(), io_close_src(), io_copy_attrs(), io_write_buf(), lseek, message_error(), SEEK_CUR, signals_block(), signals_unblock(), and STDOUT_FILENO.
Referenced by coder_run(), and list_file().
Fix the position in src_fd.
This is used when –single-thream has been specified and decompression is successful. If the input file descriptor supports seeking, this function fixes the input position to point to the next byte after the decompressed stream.
pair | File pair having the source file open for reading |
rewind_size | How many bytes of extra have been read i.e. how much to seek backwards. |
Definition at line 1101 of file file_io.c.
References assert(), IO_BUFFER_SIZE, lseek, SEEK_CUR, and file_pair::src_fd.
Referenced by coder_normal().
void io_init | ( | void | ) |
Initialize the I/O module.
Definition at line 95 of file file_io.c.
References _, E_ERROR, F_GETFL, F_SETFL, fcntl, flags, i, message_fatal(), O_NONBLOCK, pipe, tuklib_open_stdxxx(), user_abort_pipe, and warn_fchown.
Referenced by main().
void io_no_sparse | ( | void | ) |
Disable creation of sparse files when decompressing.
Definition at line 151 of file file_io.c.
References try_sparse.
Referenced by parse_real().
Open the destination file.
Definition at line 991 of file file_io.c.
References io_open_dest_real(), signals_block(), and signals_unblock().
Referenced by coder_run().
Open the source file.
Definition at line 741 of file file_io.c.
References error(), io_open_src_real(), is_empty_filename(), NULL, signals_block(), signals_unblock(), file_pair::src_fd, and file_pair::src_name.
Referenced by coder_run(), and list_file().
Read from source file from given offset to a buffer.
This is remotely similar to standard pread(). This uses lseek() though, so the read offset is changed on each call.
pair | Seekable source file |
buf | Destination buffer |
size | Amount of data to read |
pos | Offset relative to the beginning of the file, from which the data should be read. |
Definition at line 1186 of file file_io.c.
References _, io_read(), lseek, message_error(), pos, SEEK_SET, SIZE_MAX, file_pair::src_fd, and file_pair::src_name.
Referenced by parse_block_header(), parse_check_value(), and parse_indexes().
Reads from the source file to a buffer.
pair | File pair having the source file open for reading |
buf | Destination buffer to hold the read data |
size | Size of the buffer; assumed be smaller than SSIZE_MAX |
Definition at line 1116 of file file_io.c.
References _, assert(), EINTR, file_pair::flush_needed, io_wait(), IO_WAIT_ERROR, IO_WAIT_MORE, IO_WAIT_TIMEOUT, IS_EAGAIN_OR_EWOULDBLOCK, message_bug(), message_error(), mytime_get_flush_timeout(), mytime_set_flush_time(), pos, read(), SIZE_MAX, file_pair::src_eof, file_pair::src_fd, file_pair::src_has_seen_input, file_pair::src_name, SSIZE_MAX, timeout, and user_abort.
Referenced by coder_normal(), coder_passthru(), coder_run(), and io_pread().
Writes a buffer to the destination file.
pair | File pair having the destination file open for writing |
buf | Buffer containing the data to be written |
size | Size of the buffer; assumed be smaller than SSIZE_MAX |
Definition at line 1275 of file file_io.c.
References _, assert(), CHAR_BIT, file_pair::dest_fd, file_pair::dest_name, file_pair::dest_pending_sparse, file_pair::dest_try_sparse, IO_BUFFER_SIZE, io_write_buf(), is_sparse(), lseek, message_error(), and SEEK_CUR.
Referenced by coder_passthru(), and coder_write_output().
void io_write_to_user_abort_pipe | ( | void | ) |
Write a byte to user_abort_pipe[1].
This is called from a signal handler.
Definition at line 135 of file file_io.c.
References b, user_abort_pipe, and write.
Referenced by signal_handler().