View | Details | Raw Unified | Return to bug 260181 | Differences between
and this patch

Collapse All | Expand All

(-)b/devel/libfixposix/Makefile (-1 / +2 lines)
Lines 1-9 Link Here
1
PORTNAME=	libfixposix
1
PORTNAME=	libfixposix
2
DISTVERSIONPREFIX=	v
2
DISTVERSIONPREFIX=	v
3
DISTVERSION=	0.4.3
3
DISTVERSION=	0.4.3
4
PORTREVISION=	1
4
CATEGORIES=	devel
5
CATEGORIES=	devel
5
6
6
MAINTAINER=	ports@FreeBSD.org
7
MAINTAINER=	ports@shiori.com.br
7
COMMENT=	Replacement for inconsistent parts of POSIX
8
COMMENT=	Replacement for inconsistent parts of POSIX
8
9
9
LICENSE=	BSL
10
LICENSE=	BSL
(-)b/devel/libfixposix/files/patch-src_lib_sendfile.c (-1 / +44 lines)
Added Link Here
0
- 
1
Changes `lfp_sendfile' so it returns the number of bytes sent,
2
mimicking Linux sendfile(2).
3
4
Submited to upstream by Vasily Postnicov (shamaz.mazum@gmail.com),
5
see https://github.com/sionescu/libfixposix/pull/18.
6
7
--- src/lib/sendfile.c.orig	2018-02-19 22:24:10 UTC
8
+++ src/lib/sendfile.c
9
@@ -38,6 +38,7 @@ int sendfile(int, int, off_t, off_t *, void *, int);
10
 #endif
11
 
12
 #include <stdlib.h>
13
+#include <errno.h>
14
 
15
 DSO_PUBLIC ssize_t
16
 lfp_sendfile(int out_fd, int in_fd, off_t offset, size_t nbytes)
17
@@ -46,18 +47,21 @@ lfp_sendfile(int out_fd, int in_fd, off_t offset, size
18
 # if defined(__linux__)
19
     off_t off = offset;
20
     return (ssize_t) sendfile(out_fd, in_fd, &off, nbytes);
21
-# elif defined(__FreeBSD__)
22
-    return (ssize_t) sendfile(in_fd, out_fd, offset, nbytes, NULL, NULL, SF_MNOWAIT);
23
-# elif defined(__DragonFly__)
24
-    return (ssize_t) sendfile(in_fd, out_fd, offset, nbytes, NULL, NULL, 0);
25
+# elif defined(__FreeBSD__) || defined(__DragonFly__)
26
+    off_t sbytes;
27
+    int res = sendfile(in_fd, out_fd, offset, nbytes, NULL, &sbytes, 0);
28
+    if (res == 0) { return sbytes; }
29
+    return res;
30
 # elif defined(__APPLE__)
31
     off_t len = nbytes;
32
-    return (ssize_t) sendfile(in_fd, out_fd, offset, &len, NULL, 0);
33
+    int res = sendfile(in_fd, out_fd, offset, &len, NULL, 0);
34
+    if (res == 0) { return len; }
35
+    return -1;
36
 # else
37
 #  error "It appears that this OS has sendfile(), but LFP doesn't use it at the moment"
38
 #  error "Please send an email to iolib-devel@common-lisp.net"
39
 # endif
40
 #else
41
-    return ENOSYS;
42
+    SYSERR(ENOSYS);
43
 #endif
44
 }

Return to bug 260181