Fixes to get the Mac OS X finder to behave.

This commit is contained in:
Jason Ferrara 2012-05-11 23:00:24 +00:00
parent 385417b93c
commit ec5dfac0f3
2 changed files with 33 additions and 1 deletions

View File

@ -19,6 +19,7 @@
* licensing@fsf.org
*/
#include "MtpFuseContext.h"
#include "mtpFilesystemErrors.h"
#include "MtpRoot.h"
MtpFuseContext::MtpFuseContext(std::unique_ptr<MtpDevice> device, uid_t uid, gid_t gid) :
@ -30,7 +31,9 @@ MtpFuseContext::MtpFuseContext(std::unique_ptr<MtpDevice> device, uid_t uid, gi
std::unique_ptr<MtpNode> MtpFuseContext::getNode(const FilesystemPath& path)
{
std::unique_ptr<MtpNode> root(new MtpRoot(*m_device, m_cache));
if (path.Head()=="/")
if (path.Head()!="/")
throw FileNotFound(path.str());
if (path.str()=="/")
return root;
else
return root->getNode(path.Body());

View File

@ -245,6 +245,32 @@ extern "C" int jmtpfs_statfs(const char *pathStr, struct statvfs *stat)
FUSE_ERROR_BLOCK_END
}
extern "C" int jmtpfs_chmod(const char* pathStr, mode_t mode)
{
FUSE_ERROR_BLOCK_START
FilesystemPath path(pathStr);
context->getNode(path);
// a noop since mtp doesn't support permissions. But we need to pretend
// to do it to make things like "cp -r" and the mac finder happy.
return 0;
FUSE_ERROR_BLOCK_END
}
extern "C" int jmtpfs_utime(const char* pathStr, struct utimbuf*)
{
FUSE_ERROR_BLOCK_START
FilesystemPath path(pathStr);
context->getNode(path);
// a noop since mtp doesn't support permissions. But we need to pretend
// to do it to make things like "cp -r" and the mac finder happy.
return 0;
FUSE_ERROR_BLOCK_END
}
struct jmtpfs_options
{
@ -294,6 +320,8 @@ int main(int argc, char *argv[])
jmtpfs_oper.flush = jmtpfs_flush;
jmtpfs_oper.rename = jmtpfs_rename;
jmtpfs_oper.statfs = jmtpfs_statfs;
jmtpfs_oper.chmod = jmtpfs_chmod;
jmtpfs_oper.utime = jmtpfs_utime;
jmtpfs_options options;
@ -435,6 +463,7 @@ int main(int argc, char *argv[])
#ifdef __APPLE__
fuse_opt_add_arg(&args, "-f");
std::cout << "Running in the background disabled because of an imcompatiblity between fork and libmtp under Max OS X" << std::endl;
fuse_opt_add_arg(&args, "-s"); // bug in fuse4x where multithreaded sometimes doesn't exit correctly.
#endif
int result = fuse_main(args.argc, args.argv, &jmtpfs_oper, context.get());