Browse Source

Merge pull request #1206 from trapexit/write-errs

Fix error handling for cached writes
pull/1207/head
trapexit 2 years ago
committed by GitHub
parent
commit
832903378e
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 21
      src/fuse_write.cpp

21
src/fuse_write.cpp

@ -22,18 +22,9 @@
#include "fs_movefile.hpp" #include "fs_movefile.hpp"
#include "fs_pwrite.hpp" #include "fs_pwrite.hpp"
#include "fs_pwriten.hpp" #include "fs_pwriten.hpp"
#include "ugid.hpp"
#include "fuse.h" #include "fuse.h"
#include <string>
#include <vector>
using std::string;
using std::vector;
typedef int (*WriteFunc)(const int,const void*,const size_t,const off_t);
namespace l namespace l
{ {
@ -70,7 +61,7 @@ namespace l
err = fs::dup2(rv,fi_->fd); err = fs::dup2(rv,fi_->fd);
fs::close(rv); fs::close(rv);
if(err < 0) if(err < 0)
return err;
return err_;
return fs::pwrite(fi_->fd,buf_,count_,offset_); return fs::pwrite(fi_->fd,buf_,count_,offset_);
} }
@ -101,7 +92,7 @@ namespace l
err = fs::dup2(rv,fi_->fd); err = fs::dup2(rv,fi_->fd);
fs::close(rv); fs::close(rv);
if(err < 0) if(err < 0)
return err;
return err_;
rv = fs::pwriten(fi_->fd, rv = fs::pwriten(fi_->fd,
buf_ + written_, buf_ + written_,
@ -111,7 +102,7 @@ namespace l
if(err < 0) if(err < 0)
return err; return err;
return (rv + written_);
return (written_ + rv);
} }
// When in direct_io mode write's return value should match that of // When in direct_io mode write's return value should match that of
@ -152,10 +143,8 @@ namespace l
ssize_t rv; ssize_t rv;
rv = fs::pwriten(fi_->fd,buf_,count_,offset_,&err); rv = fs::pwriten(fi_->fd,buf_,count_,offset_,&err);
if(rv == (ssize_t)count_)
return count_;
if(rv == 0)
return 0;
if(err == 0)
return rv;
if(err && !l::out_of_space(err)) if(err && !l::out_of_space(err))
return err; return err;

Loading…
Cancel
Save