git: c67821f8abb9 - main - devel/libfixposix: Import upstream fix

From: Renato Botelho <garga_at_FreeBSD.org>
Date: Wed, 22 Dec 2021 17:02:37 UTC
The branch main has been updated by garga:

URL: https://cgit.FreeBSD.org/ports/commit/?id=c67821f8abb937d459cfacac8d0afb0ca7ea0121

commit c67821f8abb937d459cfacac8d0afb0ca7ea0121
Author:     Filipe da Silva Santos <ports@shiori.com.br>
AuthorDate: 2021-12-22 16:43:37 +0000
Commit:     Renato Botelho <garga@FreeBSD.org>
CommitDate: 2021-12-22 17:02:33 +0000

    devel/libfixposix: Import upstream fix
    
    Changes `lfp_sendfile()' so it mimics Linux sendfile(2), returning on
    success the number of bytes, instead of just 0.  While here, adopt the
    port.
    
    PR:             260181
    Obtained from:  https://github.com/sionescu/libfixposix/commit/fc5bbe41a574e668ccfafb0f15dddd28f6decd31
    Sponsored by:   Rubicon Communications, LLC ("Netgate")
---
 devel/libfixposix/Makefile                       |  3 +-
 devel/libfixposix/files/patch-src_lib_sendfile.c | 44 ++++++++++++++++++++++++
 2 files changed, 46 insertions(+), 1 deletion(-)

diff --git a/devel/libfixposix/Makefile b/devel/libfixposix/Makefile
index eab4ef76c2f2..0bf0e398cafc 100644
--- a/devel/libfixposix/Makefile
+++ b/devel/libfixposix/Makefile
@@ -1,9 +1,10 @@
 PORTNAME=	libfixposix
 DISTVERSIONPREFIX=	v
 DISTVERSION=	0.4.3
+PORTREVISION=	1
 CATEGORIES=	devel
 
-MAINTAINER=	ports@FreeBSD.org
+MAINTAINER=	ports@shiori.com.br
 COMMENT=	Replacement for inconsistent parts of POSIX
 
 LICENSE=	BSL
diff --git a/devel/libfixposix/files/patch-src_lib_sendfile.c b/devel/libfixposix/files/patch-src_lib_sendfile.c
new file mode 100644
index 000000000000..c69cc84fa1ed
--- /dev/null
+++ b/devel/libfixposix/files/patch-src_lib_sendfile.c
@@ -0,0 +1,44 @@
+Changes `lfp_sendfile' so it returns the number of bytes sent,
+mimicking Linux sendfile(2).
+
+Submited to upstream by Vasily Postnicov (shamaz.mazum@gmail.com),
+see https://github.com/sionescu/libfixposix/pull/18.
+
+--- src/lib/sendfile.c.orig	2018-02-19 22:24:10 UTC
++++ src/lib/sendfile.c
+@@ -38,6 +38,7 @@ int sendfile(int, int, off_t, off_t *, void *, int);
+ #endif
+ 
+ #include <stdlib.h>
++#include <errno.h>
+ 
+ DSO_PUBLIC ssize_t
+ lfp_sendfile(int out_fd, int in_fd, off_t offset, size_t nbytes)
+@@ -46,18 +47,21 @@ lfp_sendfile(int out_fd, int in_fd, off_t offset, size
+ # if defined(__linux__)
+     off_t off = offset;
+     return (ssize_t) sendfile(out_fd, in_fd, &off, nbytes);
+-# elif defined(__FreeBSD__)
+-    return (ssize_t) sendfile(in_fd, out_fd, offset, nbytes, NULL, NULL, SF_MNOWAIT);
+-# elif defined(__DragonFly__)
+-    return (ssize_t) sendfile(in_fd, out_fd, offset, nbytes, NULL, NULL, 0);
++# elif defined(__FreeBSD__) || defined(__DragonFly__)
++    off_t sbytes;
++    int res = sendfile(in_fd, out_fd, offset, nbytes, NULL, &sbytes, 0);
++    if (res == 0) { return sbytes; }
++    return res;
+ # elif defined(__APPLE__)
+     off_t len = nbytes;
+-    return (ssize_t) sendfile(in_fd, out_fd, offset, &len, NULL, 0);
++    int res = sendfile(in_fd, out_fd, offset, &len, NULL, 0);
++    if (res == 0) { return len; }
++    return -1;
+ # else
+ #  error "It appears that this OS has sendfile(), but LFP doesn't use it at the moment"
+ #  error "Please send an email to iolib-devel@common-lisp.net"
+ # endif
+ #else
+-    return ENOSYS;
++    SYSERR(ENOSYS);
+ #endif
+ }