summaryrefslogtreecommitdiff
path: root/src/libstddjb/iobufferk_isworking.c
blob: f671f8136b5c649202351929a164be5d8c13173e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/* ISC license. */

#include <skalibs/sysdeps.h>

#ifdef SKALIBS_HASSPLICE

#include <skalibs/nonposix.h>
#include <errno.h>
#include <fcntl.h>
#include <skalibs/iobuffer.h>

int iobufferk_isworking (iobufferk *k)
{
 /* for now splice() with a length of 0 returns 0 no matter what, so this */
 /* test is useless. splice() should test the underlying filesystems even */
 /* if the length is 0. */

# if 0

  register int e = errno ;
  if (splice(k->fd[0], 0, k->p[1], 0, 0, 0) < 0) goto no ;
  if (splice(k->p[0], 0, k->fd[1], 0, 0, 0) < 0) goto no ;
  errno = e ;
  return 1 ;
 no:
  errno = e ;
  return 0 ;

# else

  (void)k ;
  return 1 ;

# endif
}

#else

#include <skalibs/iobuffer.h>

int iobufferk_isworking (iobufferk *k)
{
  (void)k ;
  return 0 ;
}

#endif