From patchwork Fri Jun 30 14:54:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Zhangjin Wu X-Patchwork-Id: 13298293 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F350BEB64D7 for ; Fri, 30 Jun 2023 14:54:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231546AbjF3Oyx (ORCPT ); Fri, 30 Jun 2023 10:54:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52378 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231490AbjF3Oyn (ORCPT ); Fri, 30 Jun 2023 10:54:43 -0400 Received: from bg4.exmail.qq.com (bg4.exmail.qq.com [43.154.54.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7FD8B199C; Fri, 30 Jun 2023 07:54:41 -0700 (PDT) X-QQ-mid: bizesmtp62t1688136872tw3c6ubu Received: from linux-lab-host.localdomain ( [119.123.131.49]) by bizesmtp.qq.com (ESMTP) with id ; Fri, 30 Jun 2023 22:54:31 +0800 (CST) X-QQ-SSF: 01200000000000D0W000000A0000000 X-QQ-FEAT: znfcQSa1hKbueF+mXAgBy3rJOgj1RLfbDdVxw5G9LZsIKSHSDWEo0cPthZn5y 2507pXERHbMQlfcGVi/fPoErK4Q+RhkejsHI7PKAIoYK61wlHUruw2XEBjLind0HIk+RQsP ESu4yDckaqB4Zu8BTqm1n04LvedF4U3iF/SkLxvf8Z3oiOG4m5c6Tny1Igo5PX+/R3qpMRg yZlvGKhBNasKGPiAwMJAAnNO6oxAVrdVDl5DurO9CQzy7f5YuLC2zPOtWfLEI4giP7v/88H pEkPmmeDcjaBK1YbDkRmiJtiPyNN1F+M0m0458Hq55J5tjaRE3Nh39h0bIF/4HvmGeHBytE ZZFY9FD/68V5g2Iz7zu+8a1Dpt9Yl3c8ZwVxpOYETRHTjKCFTyKaT8dwFeFzg== X-QQ-GoodBg: 0 X-BIZMAIL-ID: 657531427943538185 From: Zhangjin Wu To: thomas@t-8ch.de, w@1wt.eu Cc: arnd@arndb.de, falcon@tinylab.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Subject: [PATCH v3 09/14] tools/nolibc: add rmdir() support Date: Fri, 30 Jun 2023 22:54:24 +0800 Message-Id: <630ad07b61503e1970f93c6f24b3c6e2fc3a1650.1688134400.git.falcon@tinylab.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:tinylab.org:qybglogicsvrgz:qybglogicsvrgz5a-1 Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org a reverse operation of mkdir() is meaningful, add rmdir() here. required by nolibc-test to remove /proc while CONFIG_PROC_FS is not enabled. Reviewed-by: Thomas Weißschuh Signed-off-by: Zhangjin Wu --- tools/include/nolibc/sys.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tools/include/nolibc/sys.h b/tools/include/nolibc/sys.h index b6c33c40c037..7b052958e2ae 100644 --- a/tools/include/nolibc/sys.h +++ b/tools/include/nolibc/sys.h @@ -610,6 +610,28 @@ int mkdir(const char *path, mode_t mode) return __sysret(sys_mkdir(path, mode)); } +/* + * int rmdir(const char *path); + */ + +static __attribute__((unused)) +int sys_rmdir(const char *path) +{ +#ifdef __NR_rmdir + return my_syscall1(__NR_rmdir, path); +#elif defined(__NR_unlinkat) + return my_syscall3(__NR_unlinkat, AT_FDCWD, path, AT_REMOVEDIR); +#else + return -ENOSYS; +#endif +} + +static __attribute__((unused)) +int rmdir(const char *path) +{ + return __sysret(sys_rmdir(path)); +} + /* * int mknod(const char *path, mode_t mode, dev_t dev);