Quantcast

Compile libfuse for android. Problem.

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Compile libfuse for android. Problem.

Paulo Ribeiro
Hi, I'm trying to compile libfuse for android, and mount the hello example. I successfully compiled the libfuse 2.9.3 as a SHARED LIBRARY, and then compiled hello example (replacing main with a ndk native function, that i call from java.) as a SHARED LIBRARY TO. When I try to run the example I get this error "fuse: failed to open /dev/fuse: Permission denied". Can anyone Help me?

If I try to build libfuse as a STATIC LIBRARY i get this error: "version node not found for symbol fuse_lowlevel_new@FUSE_2.5".  And the lib does not compile. I dont know why this only happen when BUILDING AS STATIC LIBRARY. I relly need to make this run, whitout root permission if possible. I need to mount a fuse FS in android from an APP for my Master Thesis.

More details about the Android.mk and other files here: https://github.com/libfuse/libfuse/issues/108

------------------------------------------------------------------------------
The Command Line: Reinvented for Modern Developers
Did the resurgence of CLI tooling catch you by surprise?
Reconnect with the command line and become more productive.
Learn the new .NET and ASP.NET CLI. Get your free copy!
http://sdm.link/telerik
--
fuse-devel mailing list
To unsubscribe or subscribe, visit https://lists.sourceforge.net/lists/listinfo/fuse-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Compile libfuse for android. Problem.

Paulo Ribeiro
I managed to resolve the "fuse: failed to open /dev/fuse: Permission denied" error. But now im getting logcat messages "type=1400 audit(0.0:213): avc: denied { read write } for name="fuse" dev="tmpfs" ino=7418 scontext=u:r:untrusted_app:s0 tcontext=u:object_r:fuse_device:s0 tclass=chr_file permissive=1" and "type=1400 audit(0.0:214): avc: denied { open } for name="fuse" dev="tmpfs" ino=7418 scontext=u:r:untrusted_app:s0 tcontext=u:object_r:fuse_device:s0 tclass=chr_file permissive=1".

they happen when running fuse_mount_sys that return -1(/* Maybe kernel doesn't support unprivileged mounts, in this case try falling back to fusermount*/) then the excution fall's back to fuse_mount_fusermount and this fails to (return -1), rv = receive_fd(fds[1]); :


static int receive_fd(int fd)
{
struct msghdr msg;
struct iovec iov;
char buf[1];
int rv;
size_t ccmsg[CMSG_SPACE(sizeof(int)) / sizeof(size_t)];
struct cmsghdr *cmsg;

iov.iov_base = buf;
iov.iov_len = 1;

memset(&msg, 0, sizeof(msg));
msg.msg_name = 0;
msg.msg_namelen = 0;
msg.msg_iov = &iov;
msg.msg_iovlen = 1;
/* old BSD implementations should use msg_accrights instead of
* msg_control; the interface is different. */
msg.msg_control = ccmsg;
msg.msg_controllen = sizeof(ccmsg);

while(((rv = recvmsg(fd, &msg, 0)) == -1) && errno == EINTR);
if (rv == -1) {
__android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, "\tperror(\"recvmsg\");");
perror("recvmsg");
return -1;
}
if(!rv) {
__android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, "\t/* EOF */");
/* EOF */
return -1;
}

cmsg = CMSG_FIRSTHDR(&msg);
if (cmsg->cmsg_type != SCM_RIGHTS) {
fprintf(stderr, "got control message of unknown type %d\n", cmsg->cmsg_type);
__android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, "got control message of unknown type %d\n", cmsg->cmsg_type);
return -1;
}
return *(int*)CMSG_DATA(cmsg);
}
It returns -1 here:
  if(!rv) {
__android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, "\t/* EOF */");
/* EOF */
return -1;
}

Can anyone help pls?



2016-10-29 15:56 GMT+01:00 Paulo Ribeiro <[hidden email]>:
Hi, I'm trying to compile libfuse for android, and mount the hello example. I successfully compiled the libfuse 2.9.3 as a SHARED LIBRARY, and then compiled hello example (replacing main with a ndk native function, that i call from java.) as a SHARED LIBRARY TO. When I try to run the example I get this error "fuse: failed to open /dev/fuse: Permission denied". Can anyone Help me?

If I try to build libfuse as a STATIC LIBRARY i get this error: "version node not found for symbol fuse_lowlevel_new@FUSE_2.5".  And the lib does not compile. I dont know why this only happen when BUILDING AS STATIC LIBRARY. I relly need to make this run, whitout root permission if possible. I need to mount a fuse FS in android from an APP for my Master Thesis.

More details about the Android.mk and other files here: https://github.com/libfuse/libfuse/issues/108


------------------------------------------------------------------------------
The Command Line: Reinvented for Modern Developers
Did the resurgence of CLI tooling catch you by surprise?
Reconnect with the command line and become more productive.
Learn the new .NET and ASP.NET CLI. Get your free copy!
http://sdm.link/telerik
--
fuse-devel mailing list
To unsubscribe or subscribe, visit https://lists.sourceforge.net/lists/listinfo/fuse-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Compile libfuse for android. Problem.

Michael Zimmermann
From your logs it looks like selinux doesn't allow apps to use fuse which means that you definitely need root.
That in turn means that you need to compile your fuse implementation as a binary which you pack into your apk and then extract and run because app's themselves can't run as root. 

On Sat, Oct 29, 2016 at 6:26 PM, Paulo Ribeiro <[hidden email]> wrote:
I managed to resolve the "fuse: failed to open /dev/fuse: Permission denied" error. But now im getting logcat messages "type=1400 audit(0.0:213): avc: denied { read write } for name="fuse" dev="tmpfs" ino=7418 scontext=u:r:untrusted_app:s0 tcontext=u:object_r:fuse_device:s0 tclass=chr_file permissive=1" and "type=1400 audit(0.0:214): avc: denied { open } for name="fuse" dev="tmpfs" ino=7418 scontext=u:r:untrusted_app:s0 tcontext=u:object_r:fuse_device:s0 tclass=chr_file permissive=1".

they happen when running fuse_mount_sys that return -1(/* Maybe kernel doesn't support unprivileged mounts, in this case try falling back to fusermount*/) then the excution fall's back to fuse_mount_fusermount and this fails to (return -1), rv = receive_fd(fds[1]); :


static int receive_fd(int fd)
{
struct msghdr msg;
struct iovec iov;
char buf[1];
int rv;
size_t ccmsg[CMSG_SPACE(sizeof(int)) / sizeof(size_t)];
struct cmsghdr *cmsg;

iov.iov_base = buf;
iov.iov_len = 1;

memset(&msg, 0, sizeof(msg));
msg.msg_name = 0;
msg.msg_namelen = 0;
msg.msg_iov = &iov;
msg.msg_iovlen = 1;
/* old BSD implementations should use msg_accrights instead of
* msg_control; the interface is different. */
msg.msg_control = ccmsg;
msg.msg_controllen = sizeof(ccmsg);

while(((rv = recvmsg(fd, &msg, 0)) == -1) && errno == EINTR);
if (rv == -1) {
__android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, "\tperror(\"recvmsg\");");
perror("recvmsg");
return -1;
}
if(!rv) {
__android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, "\t/* EOF */");
/* EOF */
return -1;
}

cmsg = CMSG_FIRSTHDR(&msg);
if (cmsg->cmsg_type != SCM_RIGHTS) {
fprintf(stderr, "got control message of unknown type %d\n", cmsg->cmsg_type);
__android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, "got control message of unknown type %d\n", cmsg->cmsg_type);
return -1;
}
return *(int*)CMSG_DATA(cmsg);
}
It returns -1 here:
  if(!rv) {
__android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, "\t/* EOF */");
/* EOF */
return -1;
}

Can anyone help pls?



2016-10-29 15:56 GMT+01:00 Paulo Ribeiro <[hidden email]>:
Hi, I'm trying to compile libfuse for android, and mount the hello example. I successfully compiled the libfuse 2.9.3 as a SHARED LIBRARY, and then compiled hello example (replacing main with a ndk native function, that i call from java.) as a SHARED LIBRARY TO. When I try to run the example I get this error "fuse: failed to open /dev/fuse: Permission denied". Can anyone Help me?

If I try to build libfuse as a STATIC LIBRARY i get this error: "version node not found for symbol fuse_lowlevel_new@FUSE_2.5".  And the lib does not compile. I dont know why this only happen when BUILDING AS STATIC LIBRARY. I relly need to make this run, whitout root permission if possible. I need to mount a fuse FS in android from an APP for my Master Thesis.

More details about the Android.mk and other files here: https://github.com/libfuse/libfuse/issues/108


------------------------------------------------------------------------------
The Command Line: Reinvented for Modern Developers
Did the resurgence of CLI tooling catch you by surprise?
Reconnect with the command line and become more productive.
Learn the new .NET and ASP.NET CLI. Get your free copy!
http://sdm.link/telerik
--
fuse-devel mailing list
To unsubscribe or subscribe, visit https://lists.sourceforge.net/lists/listinfo/fuse-devel



------------------------------------------------------------------------------
The Command Line: Reinvented for Modern Developers
Did the resurgence of CLI tooling catch you by surprise?
Reconnect with the command line and become more productive.
Learn the new .NET and ASP.NET CLI. Get your free copy!
http://sdm.link/telerik
--
fuse-devel mailing list
To unsubscribe or subscribe, visit https://lists.sourceforge.net/lists/listinfo/fuse-devel
Loading...