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 "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_int(se, &fbuf, NULL);
28 
29  if (res == -EINTR)
30  continue;
31  if (res <= 0)
32  break;
33 
34  fuse_session_process_buf_int(se, &fbuf, NULL);
35  }
36 
37  free(fbuf.mem);
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;
45  return res;
46 }
void fuse_session_reset(struct fuse_session *se)
int fuse_session_loop(struct fuse_session *se)
Definition: fuse_loop.c:19
int fuse_session_exited(struct fuse_session *se)
void * mem
Definition: fuse_common.h:629