add missing patch (from Christian)
[openwrt.git] / package / fuse / patches / 111-uclibc_changes.patch
1 diff -ruw fuse-2.3.0.org/lib/mount.c fuse-2.3.0/lib/mount.c
2 --- fuse-2.3.0.org/lib/mount.c  2005-02-02 12:14:44.000000000 +0100
3 +++ fuse-2.3.0/lib/mount.c      2005-08-26 09:23:11.000000000 +0200
4 @@ -6,6 +6,13 @@
5      See the file COPYING.LIB.
6  */
7  
8 +#include <config.h>
9 +#ifdef HAVE_FEATURES_H
10 +#include <features.h>
11 +#endif
12 +/* Remove this when config.h is updated with HAVE_FEATURES_H */
13 +#include <features.h>
14 +
15  #include "fuse.h"
16  #include "fuse_compat.h"
17  
18 @@ -92,10 +99,11 @@
19          return -1;
20      }
21  
22 -#ifndef USE_UCLIBC
23 -    pid = fork();
24 -#else
25 +#if defined(__UCLIBC__) && \
26 +  (!defined(__ARCH_HAS_MMU__) && !defined(__UCLIBC_HAS_MMU__))
27      pid = vfork();
28 +#else
29 +    pid = fork();
30  #endif
31      if(pid == -1) {
32          perror("fuse: fork() failed");
33 diff -ruw fuse-2.3.0.org/util/fusermount.c fuse-2.3.0/util/fusermount.c
34 --- fuse-2.3.0.org/util/fusermount.c    2005-05-17 18:54:17.000000000 +0200
35 +++ fuse-2.3.0/util/fusermount.c        2005-08-26 09:20:12.000000000 +0200
36 @@ -17,6 +17,17 @@
37   */
38  
39  #include <config.h>
40 +#ifdef HAVE_FEATURES_H
41 +#include <features.h>
42 +#endif
43 +/* Remove this when config.h is updated with HAVE_FEATURES_H */
44 +#include <features.h>
45 +
46 +#ifdef __UCLIBC__
47 +/* Most embedded systems with uclibc have read-only root filesystem. Should
48 + * replace this into a parameter --disable-mtab instead */
49 +#define READONLY_MTAB 1
50 +#endif
51  
52  #include <stdio.h>
53  #include <stdlib.h>
54 @@ -40,7 +51,12 @@
55  #define FUSE_COMMFD_ENV         "_FUSE_COMMFD"
56  
57  #define FUSE_DEV_OLD "/proc/fs/fuse/dev"
58 +#ifdef __UCLIBC__
59 +/* /dev is mounted as devfs in OpenWRT, and device is created here */
60 +#define FUSE_DEV_NEW "/dev/misc/fuse"
61 +#else
62  #define FUSE_DEV_NEW "/dev/fuse"
63 +#endif
64  #define FUSE_VERSION_FILE_OLD "/proc/fs/fuse/version"
65  #define FUSE_CONF "/etc/fuse.conf"
66  #define FUSE_MAJOR 10
67 @@ -89,7 +105,7 @@
68      return res;
69  }
70  
71 -#ifndef USE_UCLIBC
72 +#ifndef READONLY_MTAB
73  /* use a lock file so that multiple fusermount processes don't try and
74     modify the mtab file at once! */
75  static int lock_mtab()
76 @@ -701,7 +717,12 @@
77      return fd;
78  }
79  
80 +#ifdef __UCLIBC__
81 +/* /dev is writeable on openwrt distribution */
82 +#define FUSE_TMP_DIRNAME "/dev/.fuse_devXXXXXX"
83 +#else
84  #define FUSE_TMP_DIRNAME "/tmp/.fuse_devXXXXXX"
85 +#endif
86  #define FUSE_TMP_DEVNAME "/fuse"
87  
88  static int try_open_new_temp(dev_t devnum, char **devp)
89 @@ -761,17 +782,19 @@
90          pid_t pid;
91  
92          fd = try_open_fuse_device(devp);
93 +       //fprintf(stderr, "open_fuse_device: try_open_fuse_device() ret=%d\n", fd);
94          if (fd >= 0)
95              return fd;
96  
97 -#ifndef USE_UCLIBC
98 -        pid = fork();
99 -#else
100 +#if defined(__UCLIBC__) && \
101 +  (!defined(__ARCH_HAS_MMU__) && !defined(__UCLIBC_HAS_MMU__))
102          pid = vfork();
103 +#else
104 +       pid = fork();
105  #endif
106          if (pid == 0) {
107              setuid(0);
108 -            execl("/sbin/modprobe", "/sbin/modprobe", "fuse", NULL);
109 +            execl("/sbin/insmod", "/sbin/insmod", "fuse", NULL);
110              exit(1);
111          }
112          if (pid != -1)