/* Copyright (c) 2002-2018 Dovecot authors, see the included COPYING file */
/* @UNSAFE: whole file */
#include "lib.h"
#include "ioloop.h"
#include "istream-file-private.h"
#include "net.h"
#include <time.h>
#include <unistd.h>
#include <fcntl.h>
bool close_parent ATTR_UNUSED)
{
i_error("file_istream.close(%s) failed: %m",
}
}
}
{
"open(%s) failed: %m", path);
return -1;
}
return 0;
}
{
return -2;
if (i_stream_file_open(stream) < 0)
return -1;
}
/* don't try to read() again. EOF from keyboard (^D)
requires this to work right. */
ret = 0;
} else {
size);
}
if (ret == 0) {
/* EOF */
return -1;
}
ret = 0;
} else {
/* if we get EBADF for a valid fd, it means something's
really wrong and we'd better just crash. */
"pread(size=%"PRIuSIZE_T
} else {
size);
}
return -1;
}
}
ret = 0;
} else {
}
}
return ret;
}
bool mark ATTR_UNUSED)
{
i_panic("stream doesn't support seeking backwards");
}
}
{
/* can't do anything or data would be lost */
return;
}
}
static int
{
/* return defaults */
"file_istream.fstat(%s) failed: %m", name);
return -1;
}
} else {
"file_istream.stat(%s) failed: %m", name);
return -1;
}
}
return 0;
}
struct istream *
{
bool is_file;
int flags;
/* if it's a file, set the flags properly */
if (fd == -1) {
/* only the path is known for now - the fd is opened later */
else {
/* we're trying to open a directory.
we're not designed for it. */
"%s is a directory, can't read it as file",
}
if (is_file) {
/* shouldn't happen */
"fcntl(%d, F_GETFL) failed: %m", fd);
} else if ((flags & O_NONBLOCK) == 0) {
}
return input;
}
{
}
{
*fd = -1;
return input;
}
{
return input;
}