libfuse: lib/fuse_loop.c Source File

libfuse

fuse_loop.c
1/*
2 FUSE: Filesystem in Userspace
3 Copyright (C) 2001-2007 Miklos Szeredi <miklos@szeredi.hu>
4
5 Implementation of the single-threaded FUSE session loop.
6
7 This program can be distributed under the terms of the GNU LGPLv2.
8 See the file COPYING.LIB
9*/
10
11#include "fuse_config.h"
12#include "fuse_lowlevel.h"
13#include "fuse_i.h"
14
15#include <stdio.h>
16#include <stdlib.h>
17#include <errno.h>
18
19 int fuse_session_loop(struct fuse_session *se)
20{
21 int res = 0;
22 struct fuse_buf fbuf = {
23 .mem = NULL,
24 };
25
26 while (!fuse_session_exited(se)) {
27 res = fuse_session_receive_buf_internal(se, &fbuf, NULL);
28
29 if (res == -EINTR)
30 continue;
31 if (res <= 0)
32 break;
33
34 fuse_session_process_buf(se, &fbuf);
35 }
36
37 fuse_buf_free(&fbuf);
38 if(res > 0)
39 /* No error, just the length of the most recently read
40 request */
41 res = 0;
42 if(se->error != 0)
43 res = se->error;
44 fuse_session_reset(se);
45 return res;
46}
fuse_lowlevel.h
fuse_session_process_buf
void fuse_session_process_buf(struct fuse_session *se, const struct fuse_buf *buf)
Definition fuse_lowlevel.c:2771
fuse_session_exited
int fuse_session_exited(struct fuse_session *se)
fuse_session_loop
int fuse_session_loop(struct fuse_session *se)
Definition fuse_loop.c:19
fuse_session_reset
void fuse_session_reset(struct fuse_session *se)
fuse_buf
Definition fuse_common.h:884
fuse_buf::mem
void * mem
Definition fuse_common.h:900