mirror of
https://github.com/vgough/encfs.git
synced 2024-11-21 23:43:26 +01:00
Check (not entirely yet) read and write return codes
This commit is contained in:
parent
5c90ad451e
commit
3cd97c3568
@ -2,7 +2,11 @@ dist: trusty
|
||||
|
||||
language: cpp
|
||||
|
||||
sudo: true
|
||||
sudo: required
|
||||
|
||||
env:
|
||||
global:
|
||||
- SUDO_MOUNT=sudo
|
||||
|
||||
os:
|
||||
- linux
|
||||
|
@ -202,11 +202,13 @@ ssize_t RawFileIO::read(const IORequest &req) const {
|
||||
rAssert(fd >= 0);
|
||||
|
||||
ssize_t readSize = pread(fd, req.data, req.dataLen, req.offset);
|
||||
int eno = errno;
|
||||
errno = 0; //just to be sure error seen in integration tests really comes from the function rc.
|
||||
|
||||
if (readSize < 0) {
|
||||
readSize = -errno;
|
||||
RLOG(WARNING) << "read failed at offset " << req.offset << " for "
|
||||
<< req.dataLen << " bytes: " << strerror(-readSize);
|
||||
<< req.dataLen << " bytes: " << strerror(eno);
|
||||
return -eno;
|
||||
}
|
||||
|
||||
return readSize;
|
||||
@ -226,6 +228,7 @@ ssize_t RawFileIO::write(const IORequest &req) {
|
||||
errno = 0;
|
||||
ssize_t writeSize = ::pwrite(fd, buf, bytes, offset);
|
||||
eno = errno;
|
||||
errno = 0; //just to be sure error seen in integration tests really comes from the function rc.
|
||||
|
||||
if (writeSize < 0) {
|
||||
knownSize = false;
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
# Test EncFS normal and paranoid mode
|
||||
|
||||
use Test::More tests => 122;
|
||||
use Test::More tests => 132;
|
||||
use File::Path;
|
||||
use File::Copy;
|
||||
use File::Temp;
|
||||
@ -78,6 +78,8 @@ sub runTests
|
||||
&grow;
|
||||
&umask0777;
|
||||
&create_unmount_remount;
|
||||
&checkReadError;
|
||||
&checkWriteError;
|
||||
|
||||
&configFromPipe;
|
||||
&cleanup;
|
||||
@ -430,3 +432,38 @@ sub create_unmount_remount
|
||||
|
||||
portable_unmount($mnt);
|
||||
}
|
||||
|
||||
# Test that read errors are correctly thrown up to us
|
||||
sub checkReadError
|
||||
{
|
||||
# Not sure how to implement this, so feel free !
|
||||
ok(1, "read error");
|
||||
}
|
||||
|
||||
# Test that write errors are correctly thrown up to us
|
||||
sub checkWriteError
|
||||
{
|
||||
# Not sure how to implement this on Mac OS, so feel free !
|
||||
if($^O eq "darwin") {
|
||||
ok(1, "write error");
|
||||
ok(1, "write error");
|
||||
ok(1, "write error");
|
||||
ok(1, "write error");
|
||||
}
|
||||
else {
|
||||
my $crypt = "$workingDir/checkWriteError.crypt";
|
||||
my $mnt = "$workingDir/checkWriteError.mnt";
|
||||
mkdir($crypt) || BAIL_OUT($!);
|
||||
mkdir($mnt) || BAIL_OUT($!);
|
||||
system(($ENV{'SUDO_MOUNT'}||"")." mount -t tmpfs -o size=1m tmpfs $crypt");
|
||||
ok( $? == 0, "mount command returns 0") || return;
|
||||
system("./build/encfs --standard --extpass=\"echo test\" $crypt $mnt 2>&1");
|
||||
ok( $? == 0, "encfs command returns 0") || return;
|
||||
ok(open(OUT , "> $mnt/file"), "write content");
|
||||
while(print OUT "0123456789") {}
|
||||
ok ($!{ENOSPC}, "write returned $! instead of ENOSPC");
|
||||
close OUT;
|
||||
portable_unmount($mnt);
|
||||
system(($ENV{'SUDO_MOUNT'}||"")." umount $crypt");
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user