diff -ruw fuse-1.4.org/lib/fuse.c fuse-1.4/lib/fuse.c --- fuse-1.4.org/lib/fuse.c 2004-09-14 09:02:29.000000000 +0200 +++ fuse-1.4/lib/fuse.c 2005-04-10 01:28:20.199301088 +0200 @@ -15,6 +15,7 @@ #include #include #include +#include #define FUSE_MAX_PATH 4096 #define PARAM(inarg) (((char *)(inarg)) + sizeof(*inarg)) @@ -579,6 +580,16 @@ send_reply(f, in, res, link, res == 0 ? strlen(link) : 0); } +#ifdef USE_UCLIBC +#include +#if (__UCLIBC_MAJOR__ << 16)+(__UCLIBC_MINOR__ << 8)+(__UCLIBC_SUBLEVEL__) <= 0x000913 +#include +#include +#include +#define BUGGY_TMPFILE +#endif +#endif + static void do_getdir(struct fuse *f, struct fuse_in_header *in) { int res; @@ -586,8 +597,24 @@ struct fuse_dirhandle dh; char *path; - dh.fuse = f; +#ifdef BUGGY_TMPFILE + /* WRT54G router with kernel-2.4.20 and uClibc-0.9.19 doesn't remove + * the tmpfile, so make handle this a bit different.. and remove it + * in this function manually */ + char tname[32]; + int fd; + dh.fp = NULL; + strcpy(tname, "/tmp/fuseXXXXXX"); + if ((fd=mkstemp(tname))>=0) { + if((dh.fp = fdopen (fd, "w+b")) == NULL) { + close (fd); + } + } +#else /* BUGGY_TMPFILE */ + /* glibc and Coldfire with kernel-2.4.27-uc1 and uClibc-0.9.27 works */ dh.fp = tmpfile(); +#endif /* BUGGY_TMPFILE */ + dh.fuse = f; dh.dir = in->ino; res = -EIO; @@ -608,8 +635,15 @@ if (res == 0) arg.fd = fileno(dh.fp); send_reply(f, in, res, &arg, sizeof(arg)); +#ifdef BUGGY_TMPFILE + if (dh.fp != NULL) { + fclose(dh.fp); + unlink(tname); + } +#else if (dh.fp != NULL) fclose(dh.fp); +#endif } static void do_mknod(struct fuse *f, struct fuse_in_header *in, @@ -1096,7 +1130,17 @@ f->ino_table_size = 14057; f->ino_table = (struct node **) calloc(1, sizeof(struct node *) * f->ino_table_size); +#ifdef USE_UCLIBC + { + pthread_mutexattr_t attr; + pthread_mutexattr_init(&attr); + pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ADAPTIVE_NP); + pthread_mutex_init(&f->lock, &attr); + pthread_mutexattr_destroy(&attr); + } +#else pthread_mutex_init(&f->lock, NULL); +#endif f->numworker = 0; f->numavail = 0; f->op = *op; diff -ruw fuse-1.4.org/lib/mount.c fuse-1.4/lib/mount.c --- fuse-1.4.org/lib/mount.c 2004-07-07 21:25:12.000000000 +0200 +++ fuse-1.4/lib/mount.c 2004-12-06 20:33:00.000000000 +0100 @@ -91,7 +91,11 @@ return -1; } +#if defined(USE_UCLIBC) && !defined(UCLIBC_HAS_MMU) + pid = vfork(); +#else pid = fork(); +#endif if(pid == -1) { perror("fuse: fork() failed"); close(fds[0]); diff -ruw fuse-1.4.org/util/fusermount.c fuse-1.4/util/fusermount.c --- fuse-1.4.org/util/fusermount.c 2004-07-07 21:25:12.000000000 +0200 +++ fuse-1.4/util/fusermount.c 2005-02-16 15:08:05.000000000 +0100 @@ -35,6 +35,12 @@ #define CHECK_PERMISSION 1 +#define USE_CAP +#define USE_MTAB_FILE +#ifdef USE_UCLIBC +#undef USE_MTAB_FILE +#undef USE_CAP +#endif #define FUSE_DEV "/proc/fs/fuse/dev" #define FUSE_MOUNTED_ENV "_FUSE_MOUNTED" @@ -55,6 +61,7 @@ } } +#ifdef USE_MTAB_FILE /* use a lock file so that multiple fusermount processes don't try and modify the mtab file at once! */ static int lock_mtab() @@ -215,7 +222,9 @@ return 0; } +#endif +#ifdef USE_CAP /* Until there is a nice interface for capabilities in _libc_, this will remain here. I don't think it is fair to expect users to compile libcap for this program. And anyway what's all this fuss about versioning the @@ -289,6 +298,17 @@ setfsuid(oldfsuid); setfsgid(oldfsgid); } +#else +static int drop_privs() +{ + return 0; +} + +static void restore_privs() +{ + return; +} +#endif static int do_mount(const char *dev, const char *mnt, const char *type, mode_t rootmode, int fd, int fuseflags) @@ -373,7 +393,11 @@ fd = open(dev, O_RDWR); if(fd == -1) { int status; +#if defined(USE_UCLIBC) && !defined(UCLIBC_HAS_MMU) + pid_t pid = vfork(); +#else pid_t pid = fork(); +#endif if(pid == 0) { setuid(0); execl("/sbin/modprobe", "/sbin/modprobe", "fuse", NULL); @@ -397,6 +421,7 @@ if(res == -1) return -1; +#ifdef USE_MTAB_FILE mtablock = lock_mtab(); res = add_mount(fsname, mnt, type); unlock_mtab(mtablock); @@ -404,7 +429,7 @@ umount(mnt); return -1; } - +#endif return fd; } @@ -580,12 +605,18 @@ restore_privs(); if(unmount) { +#ifdef USE_MTAB_FILE int mtablock = lock_mtab(); res = remove_mount(mnt, quiet); unlock_mtab(mtablock); if(res == -1) exit(1); - +#else + res = umount(mnt); + if(res == -1) { + fprintf(stderr, "%s: umount() failed: %s\n", progname, strerror(errno)); + } +#endif return 0; }