From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pg1-f173.google.com (mail-pg1-f173.google.com [209.85.215.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7015733D6F9 for ; Thu, 2 Jul 2026 08:51:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.173 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782982277; cv=none; b=ZVAJJf8GJuhUkpqJUUnLIbEv4y0c7tLoRFMrwVk/XXp1Lz41yhlAMIoII3EGix3cycAd1AupifGXqlExuoIpQhc9dxnF4YPxCfVCqu/jmbrlJ3yud0tc8yLL7Af+b0NlTBKAA3X5ItceaNp+PjFk0zwFSa+VJqZbpDBtx6W4Snc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782982277; c=relaxed/simple; bh=Y1nokLQZA7KAt3ef8RQwtA1UVZnd1u08Ow1TvgA4mLo=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=LC6aJIILaey+YnYnio9hMA/URo2a+AaVnkRuHlcOwKlW+lcJZCA48R8qYbcv4lLeQLr2KrV1ys+wTV68vhqfz7QsX8cfHfoWK3JdihBaQ++R/3WlBZaIWnGiG12upotJ6qygzEQVPqHHrPtJJUlV/4HiX6U9HB2tkJri9XIjnQk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=thingy.jp; spf=pass smtp.mailfrom=0x0f.com; dkim=pass (1024-bit key) header.d=thingy.jp header.i=@thingy.jp header.b=gB0Gnyup; arc=none smtp.client-ip=209.85.215.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=thingy.jp Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=0x0f.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=thingy.jp header.i=@thingy.jp header.b="gB0Gnyup" Received: by mail-pg1-f173.google.com with SMTP id 41be03b00d2f7-c969ad04c1dso667464a12.0 for ; Thu, 02 Jul 2026 01:51:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thingy.jp; s=google; t=1782982274; x=1783587074; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=vOqKceEDB+jPjjmUS2i3WoUxb76PAci52/Oa5C7TjX8=; b=gB0Gnyupw9xU7LtQXg3Y/na19d4MyBaCk7jKd5jHJpXMmtFmIpY1hei172cvhAUW1t tWsIOdbyOWz04YG3ltWGZJNySPOns0mbsJiVtv1xWMCVnQQ7ttd1mG7Nl+35ivvcryYo mohIKoZhnxvs5I/ndk9MpEFDP3TgQMR0gLTvg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782982274; x=1783587074; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=vOqKceEDB+jPjjmUS2i3WoUxb76PAci52/Oa5C7TjX8=; b=OFx/GtIt8wFayQlIqm1xDnyDrUK3LiUeQwFZ8rU5JZAFgItvLRSLneCS5Gd5qjmmvj /SRoq6CKgeTF5YT0Xy5DZvXxLQimS2DPH1SHXPjIbTDxa9AY8ITcK6zT3LTyorQxZ/Gp fwMT+HuYkOwOgzqn3mCeg6FCMGenPXA1JTkZa/P8sqiZXif0F65NVIfhqIq8E4Ml/v95 S3zay7/0oz/0ZXGR3uoGACz4PoDji0xM4VpgXslnaRPSENs5mwEU/f+JOXAsoxIzr7j0 5TC7d9sAn0OexopyEi3l8QMlnR/RvDiZ4bI2llBgVjTnJcKEe5mxGFkCSnkHW0y9vTR4 s3HA== X-Gm-Message-State: AOJu0YwTFh1usgHTzBiv+19dG+TajtTh+IYnFVxff5HKzArWR7XcdAMO 6m+aK5mMh60UrqqBTqHNlEH581fXgUNFb8MZ2E4yr2YxL0emvvLrkUhr/2QrW12hKjzbzjCf3uY 9zSul X-Gm-Gg: AfdE7ckm1ydmOm6tNcI2Lieb1MSkfnqzErrM+aYw4jCeS+8pufj5Z3uhKWpOYwbCPpA UZnFisYCZ1CT0xlvUyqST3Ltu9kaqp3sTTPEuWbIIDF/tXP4mLYDDqH7Cke+BXXHyJPnxeGWQbS bqq1ijdu0t3QPafqEDH4nTKjjEP+i1GuPdWs2ZnZJuCd7O78iVayIHnC1zDOIrHfGTf72X+dklN Yp0AfCNcYcGf+MrcKt1luvSM7DfdkFWcacmsCwetnJ8i9ioqV4nmKdFZCdUR4CSo1//32kalB8q R3k4Dl5HBZCuB4dXlOrxY6Ly7IoNcrEkNA5BN3645xDTciAph57P4VAwghk1IX1SSu76yHYm3ws BFuZdbnQbfOHemTTOwJOGTnRuxbqkYXsehEHmOC4Y6KuOVQ6FmJGJ1cgIl9n7GBFxFZY4w/2wI7 4Ug99voLyrpU6Dr2822NQrprDUtA== X-Received: by 2002:a05:6300:2211:b0:3b4:b275:c5b1 with SMTP id adf61e73a8af0-3bfed24e533mr5913098637.26.1782982274308; Thu, 02 Jul 2026 01:51:14 -0700 (PDT) Received: from kinako.work.home.arpa ([2400:4162:2428:2ffe:a973:53e4:1a28:8545]) by smtp.googlemail.com with ESMTPSA id 41be03b00d2f7-c9e8f4cd4b1sm944649a12.12.2026.07.02.01.51.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Jul 2026 01:51:13 -0700 (PDT) From: Daniel Palmer To: w@1wt.eu, linux@weissschuh.net Cc: linux-kernel@vger.kernel.org, Daniel Palmer Subject: [PATCH v3 0/3] nolibc: Add getcwd() and readlink() Date: Thu, 2 Jul 2026 17:50:58 +0900 Message-ID: <20260702085101.3304547-1-daniel@thingy.jp> X-Mailer: git-send-email 2.53.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit I needed getcwd() for something. So I added that, then realised I also needed readlink() to test the result of getcwd(). This adds getcwd() and readlink() then adds a test that uses both. Note: getcwd() has some behaviour where if the current directory is unreachable then the kernel returns "(unreachable)" and this needs some special handling. I checked what musl was doing for this. It seems pretty difficult to test and maybe needs some calls nolibc doesn't have yet. Basically: It looks right but there is no test. v3: - Addressed the issues noted by sashiko (impressed by how good it is now) - Use __LINE__ for the error numbers in the test to make it easy to spot where it broke. - Redid the nolibc test for all archs, all passed. v2: - Addressed Thomas' comments for readlink() and making the test depend on proc. - Filled out getcwd() so it matches what musl is doing. - Expanded the test a little to try to cover passing bad arguments. Daniel Palmer (3): tools/nolibc: unistd: Add getcwd() tools/nolibc: unistd: Add readlink() selftests/nolibc: Add test for getcwd() and readlink() tools/include/nolibc/unistd.h | 58 ++++++++++++++++++++ tools/testing/selftests/nolibc/nolibc-test.c | 53 ++++++++++++++++++ 2 files changed, 111 insertions(+) -- 2.53.0