std::string real;
if (path.compare(0, 5, "/vfs/") != 0)
- throw DmException(EINVAL, "File not on the /vfs/ namespace");
+ vfsThrow(EINVAL, "file not on the /vfs/ namespace");
real = path.substr(4);
this->fd_ = ::open(real.c_str(), flags, mode);
+ syslog(LOG_DEBUG, "%s: open('%s', flags=%04X, mode=%04o) = %d", __func__, real.c_str(), flags, mode, this->fd_);
if (this->fd_ == -1)
- throw DmException(errno, "Could not open %s", path.c_str());
+ vfsThrowErrno("could not open %s)", path.c_str());
}
+std::string VfsIOHandler::getImplId() const throw()
+{
+ return "VfsIOHandler";
+
+}
+
+
+
void VfsIOHandler::close() throw (DmException)
{
::close(this->fd_);
size_t VfsIOHandler::read(char* buffer, size_t count) throw (DmException)
{
- size_t nbytes = ::read(this->fd_, buffer, count);
-
+ ssize_t ret;
+ size_t nbytes;
+
+ ret = ::read(this->fd_, buffer, count);
+
+ if (ret < 0)
+ vfsThrowErrno("error during reading");
+
+ nbytes = ret;
eof_ = (nbytes < count);
return nbytes;
size_t VfsIOHandler::write(const char* buffer, size_t count) throw (DmException)
{
- return ::write(this->fd_, buffer, count);
+ ssize_t nbytes = ::write(this->fd_, buffer, count);
+
+ if (nbytes < 0)
+ vfsThrowErrno("error during writing");
+
+ return nbytes;
}
void VfsIOHandler::seek(off_t offset, Whence whence) throw (DmException)
{
if ((pos_ = ::lseek(this->fd_, offset, whence)) == ((off_t) - 1))
- throw DmException(errno, "Could not seek (%d)", errno);
+ vfsThrowErrno("could not seek");
}