{"id":2219477,"url":"http://patchwork.ozlabs.org/api/1.0/patches/2219477/?format=json","project":{"id":8,"url":"http://patchwork.ozlabs.org/api/1.0/projects/8/?format=json","name":"Linux ext4 filesystem development","link_name":"linux-ext4","list_id":"linux-ext4.vger.kernel.org","list_email":"linux-ext4@vger.kernel.org","web_url":null,"scm_url":null,"webscm_url":null},"msgid":"<20260403040328.2385083-2-tytso@mit.edu>","date":"2026-04-03T04:03:26","name":"[1/3] libsupport: fix portability issues with the bthread.c","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"658345b90c23f829a1fd74486ddc3a88244715ae","submitter":{"id":350,"url":"http://patchwork.ozlabs.org/api/1.0/people/350/?format=json","name":"Theodore Ts'o","email":"tytso@mit.edu"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/linux-ext4/patch/20260403040328.2385083-2-tytso@mit.edu/mbox/","series":[{"id":498585,"url":"http://patchwork.ozlabs.org/api/1.0/series/498585/?format=json","date":"2026-04-03T04:03:25","name":"Fix portability issues on MacOS","version":1,"mbox":"http://patchwork.ozlabs.org/series/498585/mbox/"}],"check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2219477/checks/","tags":{},"headers":{"Return-Path":"\n <SRS0=lXvI=CC=vger.kernel.org=linux-ext4+bounces-15615-patchwork-incoming=ozlabs.org@ozlabs.org>","X-Original-To":["incoming@patchwork.ozlabs.org","linux-ext4@vger.kernel.org"],"Delivered-To":["patchwork-incoming@legolas.ozlabs.org","patchwork-incoming@ozlabs.org"],"Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=mit.edu header.i=@mit.edu header.a=rsa-sha256\n header.s=outgoing header.b=Vt6EZ7yk;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=ozlabs.org\n (client-ip=150.107.74.76; helo=mail.ozlabs.org;\n envelope-from=srs0=lxvi=cc=vger.kernel.org=linux-ext4+bounces-15615-patchwork-incoming=ozlabs.org@ozlabs.org;\n receiver=patchwork.ozlabs.org)","gandalf.ozlabs.org;\n arc=pass smtp.remote-ip=172.105.105.114 arc.chain=subspace.kernel.org","gandalf.ozlabs.org;\n dmarc=pass (p=none dis=none) header.from=mit.edu","gandalf.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=mit.edu header.i=@mit.edu header.a=rsa-sha256\n header.s=outgoing header.b=Vt6EZ7yk;\n\tdkim-atps=neutral","gandalf.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org\n (client-ip=172.105.105.114; helo=tor.lore.kernel.org;\n envelope-from=linux-ext4+bounces-15615-patchwork-incoming=ozlabs.org@vger.kernel.org;\n receiver=ozlabs.org)","smtp.subspace.kernel.org;\n\tdkim=pass (2048-bit key) header.d=mit.edu header.i=@mit.edu\n header.b=\"Vt6EZ7yk\"","smtp.subspace.kernel.org;\n arc=none smtp.client-ip=18.9.28.11","smtp.subspace.kernel.org;\n dmarc=pass (p=none dis=none) header.from=mit.edu","smtp.subspace.kernel.org;\n spf=pass smtp.mailfrom=mit.edu"],"Received":["from mail.ozlabs.org (gandalf.ozlabs.org [150.107.74.76])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fn4pq10GBz1xtJ\n\tfor <incoming@patchwork.ozlabs.org>; Fri, 03 Apr 2026 15:04:03 +1100 (AEDT)","from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3])\n\tby gandalf.ozlabs.org (Postfix) with ESMTP id 4fn4pq0XSyz4w0Q\n\tfor <incoming@patchwork.ozlabs.org>; Fri, 03 Apr 2026 15:04:03 +1100 (AEDT)","by gandalf.ozlabs.org (Postfix)\n\tid 4fn4pq0VBdz4w9h; Fri, 03 Apr 2026 15:04:03 +1100 (AEDT)","from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519)\n\t(No client certificate requested)\n\tby gandalf.ozlabs.org (Postfix) with ESMTPS id 4fn4pl5Twnz4w0Q\n\tfor <patchwork-incoming@ozlabs.org>; Fri, 03 Apr 2026 15:03:59 +1100 (AEDT)","from smtp.subspace.kernel.org (conduit.subspace.kernel.org\n [100.90.174.1])\n\tby tor.lore.kernel.org (Postfix) with ESMTP id DAB7A3057C4D\n\tfor <patchwork-incoming@ozlabs.org>; Fri,  3 Apr 2026 04:03:47 +0000 (UTC)","from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id 28A0622E3F0;\n\tFri,  3 Apr 2026 04:03:43 +0000 (UTC)","from outgoing.mit.edu (outgoing-auth-1.mit.edu [18.9.28.11])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby smtp.subspace.kernel.org (Postfix) with ESMTPS id 85970282F0F\n\tfor <linux-ext4@vger.kernel.org>; Fri,  3 Apr 2026 04:03:41 +0000 (UTC)","from trampoline.thunk.org\n (pool-173-48-112-174.bstnma.fios.verizon.net [173.48.112.174])\n\t(authenticated bits=0)\n        (User authenticated as tytso@ATHENA.MIT.EDU)\n\tby outgoing.mit.edu (8.14.7/8.12.4) with ESMTP id 63343XgF005245\n\t(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT);\n\tFri, 3 Apr 2026 00:03:34 -0400","by trampoline.thunk.org (Postfix, from userid 15806)\n\tid 7570C2E00D1; Fri, 03 Apr 2026 00:03:33 -0400 (EDT)"],"ARC-Seal":["i=2; a=rsa-sha256; d=ozlabs.org; s=201707; t=1775189043; cv=pass;\n\tb=hVsmKB6uacj+T6X5sQCQ0War2MhtAjQNNTR29TpMG8BC3yrX/d4XYhAKyjRffHcque5+9TUNMiTSayHRFmjWc8MSgIcVHIbFdEd4uZB+1Tt6hLPg312sxO6rqMjC5CEmsnPAbd9osCxWAwcd1GNQH32RUP+i8JRaDV5hZF/VuS0H2m01z1/UX1IryhZzYaWSL7LtA58ohKnIVZ1B41DfNETa9Q1WRRXfFyFB3dkDZ3nsx4FO8Zb8CjdShOfvUVsf/F18D3JUMLTgOy9oYCMvuKXY6e/whWJEy94OkOg7zAv5zUWY3RoPQRXlYJ6J/zBrVKPw+QXhDj6danrEiKu+Fw==","i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1775189023; cv=none;\n b=O/dbVMI6z9lo77gLp9LQZ62g5cTkcUFgPnbEunUDpyWDzlbOykYoFpalPtSbrk5p60VZ53NGISBSV4buyJe3ZhqIutcLTO4u7h841AtFohoA87jSvuquY+MhpfGkskWKVkjNP0SvikMSsqaA1Rn9yr0vqxfmI/yIH21aPG5nmME="],"ARC-Message-Signature":["i=2; a=rsa-sha256; d=ozlabs.org; s=201707;\n\tt=1775189043; c=relaxed/relaxed;\n\tbh=8a9XubKYofDKTEsqwFWca7AWNfZeMqbD+7hjz0rLfBE=;\n\th=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:\n\t MIME-Version;\n b=A8BJNH3ZiZjwl2IBusdltZfX0s7J2Uk/7lwdb4k9IwUZMoVaV3lWRCdyO15cOvzSvvG/Z+3B64ZD1Tf8nZzyqBDxmYxHX28ZmlAiFC1PTCxxlWkDclTj8g9oF8IRS8cCSrPfiJkUrXnJcNKEOMMFUpEXRWfOEAViCO/Ho2uAgDX9QkxFeNFa06WRgc5gllq8p0svIIOo9UwiHP3Ts2zUKo+xofKM5CaSedJVpW85Zx4vaexh4L714wxTnPCOnWwlyhfJJ9BUO+7s5hFGLaMCdUxoN1CvMYefzy4PBZCKkAeUrBVgyxCb8rP/hp/fJkMRf3rdmpknLl5vbqLfyIHH2A==","i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1775189023; c=relaxed/simple;\n\tbh=c419BAkWp3WEZ9WnLXUoEl8hYxkxgiNB6GPEcVgsERM=;\n\th=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:\n\t MIME-Version;\n b=bZU2ALH1pCtuvMwxL7xdspPTVOPr0HqNLABqg4y4cFAJwMo39AFfTO3n+s5y20TzGXqnlQlb2Xb/ViqXa7IN/EgqCfpfMwDKzXWturn01gUP1BiSDa+HLv2MKPaWPuPuz7j29iMamv1QRCJGFZ7oyv7WxR88x+c7nW0ANVduHp8="],"ARC-Authentication-Results":["i=2; gandalf.ozlabs.org;\n dmarc=pass (p=none dis=none) header.from=mit.edu; dkim=pass (2048-bit key;\n unprotected) header.d=mit.edu header.i=@mit.edu header.a=rsa-sha256\n header.s=outgoing header.b=Vt6EZ7yk; dkim-atps=neutral;\n spf=pass (client-ip=172.105.105.114; helo=tor.lore.kernel.org;\n envelope-from=linux-ext4+bounces-15615-patchwork-incoming=ozlabs.org@vger.kernel.org;\n receiver=ozlabs.org) smtp.mailfrom=vger.kernel.org","i=1; smtp.subspace.kernel.org;\n dmarc=pass (p=none dis=none) header.from=mit.edu;\n spf=pass smtp.mailfrom=mit.edu;\n dkim=pass (2048-bit key) header.d=mit.edu header.i=@mit.edu\n header.b=Vt6EZ7yk; arc=none smtp.client-ip=18.9.28.11"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=mit.edu; s=outgoing;\n\tt=1775189015; bh=8a9XubKYofDKTEsqwFWca7AWNfZeMqbD+7hjz0rLfBE=;\n\th=From:Subject:Date:Message-ID:MIME-Version;\n\tb=Vt6EZ7ykO9VqOH7uARl4cRO0TQtGd2syGOG7qRWLgD0x48z7rGscI7dIJgEgqu59s\n\t 7rllPYJRz6gM2P6/USfpw45hMY41LOpK1If05Pb5xx9DRTu7fg/f0P7NT4m/OVzaEk\n\t aL+2tJ//+0+YotmCN9+9C+OBmr06w5XYoji/wnwS68KuBd0bSUI9+xhC4YNodYFEIR\n\t s1/yGbF9QN2j+gB6aNDMMLDP6ju3ccNKPKhQBISuDwgI8yDXErroMEkhQ83m/387wz\n\t AOefSX4N+UL+xVWb454ecs5OTv1InmltRtk0iN68wWGM8mLdWH2cWp+MIBY5+bJ4QH\n\t nCJ1JiU2dgzJQ==","From":"\"Theodore Ts'o\" <tytso@mit.edu>","To":"Ext4 Developers List <linux-ext4@vger.kernel.org>","Cc":"\"Darrick J. Wong\" <djwong@kernel.org>, \"Theodore Ts'o\" <tytso@mit.edu>","Subject":"[PATCH 1/3] libsupport: fix portability issues with the bthread.c","Date":"Fri,  3 Apr 2026 00:03:26 -0400","Message-ID":"<20260403040328.2385083-2-tytso@mit.edu>","X-Mailer":"git-send-email 2.51.0","In-Reply-To":"<20260403040328.2385083-1-tytso@mit.edu>","References":"<20260403040328.2385083-1-tytso@mit.edu>","Precedence":"bulk","X-Mailing-List":"linux-ext4@vger.kernel.org","List-Id":"<linux-ext4.vger.kernel.org>","List-Subscribe":"<mailto:linux-ext4+subscribe@vger.kernel.org>","List-Unsubscribe":"<mailto:linux-ext4+unsubscribe@vger.kernel.org>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","X-Spam-Status":"No, score=-1.2 required=5.0 tests=ARC_SIGNED,ARC_VALID,\n\tDKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DMARC_PASS,\n\tHEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,\n\tSPF_PASS autolearn=disabled version=4.0.1","X-Spam-Checker-Version":"SpamAssassin 4.0.1 (2024-03-25) on gandalf.ozlabs.org"},"content":"The function pthread_setname_np() is non-portable; that's what the\n\"np\" means.  In particular, on Mac systems, the function takes only a\nsingle argument, while on most other systems which have the function,\nit takes two arguments.\n\nAlso fix a problem where a 1-bit signed integer can only accept values\nof 0 or -1.  Change it to be a 1-bit unsigned integer, which can\naccept values of 0 or 1.  Clang will issue a warning if 1-bit signed\ninteger are used incorrectly, and fail with -Werror.\n\nSigned-off-by: Theodore Ts'o <tytso@mit.edu>\n---\n configure             |  6 ++++++\n configure.ac          |  1 +\n lib/config.h.in       | 24 +++++++++++++++---------\n lib/support/bthread.c | 12 ++++++++++--\n 4 files changed, 32 insertions(+), 11 deletions(-)","diff":"diff --git a/configure b/configure\nindex 4da5439fe..b9a82dcec 100755\n--- a/configure\n+++ b/configure\n@@ -13887,6 +13887,12 @@ if test \"x$ac_cv_func_pwrite64\" = xyes\n then :\n   printf \"%s\\n\" \"#define HAVE_PWRITE64 1\" >>confdefs.h\n \n+fi\n+ac_fn_c_check_func \"$LINENO\" \"pthread_setname_np\" \"ac_cv_func_pthread_setname_np\"\n+if test \"x$ac_cv_func_pthread_setname_np\" = xyes\n+then :\n+  printf \"%s\\n\" \"#define HAVE_PTHREAD_SETNAME_NP 1\" >>confdefs.h\n+\n fi\n ac_fn_c_check_func \"$LINENO\" \"qsort_r\" \"ac_cv_func_qsort_r\"\n if test \"x$ac_cv_func_qsort_r\" = xyes\ndiff --git a/configure.ac b/configure.ac\nindex ecef9df39..2473879fd 100644\n--- a/configure.ac\n+++ b/configure.ac\n@@ -1269,6 +1269,7 @@ AC_CHECK_FUNCS(m4_flatten([\n \tpwrite\n \tpread64\n \tpwrite64\n+\tpthread_setname_np\n \tqsort_r\n \tsecure_getenv\n \tsetmntent\ndiff --git a/lib/config.h.in b/lib/config.h.in\nindex 8ea7ec2b1..c6cbced5f 100644\n--- a/lib/config.h.in\n+++ b/lib/config.h.in\n@@ -46,9 +46,6 @@\n /* Define to the version of FUSE to use */\n #undef FUSE_USE_VERSION\n \n-/* Define to 1 if fuse supports cache_readdir */\n-#undef HAVE_FUSE_CACHE_READDIR\n-\n /* Define to 1 if you have the 'add_key' function. */\n #undef HAVE_ADD_KEY\n \n@@ -73,9 +70,6 @@\n /* Define to 1 if you have the BSD-style 'qsort_r' function. */\n #undef HAVE_BSD_QSORT_R\n \n-/* Define to 1 if PR_SET_IO_FLUSHER is present */\n-#undef HAVE_PR_SET_IO_FLUSHER\n-\n /* Define to 1 if you have the Mac OS X function\n    CFLocaleCopyPreferredLanguages in the CoreFoundation framework. */\n #undef HAVE_CFLOCALECOPYPREFERREDLANGUAGES\n@@ -87,6 +81,9 @@\n /* Define to 1 if you have the 'chflags' function. */\n #undef HAVE_CHFLAGS\n \n+/* Define to 1 if CLOCK_MONOTONIC is present */\n+#undef HAVE_CLOCK_MONOTONIC\n+\n /* Define if the GNU dcgettext() function is already present or preinstalled.\n    */\n #undef HAVE_DCGETTEXT\n@@ -136,9 +133,15 @@\n /* Define to 1 if you have the 'fsync' function. */\n #undef HAVE_FSYNC\n \n+/* Define to 1 if FS_IOC_READ_VERITY_METADATA ioctl is available */\n+#undef HAVE_FS_IOC_READ_VERITY_METADATA\n+\n /* Define to 1 if you have the 'ftruncate64' function. */\n #undef HAVE_FTRUNCATE64\n \n+/* Define to 1 if fuse supports cache_readdir */\n+#undef HAVE_FUSE_CACHE_READDIR\n+\n /* Define to 1 if you have the <fuse.h> header file. */\n #undef HAVE_FUSE_H\n \n@@ -313,6 +316,9 @@\n /* Define to 1 if you have the 'pread64' function. */\n #undef HAVE_PREAD64\n \n+/* Define to 1 if PR_SET_IO_FLUSHER is present */\n+#undef HAVE_PR_SET_IO_FLUSHER\n+\n /* Define if you have POSIX threads libraries and header files. */\n #undef HAVE_PTHREAD\n \n@@ -322,6 +328,9 @@\n /* Have PTHREAD_PRIO_INHERIT. */\n #undef HAVE_PTHREAD_PRIO_INHERIT\n \n+/* Define to 1 if you have the 'pthread_setname_np' function. */\n+#undef HAVE_PTHREAD_SETNAME_NP\n+\n /* Define to 1 if you have the 'pwrite' function. */\n #undef HAVE_PWRITE\n \n@@ -699,7 +708,4 @@\n /* Define to 1 on platforms where this makes time_t a 64-bit type. */\n #undef __MINGW_USE_VC2005_COMPAT\n \n-/* Define to 1 if CLOCK_MONOTONIC is present */\n-#undef HAVE_CLOCK_MONOTONIC\n-\n #include <dirpaths.h>\ndiff --git a/lib/support/bthread.c b/lib/support/bthread.c\nindex 936ca0f0f..87eeb1b3d 100644\n--- a/lib/support/bthread.c\n+++ b/lib/support/bthread.c\n@@ -9,6 +9,7 @@\n  * %End-Header%\n  */\n #include \"config.h\"\n+#ifdef HAVE_PTHREAD\n #include <stdlib.h>\n #include <errno.h>\n #include <pthread.h>\n@@ -33,7 +34,7 @@ struct bthread {\n \tbthread_fn_t fn;\n \tvoid *data;\n \tunsigned int period; /* seconds */\n-\tint can_join:1;\n+\tunsigned int can_join:1;\n };\n \n /* Wait for a signal or for the periodic interval */\n@@ -101,7 +102,13 @@ int bthread_create(const char *name,  bthread_fn_t fn, void *data,\n \tif (error)\n \t\tgoto out_cond;\n \n+#ifdef HAVE_PTHREAD_SETNAME_NP\n+#ifdef __APPLE__\n+\tpthread_setname_np(name);\n+#else\n \tpthread_setname_np(bt->thread, name);\n+#endif\n+#endif\n \n \t*btp = bt;\n \treturn 0;\n@@ -178,7 +185,7 @@ int bthread_cancel(struct bthread *bt)\n /* Ask the thread to cancel itself and wait for it */\n void bthread_stop(struct bthread *bt)\n {\n-\tint need_join = 0;\n+\tunsigned int need_join = 0;\n \n \tpthread_mutex_lock(&bt->lock);\n \tswitch (bt->state) {\n@@ -199,3 +206,4 @@ void bthread_stop(struct bthread *bt)\n \tif (need_join)\n \t\tpthread_join(bt->thread, NULL);\n }\n+#endif /* HAVE_PTHREAD */\n","prefixes":["1/3"]}