~ubuntu-branches/ubuntu/jaunty/fuse/jaunty-security

« back to all changes in this revision

Viewing changes to lib/helper.c

  • Committer: Bazaar Package Importer
  • Author(s): Colin Watson
  • Date: 2008-01-29 10:38:39 UTC
  • mfrom: (1.1.10 upstream)
  • Revision ID: james.westby@ubuntu.com-20080129103839-kmz63d04pnttuuoc
Tags: 2.7.2-1ubuntu1
* Resynchronise with Debian. Remaining changes:
  - Don't install the init script; install the udev rule and the module
    configuration file instead.
  - debian/45-fuse.rules: set /dev/fuse group to fuse.
  - debian/fuse-utils.modprobe: module configuration file that mounts the
    control filesystem when fuse is loaded and unmounts it when fuse is
    unloaded, along with checking that the control FS is mounting before
    unmounting it.
  - debian/fuse-utils.install: add the udev rule, the module configuration
    file, and ulockmgr_server.
  - Load fuse on install, and set it so it gets loaded on reboot.
  - Move fusermount and ulockmgr_server to /bin and associated libraries
    to /lib.
  - Create libfuse2-udeb and fuse-utils-udeb.
  - Copy /sbin/mount.fuse and the fuse kernel module into the initramfs.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
    FUSE: Filesystem in Userspace
3
 
    Copyright (C) 2001-2007  Miklos Szeredi <miklos@szeredi.hu>
 
2
  FUSE: Filesystem in Userspace
 
3
  Copyright (C) 2001-2007  Miklos Szeredi <miklos@szeredi.hu>
4
4
 
5
 
    This program can be distributed under the terms of the GNU LGPLv2.
6
 
    See the file COPYING.LIB.
 
5
  This program can be distributed under the terms of the GNU LGPLv2.
 
6
  See the file COPYING.LIB.
7
7
*/
8
8
 
9
9
#include "config.h"
10
10
#include "fuse_i.h"
 
11
#include "fuse_misc.h"
11
12
#include "fuse_opt.h"
12
13
#include "fuse_lowlevel.h"
13
14
#include "fuse_common_compat.h"
21
22
#include <errno.h>
22
23
 
23
24
enum  {
24
 
    KEY_HELP,
25
 
    KEY_HELP_NOHEADER,
26
 
    KEY_VERSION,
 
25
        KEY_HELP,
 
26
        KEY_HELP_NOHEADER,
 
27
        KEY_VERSION,
27
28
};
28
29
 
29
30
struct helper_opts {
30
 
    int singlethread;
31
 
    int foreground;
32
 
    int nodefault_subtype;
33
 
    char *mountpoint;
 
31
        int singlethread;
 
32
        int foreground;
 
33
        int nodefault_subtype;
 
34
        char *mountpoint;
34
35
};
35
36
 
36
37
#define FUSE_HELPER_OPT(t, p) { t, offsetof(struct helper_opts, p), 1 }
37
38
 
38
39
static const struct fuse_opt fuse_helper_opts[] = {
39
 
    FUSE_HELPER_OPT("-d",          foreground),
40
 
    FUSE_HELPER_OPT("debug",       foreground),
41
 
    FUSE_HELPER_OPT("-f",          foreground),
42
 
    FUSE_HELPER_OPT("-s",          singlethread),
43
 
    FUSE_HELPER_OPT("fsname=",     nodefault_subtype),
44
 
    FUSE_HELPER_OPT("subtype=",    nodefault_subtype),
 
40
        FUSE_HELPER_OPT("-d",          foreground),
 
41
        FUSE_HELPER_OPT("debug",       foreground),
 
42
        FUSE_HELPER_OPT("-f",          foreground),
 
43
        FUSE_HELPER_OPT("-s",          singlethread),
 
44
        FUSE_HELPER_OPT("fsname=",     nodefault_subtype),
 
45
        FUSE_HELPER_OPT("subtype=",    nodefault_subtype),
45
46
 
46
 
    FUSE_OPT_KEY("-h",          KEY_HELP),
47
 
    FUSE_OPT_KEY("--help",      KEY_HELP),
48
 
    FUSE_OPT_KEY("-ho",         KEY_HELP_NOHEADER),
49
 
    FUSE_OPT_KEY("-V",          KEY_VERSION),
50
 
    FUSE_OPT_KEY("--version",   KEY_VERSION),
51
 
    FUSE_OPT_KEY("-d",          FUSE_OPT_KEY_KEEP),
52
 
    FUSE_OPT_KEY("debug",       FUSE_OPT_KEY_KEEP),
53
 
    FUSE_OPT_KEY("fsname=",     FUSE_OPT_KEY_KEEP),
54
 
    FUSE_OPT_KEY("subtype=",    FUSE_OPT_KEY_KEEP),
55
 
    FUSE_OPT_END
 
47
        FUSE_OPT_KEY("-h",          KEY_HELP),
 
48
        FUSE_OPT_KEY("--help",      KEY_HELP),
 
49
        FUSE_OPT_KEY("-ho",         KEY_HELP_NOHEADER),
 
50
        FUSE_OPT_KEY("-V",          KEY_VERSION),
 
51
        FUSE_OPT_KEY("--version",   KEY_VERSION),
 
52
        FUSE_OPT_KEY("-d",          FUSE_OPT_KEY_KEEP),
 
53
        FUSE_OPT_KEY("debug",       FUSE_OPT_KEY_KEEP),
 
54
        FUSE_OPT_KEY("fsname=",     FUSE_OPT_KEY_KEEP),
 
55
        FUSE_OPT_KEY("subtype=",    FUSE_OPT_KEY_KEEP),
 
56
        FUSE_OPT_END
56
57
};
57
58
 
58
59
static void usage(const char *progname)
59
60
{
60
 
    fprintf(stderr,
61
 
            "usage: %s mountpoint [options]\n\n", progname);
62
 
    fprintf(stderr,
63
 
            "general options:\n"
64
 
            "    -o opt,[opt...]        mount options\n"
65
 
            "    -h   --help            print help\n"
66
 
            "    -V   --version         print version\n"
67
 
            "\n");
 
61
        fprintf(stderr,
 
62
                "usage: %s mountpoint [options]\n\n", progname);
 
63
        fprintf(stderr,
 
64
                "general options:\n"
 
65
                "    -o opt,[opt...]        mount options\n"
 
66
                "    -h   --help            print help\n"
 
67
                "    -V   --version         print version\n"
 
68
                "\n");
68
69
}
69
70
 
70
71
static void helper_help(void)
71
72
{
72
 
    fprintf(stderr,
73
 
            "FUSE options:\n"
74
 
            "    -d   -o debug          enable debug output (implies -f)\n"
75
 
            "    -f                     foreground operation\n"
76
 
            "    -s                     disable multi-threaded operation\n"
77
 
            "\n"
78
 
            );
 
73
        fprintf(stderr,
 
74
                "FUSE options:\n"
 
75
                "    -d   -o debug          enable debug output (implies -f)\n"
 
76
                "    -f                     foreground operation\n"
 
77
                "    -s                     disable multi-threaded operation\n"
 
78
                "\n"
 
79
                );
79
80
}
80
81
 
81
82
static void helper_version(void)
82
83
{
83
 
    fprintf(stderr, "FUSE library version: %s\n", PACKAGE_VERSION);
 
84
        fprintf(stderr, "FUSE library version: %s\n", PACKAGE_VERSION);
84
85
}
85
86
 
86
87
static int fuse_helper_opt_proc(void *data, const char *arg, int key,
87
 
                                struct fuse_args *outargs)
 
88
                                struct fuse_args *outargs)
88
89
{
89
 
    struct helper_opts *hopts = data;
90
 
 
91
 
    switch (key) {
92
 
    case KEY_HELP:
93
 
        usage(outargs->argv[0]);
94
 
        /* fall through */
95
 
 
96
 
    case KEY_HELP_NOHEADER:
97
 
        helper_help();
98
 
        return fuse_opt_add_arg(outargs, "-h");
99
 
 
100
 
    case KEY_VERSION:
101
 
        helper_version();
102
 
        return 1;
103
 
 
104
 
    case FUSE_OPT_KEY_NONOPT:
105
 
        if (!hopts->mountpoint) {
106
 
            char mountpoint[PATH_MAX];
107
 
            if (realpath(arg, mountpoint) == NULL) {
108
 
                fprintf(stderr, "fuse: bad mount point `%s': %s\n", arg, strerror(errno));
109
 
                return -1;
110
 
            }
111
 
            return fuse_opt_add_opt(&hopts->mountpoint, mountpoint);
112
 
        } else {
113
 
            fprintf(stderr, "fuse: invalid argument `%s'\n", arg);
114
 
            return -1;
115
 
        }
116
 
 
117
 
    default:
118
 
        return 1;
119
 
    }
 
90
        struct helper_opts *hopts = data;
 
91
 
 
92
        switch (key) {
 
93
        case KEY_HELP:
 
94
                usage(outargs->argv[0]);
 
95
                /* fall through */
 
96
 
 
97
        case KEY_HELP_NOHEADER:
 
98
                helper_help();
 
99
                return fuse_opt_add_arg(outargs, "-h");
 
100
 
 
101
        case KEY_VERSION:
 
102
                helper_version();
 
103
                return 1;
 
104
 
 
105
        case FUSE_OPT_KEY_NONOPT:
 
106
                if (!hopts->mountpoint) {
 
107
                        char mountpoint[PATH_MAX];
 
108
                        if (realpath(arg, mountpoint) == NULL) {
 
109
                                fprintf(stderr,
 
110
                                        "fuse: bad mount point `%s': %s\n",
 
111
                                        arg, strerror(errno));
 
112
                                return -1;
 
113
                        }
 
114
                        return fuse_opt_add_opt(&hopts->mountpoint, mountpoint);
 
115
                } else {
 
116
                        fprintf(stderr, "fuse: invalid argument `%s'\n", arg);
 
117
                        return -1;
 
118
                }
 
119
 
 
120
        default:
 
121
                return 1;
 
122
        }
120
123
}
121
124
 
122
125
static int add_default_subtype(const char *progname, struct fuse_args *args)
123
126
{
124
 
    int res;
125
 
    char *subtype_opt;
126
 
    const char *basename = strrchr(progname, '/');
127
 
    if (basename == NULL)
128
 
        basename = progname;
129
 
    else if (basename[1] != '\0')
130
 
        basename++;
 
127
        int res;
 
128
        char *subtype_opt;
 
129
        const char *basename = strrchr(progname, '/');
 
130
        if (basename == NULL)
 
131
                basename = progname;
 
132
        else if (basename[1] != '\0')
 
133
                basename++;
131
134
 
132
 
    subtype_opt = (char *) malloc(strlen(basename) + 64);
133
 
    if (subtype_opt == NULL) {
134
 
        fprintf(stderr, "fuse: memory allocation failed\n");
135
 
        return -1;
136
 
    }
137
 
    sprintf(subtype_opt, "-osubtype=%s", basename);
138
 
    res = fuse_opt_add_arg(args, subtype_opt);
139
 
    free(subtype_opt);
140
 
    return res;
 
135
        subtype_opt = (char *) malloc(strlen(basename) + 64);
 
136
        if (subtype_opt == NULL) {
 
137
                fprintf(stderr, "fuse: memory allocation failed\n");
 
138
                return -1;
 
139
        }
 
140
        sprintf(subtype_opt, "-osubtype=%s", basename);
 
141
        res = fuse_opt_add_arg(args, subtype_opt);
 
142
        free(subtype_opt);
 
143
        return res;
141
144
}
142
145
 
143
146
int fuse_parse_cmdline(struct fuse_args *args, char **mountpoint,
144
 
                       int *multithreaded, int *foreground)
 
147
                       int *multithreaded, int *foreground)
145
148
{
146
 
    int res;
147
 
    struct helper_opts hopts;
148
 
 
149
 
    memset(&hopts, 0, sizeof(hopts));
150
 
    res = fuse_opt_parse(args, &hopts, fuse_helper_opts, fuse_helper_opt_proc);
151
 
    if (res == -1)
152
 
        return -1;
153
 
 
154
 
    if (!hopts.nodefault_subtype) {
155
 
        res = add_default_subtype(args->argv[0], args);
156
 
        if (res == -1)
157
 
            goto err;
158
 
    }
159
 
    if (mountpoint)
160
 
        *mountpoint = hopts.mountpoint;
161
 
    else
162
 
        free(hopts.mountpoint);
163
 
 
164
 
    if (multithreaded)
165
 
        *multithreaded = !hopts.singlethread;
166
 
    if (foreground)
167
 
        *foreground = hopts.foreground;
168
 
    return 0;
169
 
 
170
 
 err:
171
 
    free(hopts.mountpoint);
172
 
    return -1;
 
149
        int res;
 
150
        struct helper_opts hopts;
 
151
 
 
152
        memset(&hopts, 0, sizeof(hopts));
 
153
        res = fuse_opt_parse(args, &hopts, fuse_helper_opts,
 
154
                             fuse_helper_opt_proc);
 
155
        if (res == -1)
 
156
                return -1;
 
157
 
 
158
        if (!hopts.nodefault_subtype) {
 
159
                res = add_default_subtype(args->argv[0], args);
 
160
                if (res == -1)
 
161
                        goto err;
 
162
        }
 
163
        if (mountpoint)
 
164
                *mountpoint = hopts.mountpoint;
 
165
        else
 
166
                free(hopts.mountpoint);
 
167
 
 
168
        if (multithreaded)
 
169
                *multithreaded = !hopts.singlethread;
 
170
        if (foreground)
 
171
                *foreground = hopts.foreground;
 
172
        return 0;
 
173
 
 
174
err:
 
175
        free(hopts.mountpoint);
 
176
        return -1;
173
177
}
174
178
 
175
179
int fuse_daemonize(int foreground)
176
180
{
177
 
    int res;
 
181
        int res;
178
182
 
179
 
    if (!foreground) {
180
 
        res = daemon(0, 0);
181
 
        if (res == -1) {
182
 
            perror("fuse: failed to daemonize program\n");
183
 
            return -1;
184
 
        }
185
 
    }
186
 
    return 0;
 
183
        if (!foreground) {
 
184
                res = daemon(0, 0);
 
185
                if (res == -1) {
 
186
                        perror("fuse: failed to daemonize program\n");
 
187
                        return -1;
 
188
                }
 
189
        }
 
190
        return 0;
187
191
}
188
192
 
189
193
static struct fuse_chan *fuse_mount_common(const char *mountpoint,
190
 
                                           struct fuse_args *args)
 
194
                                           struct fuse_args *args)
191
195
{
192
 
    struct fuse_chan *ch;
193
 
    int fd;
194
 
 
195
 
    /*
196
 
     * Make sure file descriptors 0, 1 and 2 are open, otherwise chaos
197
 
     * would ensue.
198
 
     */
199
 
    do {
200
 
        fd = open("/dev/null", O_RDWR);
201
 
        if (fd > 2)
202
 
            close(fd);
203
 
    } while (fd >= 0 && fd <= 2);
204
 
 
205
 
    fd = fuse_mount_compat25(mountpoint, args);
206
 
    if (fd == -1)
207
 
        return NULL;
208
 
 
209
 
    ch = fuse_kern_chan_new(fd);
210
 
    if (!ch)
211
 
        fuse_kern_unmount(mountpoint, fd);
212
 
 
213
 
    return ch;
 
196
        struct fuse_chan *ch;
 
197
        int fd;
 
198
 
 
199
        /*
 
200
         * Make sure file descriptors 0, 1 and 2 are open, otherwise chaos
 
201
         * would ensue.
 
202
         */
 
203
        do {
 
204
                fd = open("/dev/null", O_RDWR);
 
205
                if (fd > 2)
 
206
                        close(fd);
 
207
        } while (fd >= 0 && fd <= 2);
 
208
 
 
209
        fd = fuse_mount_compat25(mountpoint, args);
 
210
        if (fd == -1)
 
211
                return NULL;
 
212
 
 
213
        ch = fuse_kern_chan_new(fd);
 
214
        if (!ch)
 
215
                fuse_kern_unmount(mountpoint, fd);
 
216
 
 
217
        return ch;
214
218
}
215
219
 
216
220
struct fuse_chan *fuse_mount(const char *mountpoint, struct fuse_args *args)
217
221
{
218
 
    return fuse_mount_common(mountpoint, args);
 
222
        return fuse_mount_common(mountpoint, args);
219
223
}
220
224
 
221
225
static void fuse_unmount_common(const char *mountpoint, struct fuse_chan *ch)
222
226
{
223
 
    int fd = ch ? fuse_chan_fd(ch) : -1;
224
 
    fuse_kern_unmount(mountpoint, fd);
225
 
    fuse_chan_destroy(ch);
 
227
        int fd = ch ? fuse_chan_fd(ch) : -1;
 
228
        fuse_kern_unmount(mountpoint, fd);
 
229
        fuse_chan_destroy(ch);
226
230
}
227
231
 
228
232
void fuse_unmount(const char *mountpoint, struct fuse_chan *ch)
229
233
{
230
 
    fuse_unmount_common(mountpoint, ch);
 
234
        fuse_unmount_common(mountpoint, ch);
231
235
}
232
236
 
233
237
static struct fuse *fuse_setup_common(int argc, char *argv[],
234
 
                                      const struct fuse_operations *op,
235
 
                                      size_t op_size,
236
 
                                      char **mountpoint,
237
 
                                      int *multithreaded,
238
 
                                      int *fd,
239
 
                                      void *user_data,
240
 
                                      int compat)
 
238
                                      const struct fuse_operations *op,
 
239
                                      size_t op_size,
 
240
                                      char **mountpoint,
 
241
                                      int *multithreaded,
 
242
                                      int *fd,
 
243
                                      void *user_data,
 
244
                                      int compat)
241
245
{
242
 
    struct fuse_args args = FUSE_ARGS_INIT(argc, argv);
243
 
    struct fuse_chan *ch;
244
 
    struct fuse *fuse;
245
 
    int foreground;
246
 
    int res;
247
 
 
248
 
    res = fuse_parse_cmdline(&args, mountpoint, multithreaded, &foreground);
249
 
    if (res == -1)
250
 
        return NULL;
251
 
 
252
 
    ch = fuse_mount_common(*mountpoint, &args);
253
 
    if (!ch) {
254
 
        fuse_opt_free_args(&args);
255
 
        goto err_free;
256
 
    }
257
 
 
258
 
    fuse = fuse_new_common(ch, &args, op, op_size, user_data, compat);
259
 
    fuse_opt_free_args(&args);
260
 
    if (fuse == NULL)
261
 
        goto err_unmount;
262
 
 
263
 
    res = fuse_daemonize(foreground);
264
 
    if (res == -1)
265
 
        goto err_unmount;
266
 
 
267
 
    res = fuse_set_signal_handlers(fuse_get_session(fuse));
268
 
    if (res == -1)
269
 
        goto err_unmount;
270
 
 
271
 
    if (fd)
272
 
        *fd = fuse_chan_fd(ch);
273
 
 
274
 
    return fuse;
275
 
 
276
 
 err_unmount:
277
 
    fuse_unmount_common(*mountpoint, ch);
278
 
    if (fuse)
279
 
        fuse_destroy(fuse);
280
 
 err_free:
281
 
    free(*mountpoint);
282
 
    return NULL;
 
246
        struct fuse_args args = FUSE_ARGS_INIT(argc, argv);
 
247
        struct fuse_chan *ch;
 
248
        struct fuse *fuse;
 
249
        int foreground;
 
250
        int res;
 
251
 
 
252
        res = fuse_parse_cmdline(&args, mountpoint, multithreaded, &foreground);
 
253
        if (res == -1)
 
254
                return NULL;
 
255
 
 
256
        ch = fuse_mount_common(*mountpoint, &args);
 
257
        if (!ch) {
 
258
                fuse_opt_free_args(&args);
 
259
                goto err_free;
 
260
        }
 
261
 
 
262
        fuse = fuse_new_common(ch, &args, op, op_size, user_data, compat);
 
263
        fuse_opt_free_args(&args);
 
264
        if (fuse == NULL)
 
265
                goto err_unmount;
 
266
 
 
267
        res = fuse_daemonize(foreground);
 
268
        if (res == -1)
 
269
                goto err_unmount;
 
270
 
 
271
        res = fuse_set_signal_handlers(fuse_get_session(fuse));
 
272
        if (res == -1)
 
273
                goto err_unmount;
 
274
 
 
275
        if (fd)
 
276
                *fd = fuse_chan_fd(ch);
 
277
 
 
278
        return fuse;
 
279
 
 
280
err_unmount:
 
281
        fuse_unmount_common(*mountpoint, ch);
 
282
        if (fuse)
 
283
                fuse_destroy(fuse);
 
284
err_free:
 
285
        free(*mountpoint);
 
286
        return NULL;
283
287
}
284
288
 
285
289
struct fuse *fuse_setup(int argc, char *argv[],
286
 
                        const struct fuse_operations *op, size_t op_size,
287
 
                        char **mountpoint, int *multithreaded, void *user_data)
 
290
                        const struct fuse_operations *op, size_t op_size,
 
291
                        char **mountpoint, int *multithreaded, void *user_data)
288
292
{
289
 
    return fuse_setup_common(argc, argv, op, op_size, mountpoint,
290
 
                             multithreaded, NULL, user_data, 0);
 
293
        return fuse_setup_common(argc, argv, op, op_size, mountpoint,
 
294
                                 multithreaded, NULL, user_data, 0);
291
295
}
292
296
 
293
297
static void fuse_teardown_common(struct fuse *fuse, char *mountpoint)
294
298
{
295
 
    struct fuse_session *se = fuse_get_session(fuse);
296
 
    struct fuse_chan *ch = fuse_session_next_chan(se, NULL);
297
 
    fuse_remove_signal_handlers(se);
298
 
    fuse_unmount_common(mountpoint, ch);
299
 
    fuse_destroy(fuse);
300
 
    free(mountpoint);
 
299
        struct fuse_session *se = fuse_get_session(fuse);
 
300
        struct fuse_chan *ch = fuse_session_next_chan(se, NULL);
 
301
        fuse_remove_signal_handlers(se);
 
302
        fuse_unmount_common(mountpoint, ch);
 
303
        fuse_destroy(fuse);
 
304
        free(mountpoint);
301
305
}
302
306
 
303
307
void fuse_teardown(struct fuse *fuse, char *mountpoint)
304
308
{
305
 
    fuse_teardown_common(fuse, mountpoint);
 
309
        fuse_teardown_common(fuse, mountpoint);
306
310
}
307
311
 
308
312
static int fuse_main_common(int argc, char *argv[],
309
 
                            const struct fuse_operations *op, size_t op_size,
310
 
                            void *user_data, int compat)
 
313
                            const struct fuse_operations *op, size_t op_size,
 
314
                            void *user_data, int compat)
311
315
{
312
 
    struct fuse *fuse;
313
 
    char *mountpoint;
314
 
    int multithreaded;
315
 
    int res;
316
 
 
317
 
    fuse = fuse_setup_common(argc, argv, op, op_size, &mountpoint,
318
 
                             &multithreaded, NULL, user_data, compat);
319
 
    if (fuse == NULL)
320
 
        return 1;
321
 
 
322
 
    if (multithreaded)
323
 
        res = fuse_loop_mt(fuse);
324
 
    else
325
 
        res = fuse_loop(fuse);
326
 
 
327
 
    fuse_teardown_common(fuse, mountpoint);
328
 
    if (res == -1)
329
 
        return 1;
330
 
 
331
 
    return 0;
 
316
        struct fuse *fuse;
 
317
        char *mountpoint;
 
318
        int multithreaded;
 
319
        int res;
 
320
 
 
321
        fuse = fuse_setup_common(argc, argv, op, op_size, &mountpoint,
 
322
                                 &multithreaded, NULL, user_data, compat);
 
323
        if (fuse == NULL)
 
324
                return 1;
 
325
 
 
326
        if (multithreaded)
 
327
                res = fuse_loop_mt(fuse);
 
328
        else
 
329
                res = fuse_loop(fuse);
 
330
 
 
331
        fuse_teardown_common(fuse, mountpoint);
 
332
        if (res == -1)
 
333
                return 1;
 
334
 
 
335
        return 0;
332
336
}
333
337
 
334
338
int fuse_main_real(int argc, char *argv[], const struct fuse_operations *op,
335
 
                   size_t op_size, void *user_data)
 
339
                   size_t op_size, void *user_data)
336
340
{
337
 
    return fuse_main_common(argc, argv, op, op_size, user_data, 0);
 
341
        return fuse_main_common(argc, argv, op, op_size, user_data, 0);
338
342
}
339
343
 
340
344
#undef fuse_main
341
345
int fuse_main(void);
342
346
int fuse_main(void)
343
347
{
344
 
    fprintf(stderr, "fuse_main(): This function does not exist\n");
345
 
    return -1;
 
348
        fprintf(stderr, "fuse_main(): This function does not exist\n");
 
349
        return -1;
346
350
}
347
351
 
348
352
int fuse_version(void)
349
353
{
350
 
    return FUSE_VERSION;
 
354
        return FUSE_VERSION;
351
355
}
352
356
 
353
357
#include "fuse_compat.h"
355
359
#ifndef __FreeBSD__
356
360
 
357
361
struct fuse *fuse_setup_compat22(int argc, char *argv[],
358
 
                                 const struct fuse_operations_compat22 *op,
359
 
                                 size_t op_size, char **mountpoint,
360
 
                                 int *multithreaded, int *fd)
 
362
                                 const struct fuse_operations_compat22 *op,
 
363
                                 size_t op_size, char **mountpoint,
 
364
                                 int *multithreaded, int *fd)
361
365
{
362
 
    return fuse_setup_common(argc, argv, (struct fuse_operations *) op,
363
 
                             op_size, mountpoint, multithreaded, fd, NULL, 22);
 
366
        return fuse_setup_common(argc, argv, (struct fuse_operations *) op,
 
367
                                 op_size, mountpoint, multithreaded, fd, NULL,
 
368
                                 22);
364
369
}
365
370
 
366
371
struct fuse *fuse_setup_compat2(int argc, char *argv[],
367
 
                                 const struct fuse_operations_compat2 *op,
368
 
                                 char **mountpoint, int *multithreaded,
369
 
                                 int *fd)
 
372
                                const struct fuse_operations_compat2 *op,
 
373
                                char **mountpoint, int *multithreaded,
 
374
                                int *fd)
370
375
{
371
 
    return fuse_setup_common(argc, argv, (struct fuse_operations *) op,
372
 
                             sizeof(struct fuse_operations_compat2),
373
 
                             mountpoint, multithreaded, fd, NULL, 21);
 
376
        return fuse_setup_common(argc, argv, (struct fuse_operations *) op,
 
377
                                 sizeof(struct fuse_operations_compat2),
 
378
                                 mountpoint, multithreaded, fd, NULL, 21);
374
379
}
375
380
 
376
381
int fuse_main_real_compat22(int argc, char *argv[],
377
 
                            const struct fuse_operations_compat22 *op,
378
 
                            size_t op_size)
 
382
                            const struct fuse_operations_compat22 *op,
 
383
                            size_t op_size)
379
384
{
380
 
    return fuse_main_common(argc, argv, (struct fuse_operations *) op, op_size,
381
 
                            NULL, 22);
 
385
        return fuse_main_common(argc, argv, (struct fuse_operations *) op,
 
386
                                op_size, NULL, 22);
382
387
}
383
388
 
384
389
void fuse_main_compat1(int argc, char *argv[],
385
 
                      const struct fuse_operations_compat1 *op)
 
390
                       const struct fuse_operations_compat1 *op)
386
391
{
387
 
    fuse_main_common(argc, argv, (struct fuse_operations *) op,
388
 
                     sizeof(struct fuse_operations_compat1), NULL, 11);
 
392
        fuse_main_common(argc, argv, (struct fuse_operations *) op,
 
393
                         sizeof(struct fuse_operations_compat1), NULL, 11);
389
394
}
390
395
 
391
396
int fuse_main_compat2(int argc, char *argv[],
392
 
                      const struct fuse_operations_compat2 *op)
 
397
                      const struct fuse_operations_compat2 *op)
393
398
{
394
 
    return fuse_main_common(argc, argv, (struct fuse_operations *) op,
395
 
                            sizeof(struct fuse_operations_compat2), NULL, 21);
 
399
        return fuse_main_common(argc, argv, (struct fuse_operations *) op,
 
400
                                sizeof(struct fuse_operations_compat2), NULL,
 
401
                                21);
396
402
}
397
403
 
398
404
int fuse_mount_compat1(const char *mountpoint, const char *args[])
399
405
{
400
 
    /* just ignore mount args for now */
401
 
    (void) args;
402
 
    return fuse_mount_compat22(mountpoint, NULL);
 
406
        /* just ignore mount args for now */
 
407
        (void) args;
 
408
        return fuse_mount_compat22(mountpoint, NULL);
403
409
}
404
410
 
405
 
__asm__(".symver fuse_setup_compat2,__fuse_setup@");
406
 
__asm__(".symver fuse_setup_compat22,fuse_setup@FUSE_2.2");
407
 
__asm__(".symver fuse_teardown,__fuse_teardown@");
408
 
__asm__(".symver fuse_main_compat2,fuse_main@");
409
 
__asm__(".symver fuse_main_real_compat22,fuse_main_real@FUSE_2.2");
 
411
FUSE_SYMVER(".symver fuse_setup_compat2,__fuse_setup@");
 
412
FUSE_SYMVER(".symver fuse_setup_compat22,fuse_setup@FUSE_2.2");
 
413
FUSE_SYMVER(".symver fuse_teardown,__fuse_teardown@");
 
414
FUSE_SYMVER(".symver fuse_main_compat2,fuse_main@");
 
415
FUSE_SYMVER(".symver fuse_main_real_compat22,fuse_main_real@FUSE_2.2");
410
416
 
411
417
#endif /* __FreeBSD__ */
412
418
 
413
419
 
414
420
struct fuse *fuse_setup_compat25(int argc, char *argv[],
415
 
                                 const struct fuse_operations_compat25 *op,
416
 
                                 size_t op_size, char **mountpoint,
417
 
                                 int *multithreaded, int *fd)
 
421
                                 const struct fuse_operations_compat25 *op,
 
422
                                 size_t op_size, char **mountpoint,
 
423
                                 int *multithreaded, int *fd)
418
424
{
419
 
    return fuse_setup_common(argc, argv, (struct fuse_operations *) op,
420
 
                             op_size, mountpoint, multithreaded, fd, NULL, 25);
 
425
        return fuse_setup_common(argc, argv, (struct fuse_operations *) op,
 
426
                                 op_size, mountpoint, multithreaded, fd, NULL,
 
427
                                 25);
421
428
}
422
429
 
423
430
int fuse_main_real_compat25(int argc, char *argv[],
424
 
                            const struct fuse_operations_compat25 *op,
425
 
                            size_t op_size)
 
431
                            const struct fuse_operations_compat25 *op,
 
432
                            size_t op_size)
426
433
{
427
 
    return fuse_main_common(argc, argv, (struct fuse_operations *) op, op_size,
428
 
                            NULL, 25);
 
434
        return fuse_main_common(argc, argv, (struct fuse_operations *) op,
 
435
                                op_size, NULL, 25);
429
436
}
430
437
 
431
438
void fuse_teardown_compat22(struct fuse *fuse, int fd, char *mountpoint)
432
439
{
433
 
    (void) fd;
434
 
    fuse_teardown_common(fuse, mountpoint);
 
440
        (void) fd;
 
441
        fuse_teardown_common(fuse, mountpoint);
435
442
}
436
443
 
437
444
int fuse_mount_compat25(const char *mountpoint, struct fuse_args *args)
438
445
{
439
 
    return fuse_kern_mount(mountpoint, args);
 
446
        return fuse_kern_mount(mountpoint, args);
440
447
}
441
448
 
442
 
__asm__(".symver fuse_setup_compat25,fuse_setup@FUSE_2.5");
443
 
__asm__(".symver fuse_teardown_compat22,fuse_teardown@FUSE_2.2");
444
 
__asm__(".symver fuse_main_real_compat25,fuse_main_real@FUSE_2.5");
445
 
__asm__(".symver fuse_mount_compat25,fuse_mount@FUSE_2.5");
 
449
FUSE_SYMVER(".symver fuse_setup_compat25,fuse_setup@FUSE_2.5");
 
450
FUSE_SYMVER(".symver fuse_teardown_compat22,fuse_teardown@FUSE_2.2");
 
451
FUSE_SYMVER(".symver fuse_main_real_compat25,fuse_main_real@FUSE_2.5");
 
452
FUSE_SYMVER(".symver fuse_mount_compat25,fuse_mount@FUSE_2.5");