libfuse/lib/fuse_loop.c

47 lines
878 B
C
Raw Permalink Normal View History

2005-08-15 07:00:27 +08:00
/*
2007-12-12 22:25:40 +08:00
FUSE: Filesystem in Userspace
Copyright (C) 2001-2007 Miklos Szeredi <miklos@szeredi.hu>
2005-08-15 07:00:27 +08:00
Implementation of the single-threaded FUSE session loop.
2007-12-12 22:25:40 +08:00
This program can be distributed under the terms of the GNU LGPLv2.
See the file COPYING.LIB
2005-08-15 07:00:27 +08:00
*/
#include "fuse_config.h"
2005-08-15 07:00:27 +08:00
#include "fuse_lowlevel.h"
#include "fuse_i.h"
2005-08-15 07:00:27 +08:00
#include <stdio.h>
#include <stdlib.h>
2006-03-01 20:10:13 +08:00
#include <errno.h>
2005-08-15 07:00:27 +08:00
int fuse_session_loop(struct fuse_session *se)
{
2007-12-12 22:25:40 +08:00
int res = 0;
struct fuse_buf fbuf = {
.mem = NULL,
};
2005-08-15 07:00:27 +08:00
2007-12-12 22:25:40 +08:00
while (!fuse_session_exited(se)) {
res = fuse_session_receive_buf(se, &fbuf);
2007-12-12 22:25:40 +08:00
if (res == -EINTR)
continue;
if (res <= 0)
break;
fuse_session_process_buf(se, &fbuf);
2007-12-12 22:25:40 +08:00
}
2005-08-15 07:00:27 +08:00
free(fbuf.mem);
if(res > 0)
/* No error, just the length of the most recently read
request */
res = 0;
if(se->error != 0)
res = se->error;
2007-12-12 22:25:40 +08:00
fuse_session_reset(se);
return res;
2005-08-15 07:00:27 +08:00
}