12#ifndef OPENVPN_COMMON_PERSISTFILE_H
13#define OPENVPN_COMMON_PERSISTFILE_H
37 const int f = ::open(
fn.c_str(), O_WRONLY | O_CREAT | O_CLOEXEC, S_IRUSR | S_IWUSR);
43 void write(
const void *buf,
size_t count)
45 const off_t off = ::lseek(
fd(), 0, SEEK_SET);
49 err(
"unexpected seek");
50 if (::ftruncate(
fd(), 0) < 0)
55 if (
static_cast<size_t>(len) != count || len != ::lseek(
fd(), 0, SEEK_CUR))
56 err(
"incomplete write");
57 if (::ftruncate(
fd(), len) < 0)
64 if (::fstat(
fd(), &s) < 0)
82 const int eno = errno;
86 void err(
const char *type)
const T * c_data() const
Returns a const pointer to the start of the buffer.
size_t size() const
Returns the size of the buffer in T objects.
void syserr(const char *type)
void err(const char *type)
void write(const Buffer &buf)
void write(const std::string &str)
PersistentFile(const std::string &fn_arg)
void write(const void *buf, size_t count)
void reset(const int fd_arg)
#define OPENVPN_THROW_EXCEPTION(stuff)
ssize_t write_retry(int fd, const void *buf, size_t count)
std::string strerror_str(const int errnum)
os<< "Session Name: "<< tbc-> session_name<< '\n';os<< "Layer: "<< tbc-> layer str()<< '\n'