summaryrefslogtreecommitdiff
path: root/libfuse-lite/helper.c (plain)
blob: ebd7d77ec6b2778bfeca2af2eb49094af4495123
1/*
2 FUSE: Filesystem in Userspace
3 Copyright (C) 2001-2007 Miklos Szeredi <miklos@szeredi.hu>
4
5 This program can be distributed under the terms of the GNU LGPLv2.
6 See the file COPYING.LIB.
7*/
8
9#include "config.h"
10#include "fuse_i.h"
11#include "fuse_lowlevel.h"
12
13struct fuse_chan *fuse_mount(const char *mountpoint, struct fuse_args *args)
14{
15 struct fuse_chan *ch;
16 int fd;
17
18#ifdef __SOLARIS__
19 /*
20 * Make sure file descriptors 0, 1 and 2 are open, otherwise chaos
21 * would ensue.
22 */
23 do {
24 fd = open("/dev/null", O_RDWR);
25 if (fd > 2)
26 close(fd);
27 } while (fd >= 0 && fd <= 2);
28#endif /* __SOLARIS__ */
29
30 fd = fuse_kern_mount(mountpoint, args);
31 if (fd == -1)
32 return NULL;
33
34 ch = fuse_kern_chan_new(fd);
35 if (!ch)
36 fuse_kern_unmount(mountpoint, fd);
37
38 return ch;
39}
40
41void fuse_unmount(const char *mountpoint, struct fuse_chan *ch)
42{
43 int fd = ch ? fuse_chan_fd(ch) : -1;
44 fuse_kern_unmount(mountpoint, fd);
45 fuse_chan_destroy(ch);
46}
47
48int fuse_version(void)
49{
50 return FUSE_VERSION;
51}
52
53#ifdef __SOLARIS__
54#undef fuse_main
55int fuse_main(void);
56int fuse_main(void)
57{
58 fprintf(stderr, "fuse_main(): This function does not exist\n");
59 return -1;
60}
61#endif /* __SOLARIS__ */
62