From ed96bb15e5d685bc03e5f7cdeeb5086290c7f124 Mon Sep 17 00:00:00 2001 From: szaka Date: Thu, 10 Jul 2008 22:55:50 +0000 Subject: [PATCH] fix: the driver didn't work if the standard I/O file descriptors were closed during mount, e.g. via some configuration of udev/hotplug (Ugo Riboni, laoGe) --- libfuse-lite/helper.c | 10 ---------- src/ntfs-3g.c | 12 +++++++++++- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/libfuse-lite/helper.c b/libfuse-lite/helper.c index e2860433..2827cf71 100644 --- a/libfuse-lite/helper.c +++ b/libfuse-lite/helper.c @@ -160,16 +160,6 @@ static struct fuse_chan *fuse_mount_common(const char *mountpoint, struct fuse_chan *ch; int fd; - /* - * Make sure file descriptors 0, 1 and 2 are open, otherwise chaos - * would ensue. - */ - do { - fd = open("/dev/null", O_RDWR); - if (fd > 2) - close(fd); - } while (fd >= 0 && fd <= 2); - fd = fuse_kern_mount(mountpoint, args); if (fd == -1) return NULL; diff --git a/src/ntfs-3g.c b/src/ntfs-3g.c index 3bc23d2b..f8b1b20b 100644 --- a/src/ntfs-3g.c +++ b/src/ntfs-3g.c @@ -2231,7 +2231,17 @@ int main(int argc, char *argv[]) struct fuse *fh; fuse_fstype fstype = FSTYPE_UNKNOWN; struct stat sbuf; - int err; + int err, fd; + + /* + * Make sure file descriptors 0, 1 and 2 are open, + * otherwise chaos would ensue. + */ + do { + fd = open("/dev/null", O_RDWR); + if (fd > 2) + close(fd); + } while (fd >= 0 && fd <= 2); #ifndef FUSE_INTERNAL if ((getuid() != geteuid()) || (getgid() != getegid())) {