tor  0.4.0.0-alpha-dev
Functions
fdio.c File Reference
#include "orconfig.h"
#include "lib/fdio/fdio.h"
#include "lib/cc/torint.h"
#include "lib/err/torerr.h"
#include <stdlib.h>

Go to the source code of this file.

Macros

#define SEEK_SET   0
 
#define SEEK_CUR   1
 
#define SEEK_END   2
 

Functions

off_t tor_fd_getpos (int fd)
 
int tor_fd_seekend (int fd)
 
int tor_fd_setpos (int fd, off_t pos)
 
int tor_ftruncate (int fd)
 
int write_all_to_fd_minimal (int fd, const char *buf, size_t count)
 

Detailed Description

Low-level compatibility wrappers for fd-based IO.

Definition in file fdio.c.

Macro Definition Documentation

◆ SEEK_SET

#define SEEK_SET   0

Some old versions of Unix didn't define constants for these values, and instead expect you to say 0, 1, or 2.

Definition at line 31 of file fdio.c.

Referenced by tor_fd_setpos().

Function Documentation

◆ tor_fd_getpos()

off_t tor_fd_getpos ( int  fd)

Return the position of fd with respect to the start of the file.

Definition at line 43 of file fdio.c.

Referenced by log_tor_version().

◆ tor_fd_seekend()

int tor_fd_seekend ( int  fd)

Move fd to the end of the file. Return -1 on error, 0 on success. If the file is a pipe, do nothing and succeed.

Definition at line 56 of file fdio.c.

Referenced by add_file_log().

◆ tor_fd_setpos()

int tor_fd_setpos ( int  fd,
off_t  pos 
)

Move fd to position pos in the file. Return -1 on error, 0 on success.

Definition at line 75 of file fdio.c.

References SEEK_SET.

Referenced by tor_ftruncate().

◆ tor_ftruncate()

int tor_ftruncate ( int  fd)

Replacement for ftruncate(fd, 0): move to the front of the file and remove all the rest of the file. Return -1 on error, 0 on success.

Definition at line 87 of file fdio.c.

References tor_fd_setpos().

Referenced by truncate_logs().

◆ write_all_to_fd_minimal()

int write_all_to_fd_minimal ( int  fd,
const char *  buf,
size_t  count 
)

Minimal version of write_all, for use by logging.

Definition at line 103 of file fdio.c.

Referenced by log_tor_version().