From nobody Tue Oct 7 22:35:33 2025 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B18D1309A65; Fri, 4 Jul 2025 13:43:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751636639; cv=none; b=NnWGQuKtno60CEdaR/GB/WKlJPeuCJ0TLnca0n38JVP/83L4fVJxQqyxBNTnZce/Ba9IQiAsbz6l4/0e8oEtEA0I0uzZ8nTeEJpfAnx6kz2UTLbbiKajeoG68wTGycAZpMJqQXIYuXpmZPNou4MPG3djXkeZpOIvCFQSLGGreDw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751636639; c=relaxed/simple; bh=1tma4K7d+Qt/1ub4E/c6PqwxT6BbFRRAWVL2Lb5LT9M=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=MGFPDrOcPwJR+Yx5xYMsSqcCd6h76Y3mCPAskhujE7mFawxRAmTsWrBsBSnFagNeu6Z/JcUYXyOAIcE4qmEVevq5oJC4GvDP8Bri3zyBmkqpvHKXEdsuZf5GXk1Kd2u9UyjbtumLG7kjINOhF57vHHJ03LOmWOexdtuv+nMjs/k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=QB8jkdEL; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=oaZ2OGZU; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="QB8jkdEL"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="oaZ2OGZU" From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1751636636; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=A6LoX/VJ5O0HxDxeU6ZWJrt82v0DtEHPKVNDvEjviIs=; b=QB8jkdELCn0/0Sjg4u8vLmZTgIGTQXr8TgPRp+DyqDseNblzje+o6GLcWhPp2mY9m7R0me sfxfQIvNyM+Owujy/bwNNpRFfYfTbvhe3IfI7LhBqMQ6ySfCEG1+wIgBVyDoWneot8Iq87 Yr/py3hRbTgJ/jwiRUdhbrewE0tEtuF5J5ONewCkQLQPnZRjo2Xj8vLDPbw6nM40HZgNh1 ugClkJbB4sAaAn+xqeqbUWvdxC5rL+aDFkD8S5x5epfD38Bc9cGgIxRGe9OBnSS9gZsOif skIMGGepUd2knS1bzYJ9NY5RnJOtMeUUH/OhB17O0z7hZPUxkde2NnfXnjR9Rg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1751636636; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=A6LoX/VJ5O0HxDxeU6ZWJrt82v0DtEHPKVNDvEjviIs=; b=oaZ2OGZUjmcFm6XzbhwsFsqGZ82RPnxd0ebSJ6AY3dZQIdkmchWlpnvD3tXNo5GLjRdLbJ sEAuX5B1UIekkVBQ== Date: Fri, 04 Jul 2025 15:43:12 +0200 Subject: [PATCH 1/2] selftests/nolibc: create /dev/full when running as PID 1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250704-nolibc-printf-error-v1-1-74b7a092433b@linutronix.de> References: <20250704-nolibc-printf-error-v1-0-74b7a092433b@linutronix.de> In-Reply-To: <20250704-nolibc-printf-error-v1-0-74b7a092433b@linutronix.de> To: Willy Tarreau , =?utf-8?q?Thomas_Wei=C3=9Fschuh?= , Shuah Khan , "Paul E. McKenney" Cc: linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Developer-Signature: v=1; a=ed25519-sha256; t=1751636627; l=1306; i=thomas.weissschuh@linutronix.de; s=20240209; h=from:subject:message-id; bh=1tma4K7d+Qt/1ub4E/c6PqwxT6BbFRRAWVL2Lb5LT9M=; b=8S651JVgAW8VjkWD1Cnzz3VKDzGQgnsGXLBndV/felVhBMXBrcQnk03XX/tmERDUWfQyDFIJJ TDz+usA9TMmDToUdvL9Mw/RHRnoIMOwoJ63I9vqQaidk4Clm8LHGgAD X-Developer-Key: i=thomas.weissschuh@linutronix.de; a=ed25519; pk=pfvxvpFUDJV2h2nY0FidLUml22uGLSjByFbM6aqQQws= An upcoming testcase will use /dev/full. Make sure it is always present. Signed-off-by: Thomas Wei=C3=9Fschuh Acked-by: Willy Tarreau --- tools/testing/selftests/nolibc/nolibc-test.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/s= elftests/nolibc/nolibc-test.c index b5bca1dcf36e95a576ca9ffba4f7c213978a3f35..929b966099b369aeca6d43002eb= b0a160674dddc 100644 --- a/tools/testing/selftests/nolibc/nolibc-test.c +++ b/tools/testing/selftests/nolibc/nolibc-test.c @@ -1777,12 +1777,14 @@ int prepare(void) if (stat("/dev/.", &stat_buf) =3D=3D 0 || mkdir("/dev", 0755) =3D=3D 0) { if (stat("/dev/console", &stat_buf) !=3D 0 || stat("/dev/null", &stat_buf) !=3D 0 || - stat("/dev/zero", &stat_buf) !=3D 0) { + stat("/dev/zero", &stat_buf) !=3D 0 || + stat("/dev/full", &stat_buf) !=3D 0) { /* try devtmpfs first, otherwise fall back to manual creation */ if (mount("/dev", "/dev", "devtmpfs", 0, 0) !=3D 0) { mknod("/dev/console", 0600 | S_IFCHR, makedev(5, 1)); mknod("/dev/null", 0666 | S_IFCHR, makedev(1, 3)); mknod("/dev/zero", 0666 | S_IFCHR, makedev(1, 5)); + mknod("/dev/full", 0666 | S_IFCHR, makedev(1, 7)); } } } --=20 2.50.0 From nobody Tue Oct 7 22:35:33 2025 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 79EC3309DCC; Fri, 4 Jul 2025 13:43:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751636641; cv=none; b=ElPRV1rNycanpTU7OcKnLFgcwesxPMoFSP7N9M78OAsWy3dH08++McC7qZpKXKXT1yborMqAMHNP7Jxl54nI5g+k55FO2kaL/m0ZAidJPDzdJdHEOzuoYj+o+h92mLpHRUEyje9B+O6o9wAG6tyebDEmO+zm3+Tgg79YwhTSky0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751636641; c=relaxed/simple; bh=iyflMMcaww0TaUxIqv5bhmdY1+EB8uHiVyLkjVNtbmQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ZLW2CUl4ailut6xpwfjq/nlbUqVidnq/rj4hfK0pZnvq/D2Fn1oP/BtItlD/wy6rP2DL9XDBAoKeO/CNFSZBiC/c26SUGf2zlARjVp0g5MNtx9wHMm8o2hvlNGS5i+DmpHFX1c7vHk76OzovSjkNKmK9hM9JIK5NCRJ1ZyHWYvM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=rYFVQfVM; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=g0tO88ty; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="rYFVQfVM"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="g0tO88ty" From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1751636636; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7n6+lL1C8Ihfql4cv8oByCjEskhz1uNdcFSsnzh03nU=; b=rYFVQfVM/TKJXzTAaMVv9SxUNf5aWULBmV2rc8Vq2WRxNImdeXf63jyCoy7w/HIQJdaoBN 0rGa4/1rwtlFud5KB91uqOAVaJ0908cUmHd12YSSvtQujPJFkMP0q3ZOnvZcYHJISy14kL lLseEwhCJAylj7Fbl4BdF30+4K+hjqFwLCrfEKMmJkaVdfOcBiAQA/c8BSaIgvmf/oWVOn Nutd2LuRfHORd1wuQvy38IDsctP9Hz8im1sOqR3e0X5Wp1bB8jwLr4obwB7eUOF3cmQ/5O oTC8tgaohhwpb9P0ocy2x/jtMNK1VD8zJlj+gorpJ/B1lYPCLyqqgOFqQmjHxw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1751636636; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7n6+lL1C8Ihfql4cv8oByCjEskhz1uNdcFSsnzh03nU=; b=g0tO88tyvGX+T4EQfkgCZ06GxlmRSYAmT59ruAZcMPWCIKvgCVDg4nAXEg2gG7JbvsWvf7 P5Nb56yAgtKRYoCA== Date: Fri, 04 Jul 2025 15:43:13 +0200 Subject: [PATCH 2/2] selftests/nolibc: correctly report errors from printf() and friends Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250704-nolibc-printf-error-v1-2-74b7a092433b@linutronix.de> References: <20250704-nolibc-printf-error-v1-0-74b7a092433b@linutronix.de> In-Reply-To: <20250704-nolibc-printf-error-v1-0-74b7a092433b@linutronix.de> To: Willy Tarreau , =?utf-8?q?Thomas_Wei=C3=9Fschuh?= , Shuah Khan , "Paul E. McKenney" Cc: linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Developer-Signature: v=1; a=ed25519-sha256; t=1751636627; l=2397; i=thomas.weissschuh@linutronix.de; s=20240209; h=from:subject:message-id; bh=iyflMMcaww0TaUxIqv5bhmdY1+EB8uHiVyLkjVNtbmQ=; b=vlqXtG0vZzOuAK5oipWe+2Nkn/Dq/7rTG5mSwe6qGxTYsltBGHKy2CDC6OcU68Hcbl7E7iTUb /M/6gH+5cbgDbx8WJAgUbrG7Nq0hYR6e0z0cIDHn79lm9O/ZprcwTfN X-Developer-Key: i=thomas.weissschuh@linutronix.de; a=ed25519; pk=pfvxvpFUDJV2h2nY0FidLUml22uGLSjByFbM6aqQQws= When an error is encountered by printf() it needs to be reported. errno() is already set by the callback. sprintf() is different, but that keeps working and is already tested. Also add a new test. Fixes: 7e4346f4a3a6 ("tools/nolibc/stdio: add a minimal [vf]printf() implem= entation") Signed-off-by: Thomas Wei=C3=9Fschuh Acked-by: Willy Tarreau --- tools/include/nolibc/stdio.h | 4 ++-- tools/testing/selftests/nolibc/nolibc-test.c | 23 +++++++++++++++++++++++ 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/tools/include/nolibc/stdio.h b/tools/include/nolibc/stdio.h index c470d334ef3f410d0584e01045d380347d61ad95..7630234408c584a560b059f0a7e= 30d407d186f17 100644 --- a/tools/include/nolibc/stdio.h +++ b/tools/include/nolibc/stdio.h @@ -358,11 +358,11 @@ int __nolibc_printf(__nolibc_printf_cb cb, intptr_t s= tate, size_t n, const char n -=3D w; while (width-- > w) { if (cb(state, " ", 1) !=3D 0) - break; + return -1; written +=3D 1; } if (cb(state, outstr, w) !=3D 0) - break; + return -1; } =20 written +=3D len; diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/s= elftests/nolibc/nolibc-test.c index 929b966099b369aeca6d43002ebb0a160674dddc..2835f65bda30ffabde749f42a6d= 3dfecc9b555fd 100644 --- a/tools/testing/selftests/nolibc/nolibc-test.c +++ b/tools/testing/selftests/nolibc/nolibc-test.c @@ -1661,6 +1661,28 @@ int test_strerror(void) return 0; } =20 +static int test_printf_error(void) +{ + int fd, ret, saved_errno; + + fd =3D open("/dev/full", O_RDWR); + if (fd =3D=3D -1) + return 1; + + errno =3D 0; + ret =3D dprintf(fd, "foo"); + saved_errno =3D errno; + close(fd); + + if (ret !=3D -1) + return 2; + + if (saved_errno !=3D ENOSPC) + return 3; + + return 0; +} + static int run_printf(int min, int max) { int test; @@ -1690,6 +1712,7 @@ static int run_printf(int min, int max) CASE_TEST(width_trunc); EXPECT_VFPRINTF(25, " ", "%2= 5d", 1); break; CASE_TEST(scanf); EXPECT_ZR(1, test_scanf()); break; CASE_TEST(strerror); EXPECT_ZR(1, test_strerror()); break; + CASE_TEST(printf_error); EXPECT_ZR(1, test_printf_error()); break; case __LINE__: return ret; /* must be last */ /* note: do not set any defaults so as to permit holes above */ --=20 2.50.0