From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f177.google.com (mail-pl1-f177.google.com [209.85.214.177]) (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 143684192FF for ; Tue, 30 Jun 2026 13:24:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.177 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782825875; cv=none; b=PaO7Tf4Wpq0ycpiSLnUkXXYHZPPX/HwrgXrwGNP5sxoT476om+yvppAj1eZMkMWotb0dh+7LdMacdpQajgauorSnuM8wk+J9hjVH6/Y/kY3goomtDPJwFlDSF5E4EqqR12mAe7B5+v7GPchQwFaKUYqgDthdYty0kT+r83wyRYY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782825875; c=relaxed/simple; bh=qLAsR2pXyIOmc89PdZoB3S2mIg9N7uaqTsOTV+mVRCo=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=UQJWHQq+kZdwQ9Z2P6xR3LfJfJ77fJN2ZcM1ZHfnLYww+zot6R1mTo6/E5mTiFiRAwaYy6zj3qN59NNSntypU+2u+3NCsRYysuYPJQ5PJ6hEqRjyLPZVh1fKoT+XIgHKF4Z5Elqmeko97o58nGKdzBl657pmF1mLyuL0sIkcVL0= 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=Qt5dJJ3m; arc=none smtp.client-ip=209.85.214.177 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="Qt5dJJ3m" Received: by mail-pl1-f177.google.com with SMTP id d9443c01a7336-2c81d799ef2so22408595ad.3 for ; Tue, 30 Jun 2026 06:24:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thingy.jp; s=google; t=1782825871; x=1783430671; 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:content-type; bh=GEvY01C3gXys9+UmAEJWHDsPyZPieLCejKyrt3XdHhU=; b=Qt5dJJ3mqVaZDPGymv00tIxASFYW1SJbjhZSvn56C2FKrvaPNr9uKFl3UxFCj9RTRk j/oPdNLgOgK+t1d0OwV1qDqrBY+S0/eM8JUfwpoTtVnouicNeeaNEUFg76HH7yHokZlp nHb43wOeCbqo6OZ0Gv+/bYT1yunqjsBBhgmdo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782825871; x=1783430671; 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:content-type; bh=GEvY01C3gXys9+UmAEJWHDsPyZPieLCejKyrt3XdHhU=; b=aUa+KPpGvtHTx1BvwuPpOJzkTPwq+Lu+xbrc2VxSBGjhZx7taN8IvqAdPubrCEg3w/ Z2VUdWJE4GP2y6zJb6zbnfXx8Bg6XYllrdFzQHttewNu7JkNMvk/kDTzrBoeXtoAkDpD HPV9ff+szuIxpSft/WUW7f6BfmLZlaufvxwXg3W/Ig5mMFpXrhT4t3vQzidpxg0hO6fC K3AE05aJncbcfzssCLxldII6eGLzzOY4uok01kGSAaKIz+ebYKLsnd7nWnSblL+LOydO Ot9psDfkB/CSz1Ph/s1H/ZsFgD2vOCmWjg5/xiUKiWFJmoYe6oqa8K/p0vrOaHW2uxdB 6mkQ== X-Gm-Message-State: AOJu0Yzm1i4eJsKJLBd6qFZ+rwedkYp7BI3g3Ywz0oSldRyWV0agp0OG GJlrVZ+QfN7hQoOQ1uybN2uu+3/pENqAVKNafj/i+polLy9+cVt1hRso9pMCQZhzb+B9/e/Zb/W JTDY+ X-Gm-Gg: AfdE7cnan7vM0KMA2/W61HIAn3kKc541blTB3cRzcvGXuaddV/gFh6AYHp3n3oVcWmo dnf30ZkRDdPTJHiDxA4FYpLJs3tQgquCx7s95xgK8oKEw42GOiHfulcuBJJoGvmRkKpT8WGC0rD IbMUFe6is42QcKBgqKcJjO81xb43jJCRd96s+CGeREXjylGQP2IKIEZPjSl/w6DYnqswLVYsbBm /SL0l5UkfSF7hkM/NdNZWGdeonAURE4B6YleEjQc//5bM9+OwxT0jPEJ9XgmVngfWuy0iHmALmf NSZDftGg9dRlwGZdIN0TNHmVA/ciaUvLPFaURigMaeh7f1j/HUKTtOtfkkb8l325CkeZzRNz6L9 DbIrtAFZkAoIhCIyy9xfdvmH6dgFTdX3s4lzu5+Id7oQMJcoBuyC/LVYo3eOd+j8cqziZRBLhQ4 rc/hqYKErwWO1zoieWtuTcE2ROGw== X-Received: by 2002:a17:903:2448:b0:2c9:99a2:d108 with SMTP id d9443c01a7336-2ca2ea32c6emr29312295ad.37.1782825871044; Tue, 30 Jun 2026 06:24:31 -0700 (PDT) Received: from kinako.work.home.arpa ([2400:4162:2428:2ffe:a973:53e4:1a28:8545]) by smtp.googlemail.com with ESMTPSA id d9443c01a7336-2ca382abefdsm14716155ad.59.2026.06.30.06.24.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jun 2026 06:24:30 -0700 (PDT) From: Daniel Palmer To: w@1wt.eu, linux@weissschuh.net Cc: linux-kernel@vger.kernel.org, Daniel Palmer Subject: [PATCH v2 0/3] nolibc: Add getcwd() and readlink() Date: Tue, 30 Jun 2026 22:24:16 +0900 Message-ID: <20260630132419.2523890-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. 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 | 56 ++++++++++++++++++++ tools/testing/selftests/nolibc/nolibc-test.c | 48 +++++++++++++++++ 2 files changed, 104 insertions(+) -- 2.53.0