Android-x86
Fork
Spenden

  • R/O
  • HTTP
  • SSH
  • HTTPS

external-ntfs-3g: Commit

external/ntfs-3g


Commit MetaInfo

Revision1f0d87606fe1ac80aedd99a6484bed4c5f5b74b2 (tree)
Zeit2014-04-18 15:25:13
AutorChih-Wei Huang <cwhuang@linu...>
CommiterChih-Wei Huang

Log Message

Add implementation of fuse_daemonize

It's used by exfat.

Ändern Zusammenfassung

Diff

--- a/include/fuse-lite/fuse_common.h
+++ b/include/fuse-lite/fuse_common.h
@@ -154,7 +154,7 @@ struct fuse_chan *fuse_mount(const char *mountpoint, struct fuse_args *args);
154154 */
155155 void fuse_unmount(const char *mountpoint, struct fuse_chan *ch);
156156
157-#ifdef __SOLARIS__
157+#if defined(__SOLARIS__) || defined(__ANDROID__)
158158 /**
159159 * Parse common options
160160 *
--- a/libfuse-lite/helper.c
+++ b/libfuse-lite/helper.c
@@ -59,3 +59,39 @@ int fuse_main(void)
5959 return -1;
6060 }
6161 #endif /* __SOLARIS__ */
62+
63+#ifdef __ANDROID__
64+int fuse_daemonize(int foreground)
65+{
66+ if (!foreground) {
67+ int nullfd;
68+ int pid = fork();
69+
70+ /*
71+ * demonize current process by forking it and killing the
72+ * parent. This makes current process as a child of 'init'.
73+ */
74+ if (pid < 0) {
75+ fprintf(stderr, "fuse_daemonize: fork\n");
76+ return -1;
77+ } else if (pid > 0)
78+ _exit(0);
79+
80+ if (setsid() == -1) {
81+ fprintf(stderr, "fuse_daemonize: setsid\n");
82+ return -1;
83+ }
84+
85+ chdir("/");
86+ nullfd = open("/dev/null", O_RDWR, 0);
87+ if (nullfd != -1) {
88+ dup2(nullfd, 0);
89+ dup2(nullfd, 1);
90+ dup2(nullfd, 2);
91+ if (nullfd > 2)
92+ close(nullfd);
93+ }
94+ }
95+ return 0;
96+}
97+#endif
Show on old repository browser