~barry/ubuntu/maverick/fuse/bug-697792-m

« back to all changes in this revision

Viewing changes to lib/helper.c

  • Committer: Bazaar Package Importer
  • Author(s): Colin Watson
  • Date: 2007-08-04 08:09:00 UTC
  • mfrom: (1.1.8 upstream)
  • Revision ID: james.westby@ubuntu.com-20070804080900-m1e9xpk5eitzmelg
Tags: 2.7.0-1ubuntu1
* Resynchronise with Debian (LP: #128292). 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.
* Use dpkg-query to fetch conffile md5sums rather than parsing
  /var/lib/dpkg/status directly.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
2
    FUSE: Filesystem in Userspace
3
 
    Copyright (C) 2001-2006  Miklos Szeredi <miklos@szeredi.hu>
 
3
    Copyright (C) 2001-2007  Miklos Szeredi <miklos@szeredi.hu>
4
4
 
5
5
    This program can be distributed under the terms of the GNU LGPL.
6
6
    See the file COPYING.LIB.
29
29
struct helper_opts {
30
30
    int singlethread;
31
31
    int foreground;
32
 
    int fsname;
 
32
    int nodefault_subtype;
33
33
    char *mountpoint;
34
34
};
35
35
 
40
40
    FUSE_HELPER_OPT("debug",       foreground),
41
41
    FUSE_HELPER_OPT("-f",          foreground),
42
42
    FUSE_HELPER_OPT("-s",          singlethread),
43
 
    FUSE_HELPER_OPT("fsname=",     fsname),
 
43
    FUSE_HELPER_OPT("fsname=",     nodefault_subtype),
 
44
    FUSE_HELPER_OPT("subtype=",    nodefault_subtype),
44
45
 
45
46
    FUSE_OPT_KEY("-h",          KEY_HELP),
46
47
    FUSE_OPT_KEY("--help",      KEY_HELP),
50
51
    FUSE_OPT_KEY("-d",          FUSE_OPT_KEY_KEEP),
51
52
    FUSE_OPT_KEY("debug",       FUSE_OPT_KEY_KEEP),
52
53
    FUSE_OPT_KEY("fsname=",     FUSE_OPT_KEY_KEEP),
 
54
    FUSE_OPT_KEY("subtype=",    FUSE_OPT_KEY_KEEP),
53
55
    FUSE_OPT_END
54
56
};
55
57
 
117
119
    }
118
120
}
119
121
 
120
 
static int add_default_fsname(const char *progname, struct fuse_args *args)
 
122
static int add_default_subtype(const char *progname, struct fuse_args *args)
121
123
{
122
124
    int res;
123
 
    char *fsname_opt;
 
125
    char *subtype_opt;
124
126
    const char *basename = strrchr(progname, '/');
125
127
    if (basename == NULL)
126
128
        basename = progname;
127
129
    else if (basename[1] != '\0')
128
130
        basename++;
129
131
 
130
 
    fsname_opt = (char *) malloc(strlen(basename) + 64);
131
 
    if (fsname_opt == NULL) {
 
132
    subtype_opt = (char *) malloc(strlen(basename) + 64);
 
133
    if (subtype_opt == NULL) {
132
134
        fprintf(stderr, "fuse: memory allocation failed\n");
133
135
        return -1;
134
136
    }
135
 
    sprintf(fsname_opt, "-ofsname=%s", basename);
136
 
    res = fuse_opt_add_arg(args, fsname_opt);
137
 
    free(fsname_opt);
 
137
    sprintf(subtype_opt, "-osubtype=%s", basename);
 
138
    res = fuse_opt_add_arg(args, subtype_opt);
 
139
    free(subtype_opt);
138
140
    return res;
139
141
}
140
142
 
149
151
    if (res == -1)
150
152
        return -1;
151
153
 
152
 
    if (!hopts.fsname) {
153
 
        res = add_default_fsname(args->argv[0], args);
 
154
    if (!hopts.nodefault_subtype) {
 
155
        res = add_default_subtype(args->argv[0], args);
154
156
        if (res == -1)
155
157
            goto err;
156
158
    }
180
182
            perror("fuse: failed to daemonize program\n");
181
183
            return -1;
182
184
        }
183
 
    } else {
184
 
        /* Ensure consistant behavior across debug and normal modes */
185
 
        res = chdir("/");
186
 
        if (res == -1) {
187
 
            perror("fuse: failed to change working directory to /\n");
188
 
            return -1;
189
 
        }
190
185
    }
191
186
    return 0;
192
187
}
338
333
    return -1;
339
334
}
340
335
 
 
336
int fuse_version(void)
 
337
{
 
338
    return FUSE_VERSION;
 
339
}
 
340
 
341
341
#include "fuse_compat.h"
342
342
 
343
343
#ifndef __FreeBSD__