DECLARE_WAITQUEUE(wait, current);
add_wait_queue_exclusive(&fc->waitq, &wait);
- while(list_empty(&fc->pending)) {
+ while(fc->sb != NULL && list_empty(&fc->pending)) {
set_current_state(TASK_INTERRUPTIBLE);
if(signal_pending(current))
break;
struct fuse_conn *fc = DEV_FC(file);
struct fuse_req *req = NULL;
- if(fc->sb == NULL)
- return -EPERM;
-
spin_lock(&fuse_lock);
request_wait(fc);
- if(!list_empty(&fc->pending)) {
+ if(fc->sb != NULL && !list_empty(&fc->pending)) {
req = list_entry(fc->pending.next, struct fuse_req, list);
list_del_init(&req->list);
req->locked = 1;
}
spin_unlock(&fuse_lock);
+ if(fc->sb == NULL)
+ return -ENODEV;
if(req == NULL)
return -ERESTARTSYS;
reclen = FUSE_DIRENT_SIZE(&dirent);
res = fwrite(&dirent, reclen, 1, dh->fp);
if(res == 0) {
- perror("writing directory file");
+ perror("fuse: writing directory file");
return -EIO;
}
return 0;
if(res == -1) {
/* ENOENT means the operation was interrupted */
if(errno != ENOENT)
- perror("writing fuse device");
+ perror("fuse: writing device");
}
}
struct fuse_out_header *out;
if(error > 0) {
- fprintf(stderr, "positive error code: %i\n", error);
+ fprintf(stderr, "fuse: positive error code: %i\n", error);
error = -ERANGE;
}
res = read(f->fd, cmd->buf, FUSE_MAX_IN);
if(res == -1) {
- perror("reading fuse device");
- /* BAD... This will happen again */
+ /* ENODEV means we got unmounted, so we silenty return failure */
+ if(errno != ENODEV) {
+ perror("fuse: reading device");
+ /* BAD... This will happen again */
+ }
free_cmd(cmd);
return NULL;
}
while(1) {
struct fuse_cmd *cmd = __fuse_read_cmd(w->f);
if(cmd == NULL)
- exit(1);
+ pthread_exit(NULL);
if(f->numavail == 0 && f->numworker < FUSE_MAX_WORKERS) {
pthread_mutex_lock(&f->lock);