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

« back to all changes in this revision

Viewing changes to lib/fuse_lowlevel.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
75
75
    attr->atime     = stbuf->st_atime;
76
76
    attr->mtime     = stbuf->st_mtime;
77
77
    attr->ctime     = stbuf->st_ctime;
78
 
#ifdef FUSE_STAT_HAS_NANOSEC
79
 
    attr->atimensec = ST_ATIM(stbuf).tv_nsec;
80
 
    attr->mtimensec = ST_MTIM(stbuf).tv_nsec;
81
 
    attr->ctimensec = ST_CTIM(stbuf).tv_nsec;
82
 
#endif
 
78
    attr->atimensec = ST_ATIM_NSEC(stbuf);
 
79
    attr->mtimensec = ST_MTIM_NSEC(stbuf);
 
80
    attr->ctimensec = ST_CTIM_NSEC(stbuf);
83
81
}
84
82
 
85
83
static void convert_attr(const struct fuse_setattr_in *attr, struct stat *stbuf)
90
88
    stbuf->st_size         = attr->size;
91
89
    stbuf->st_atime        = attr->atime;
92
90
    stbuf->st_mtime        = attr->mtime;
93
 
#ifdef FUSE_STAT_HAS_NANOSEC
94
 
    ST_ATIM(stbuf).tv_nsec = attr->atimensec;
95
 
    ST_MTIM(stbuf).tv_nsec = attr->mtimensec;
96
 
#endif
 
91
    ST_ATIM_NSEC_SET(stbuf, attr->atimensec);
 
92
    ST_MTIM_NSEC_SET(stbuf, attr->mtimensec);
97
93
}
98
94
 
99
95
static  size_t iov_length(const struct iovec *iov, size_t count)
153
149
        destroy_req(req);
154
150
}
155
151
 
156
 
static int send_reply(fuse_req_t req, int error, const void *arg,
157
 
                      size_t argsize)
 
152
static int send_reply_iov(fuse_req_t req, int error, struct iovec *iov,
 
153
                          int count)
158
154
{
159
155
    struct fuse_out_header out;
160
 
    struct iovec iov[2];
161
 
    size_t count;
162
156
    int res;
163
157
 
164
158
    if (error <= -1000 || error > 0) {
168
162
 
169
163
    out.unique = req->unique;
170
164
    out.error = error;
171
 
    count = 1;
172
165
    iov[0].iov_base = &out;
173
166
    iov[0].iov_len = sizeof(struct fuse_out_header);
174
 
    if (argsize && !error) {
175
 
        count++;
 
167
    out.len = iov_length(iov, count);
 
168
 
 
169
    if (req->f->debug)
 
170
        fprintf(stderr, "   unique: %llu, error: %i (%s), outsize: %i\n",
 
171
                (unsigned long long) out.unique, out.error,
 
172
                strerror(-out.error), out.len);
 
173
    res = fuse_chan_send(req->ch, iov, count);
 
174
    free_req(req);
 
175
 
 
176
    return res;
 
177
}
 
178
 
 
179
static int send_reply(fuse_req_t req, int error, const void *arg,
 
180
                      size_t argsize)
 
181
{
 
182
    struct iovec iov[2];
 
183
    int count = 1;
 
184
    if (argsize) {
176
185
        iov[1].iov_base = (void *) arg;
177
186
        iov[1].iov_len = argsize;
178
 
    }
179
 
    out.len = iov_length(iov, count);
180
 
 
181
 
    if (req->f->debug) {
182
 
        printf("   unique: %llu, error: %i (%s), outsize: %i\n",
183
 
               out.unique, out.error, strerror(-out.error), out.len);
184
 
        fflush(stdout);
185
 
    }
186
 
    res = fuse_chan_send(req->ch, iov, count);
187
 
    free_req(req);
 
187
        count++;
 
188
    }
 
189
    return send_reply_iov(req, error, iov, count);
 
190
}
 
191
 
 
192
int fuse_reply_iov(fuse_req_t req, const struct iovec *iov, int count)
 
193
{
 
194
    int res;
 
195
    struct iovec *padded_iov;
 
196
 
 
197
    padded_iov = malloc((count + 1) * sizeof(struct iovec));
 
198
    if (padded_iov == NULL)
 
199
        return fuse_reply_err(req, -ENOMEM);
 
200
 
 
201
    memcpy(padded_iov + 1, iov, count * sizeof(struct iovec));
 
202
    count++;
 
203
 
 
204
    res = send_reply_iov(req, 0, padded_iov, count);
 
205
    free(padded_iov);
188
206
 
189
207
    return res;
190
208
}
889
907
    struct fuse_ll *f = req->f;
890
908
 
891
909
    (void) nodeid;
892
 
    if (f->debug) {
893
 
        printf("INTERRUPT: %llu\n", (unsigned long long) arg->unique);
894
 
        fflush(stdout);
895
 
    }
 
910
    if (f->debug)
 
911
        fprintf(stderr, "INTERRUPT: %llu\n", (unsigned long long) arg->unique);
896
912
 
897
913
    req->u.i.unique = arg->unique;
898
914
 
944
960
 
945
961
    (void) nodeid;
946
962
    if (f->debug) {
947
 
        printf("INIT: %u.%u\n", arg->major, arg->minor);
 
963
        fprintf(stderr, "INIT: %u.%u\n", arg->major, arg->minor);
948
964
        if (arg->major > 7 || (arg->major == 7 && arg->minor >= 6)) {
949
 
            printf("flags=0x%08x\n", arg->flags);
950
 
            printf("max_readahead=0x%08x\n", arg->max_readahead);
 
965
            fprintf(stderr, "flags=0x%08x\n", arg->flags);
 
966
            fprintf(stderr, "max_readahead=0x%08x\n", arg->max_readahead);
951
967
        }
952
 
        fflush(stdout);
953
968
    }
954
969
    f->conn.proto_major = arg->major;
955
970
    f->conn.proto_minor = arg->minor;
996
1011
    outarg.max_write = f->conn.max_write;
997
1012
 
998
1013
    if (f->debug) {
999
 
        printf("   INIT: %u.%u\n", outarg.major, outarg.minor);
1000
 
        printf("   flags=0x%08x\n", outarg.flags);
1001
 
        printf("   max_readahead=0x%08x\n", outarg.max_readahead);
1002
 
        printf("   max_write=0x%08x\n", outarg.max_write);
1003
 
        fflush(stdout);
 
1014
        fprintf(stderr, "   INIT: %u.%u\n", outarg.major, outarg.minor);
 
1015
        fprintf(stderr, "   flags=0x%08x\n", outarg.flags);
 
1016
        fprintf(stderr, "   max_readahead=0x%08x\n", outarg.max_readahead);
 
1017
        fprintf(stderr, "   max_write=0x%08x\n", outarg.max_write);
1004
1018
    }
1005
1019
 
1006
1020
    send_reply_ok(req, &outarg, arg->minor < 5 ? 8 : sizeof(outarg));
1112
1126
    const void *inarg = buf + sizeof(struct fuse_in_header);
1113
1127
    struct fuse_req *req;
1114
1128
 
1115
 
    if (f->debug) {
1116
 
        printf("unique: %llu, opcode: %s (%i), nodeid: %lu, insize: %zu\n",
1117
 
               (unsigned long long) in->unique,
1118
 
               opname((enum fuse_opcode) in->opcode), in->opcode,
1119
 
               (unsigned long) in->nodeid, len);
1120
 
        fflush(stdout);
1121
 
    }
 
1129
    if (f->debug)
 
1130
        fprintf(stderr, "unique: %llu, opcode: %s (%i), nodeid: %lu, insize: %zu\n",
 
1131
                (unsigned long long) in->unique,
 
1132
                opname((enum fuse_opcode) in->opcode), in->opcode,
 
1133
                (unsigned long) in->nodeid, len);
1122
1134
 
1123
1135
    req = (struct fuse_req *) calloc(1, sizeof(struct fuse_req));
1124
1136
    if (req == NULL) {