minidlna support now Samsung TV C550/C650 (thx amir909)
[tomato.git] / release / src / router / ntfs-3g / libfuse-lite / fuse_loop.c
blob0b592e5316885cfffb5558dcdeee3d888222e7da
1 /*
2 FUSE: Filesystem in Userspace
3 Copyright (C) 2001-2007 Miklos Szeredi <miklos@szeredi.hu>
5 This program can be distributed under the terms of the GNU LGPLv2.
6 See the file COPYING.LIB
7 */
9 #include "config.h"
10 #include "fuse_lowlevel.h"
12 #include <stdio.h>
13 #include <stdlib.h>
14 #include <errno.h>
16 int fuse_session_loop(struct fuse_session *se)
18 int res = 0;
19 struct fuse_chan *ch = fuse_session_next_chan(se, NULL);
20 size_t bufsize = fuse_chan_bufsize(ch);
21 char *buf = (char *) malloc(bufsize);
22 if (!buf) {
23 fprintf(stderr, "fuse: failed to allocate read buffer\n");
24 return -1;
27 while (!fuse_session_exited(se)) {
28 struct fuse_chan *tmpch = ch;
29 res = fuse_chan_recv(&tmpch, buf, bufsize);
30 if (res == -EINTR)
31 continue;
32 if (res <= 0)
33 break;
34 fuse_session_process(se, buf, res, tmpch);
37 free(buf);
38 fuse_session_reset(se);
39 return res < 0 ? -1 : 0;