From 63035618f82ee9b2fc8e6618ea6e43213efada10 Mon Sep 17 00:00:00 2001 From: Peter Hatina Date: Tue, 24 Sep 2013 21:55:26 +0200 Subject: [PATCH] rewrite SMTPFileSystem::open() --- src/simple-mtpfs-fuse.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/simple-mtpfs-fuse.cpp b/src/simple-mtpfs-fuse.cpp index b6fd643..e51c174 100644 --- a/src/simple-mtpfs-fuse.cpp +++ b/src/simple-mtpfs-fuse.cpp @@ -596,13 +596,18 @@ int SMTPFileSystem::open(const char *path, struct fuse_file_info *file_info) std::string tmp_file = m_tmp_files_pool.makeTmpPath(std::string(path)); int rval = m_device.filePull(std::string(path), tmp_file); - if (rval != 0) - return rval; + if (rval != 0) { + errno = rval; + return -1; + } + int fd = ::open(tmp_file.c_str(), file_info->flags); if (fd < 0) - return -errno; + return -1; + file_info->fh = fd; m_tmp_files_pool.addFile(TypeTmpFile(std::string(path), tmp_file, fd)); + return 0; }