backport posix_fallocate fix in case

posix_fallocate returns an error.
This commit is contained in:
Frank Kardel 2020-10-12 20:43:05 +02:00
parent 2d7beee4df
commit 7a50165b7d
2 changed files with 15 additions and 16 deletions

View File

@ -4,6 +4,6 @@ SHA1 (frr-7.4.tar.gz) = 97ee20790e59d672d6ce41a147dad7639de65e91
RMD160 (frr-7.4.tar.gz) = 6c8dbf18b9d59c6518d57b2a1869d827ff194448
SHA512 (frr-7.4.tar.gz) = d5c4e3bf7527bc094a65b24fda1b7a86f87e996fb3d98abe646e878274e0ca30f45aefca76816414b9d44607616cd2eb8ad118045b8986a92dd130f3a704162f
Size (frr-7.4.tar.gz) = 6074854 bytes
SHA1 (patch-lib_zlog.c) = 00e70b92eae8e399ac3083fec815350463a6b0e0
SHA1 (patch-lib_zlog.c) = 206b6c48129d8122bf23d245f3d86284e5057fee
SHA1 (patch-pkgsrc_zebra.sh.in) = b692068722ee5a06e4fd975edbf0a724dfc03ac9
SHA1 (patch-zebra_ioctl.c) = 99b7606564f4dc620df997889156b5c09f7fb396

View File

@ -1,22 +1,21 @@
$NetBSD$
As NetBSD currently (2020) implements
posix_fallocate() but no file system supports it
we need to stay away from posix_fallocate.
Additionally the present frr code relies on
negative errnos (as found e.g. in Linux) and
also did not find in the manual that
posix_fallocate() return the errno and does not set
errno.
backport posix_fallocate fix in case
posix_fallocate returns an error.
--- lib/zlog.c.orig 2020-06-30 11:08:57.000000000 +0000
+++ lib/zlog.c
@@ -245,7 +246,7 @@ void zlog_tls_buffer_init(void)
}
@@ -246,10 +246,10 @@ void zlog_tls_buffer_init(void)
fchown(mmfd, zlog_uid, zlog_gid);
-#ifdef HAVE_POSIX_FALLOCATE
+#if defined(HAVE_POSIX_FALLOCATE) && !defined(__NetBSD__)
if (posix_fallocate(mmfd, 0, TLS_LOG_BUF_SIZE) < 0) {
#else
if (ftruncate(mmfd, TLS_LOG_BUF_SIZE) < 0) {
#ifdef HAVE_POSIX_FALLOCATE
- if (posix_fallocate(mmfd, 0, TLS_LOG_BUF_SIZE) < 0) {
-#else
- if (ftruncate(mmfd, TLS_LOG_BUF_SIZE) < 0) {
+ if (posix_fallocate(mmfd, 0, TLS_LOG_BUF_SIZE) != 0)
+ /* note next statement is under above if() */
#endif
+ if (ftruncate(mmfd, TLS_LOG_BUF_SIZE) < 0) {
zlog_err("failed to allocate thread log buffer \"%s\": %s",
mmpath, strerror(errno));
goto out_anon_unlink;