Commit ddbbf8c0 authored by Ciarán Ó Rourke's avatar Ciarán Ó Rourke
Browse files

New Phobos version working

parent fbd7fb1c
......@@ -203,6 +203,44 @@ static int pho_posix_set_addr(const char *id, const char *tag,
}
}
/**
* read/write wrapper
*
* support for pipe I/O
*/
static int pho_posix_read_write(int tgt_fd, int src_fd, size_t count)
{
ssize_t r = 0;
ssize_t w = 0;
char *buf = malloc(count);
while (count > 0) {
r = read(src_fd, buf, count);
if (r < 0)
LOG_RETURN(-errno, "read failure");
else {
w = write(tgt_fd, buf, r);
if (w < 0)
LOG_RETURN(-errno, "write failure");
}
if (count && (r == 0 || w == 0))
LOG_RETURN(-ENOBUFS,
"read/write failure, reached source fd eof too soon");
if (r == w) {
pho_debug("read/write returned after copying %zd bytes. %zd bytes left",
r, count - r);
}
else {
LOG_RETURN(-ENOBUFS,
"read/write failure, read and write count mismatch");
}
count -=r;
}
free(buf);
return 0;
}
/**
* Sendfile wrapper
* @TODO fallback to (p)read/(p)write
......@@ -218,8 +256,15 @@ static int pho_posix_sendfile(int tgt_fd, int src_fd, size_t count)
while (count > 0) {
rw = sendfile(tgt_fd, src_fd, NULL, count);
if (rw < 0)
LOG_RETURN(-errno, "sendfile failure");
if (rw < 0) {
if (errno == EINVAL || errno == ENOSYS) {
errno = 0;
rw = pho_posix_read_write(tgt_fd, src_fd, count);
return rw;
}
else
LOG_RETURN(-errno, "sendfile failure");
}
if (count && rw == 0)
LOG_RETURN(-ENOBUFS,
......
......@@ -49,6 +49,7 @@ sed -i '/lrs/ a default_family = dir' /etc/phobos.conf
make install
cd ${phobos_dir}/src/cli && python setup.py install
phobosd
mkdir /tmp/phobos_test
phobos dir add --unlock /tmp/phobos_test
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment