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: 114754 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp10438551vqr; Fri, 30 Jun 2023 08:07:07 -0700 (PDT) X-Google-Smtp-Source: APBJJlFBigRyi+L1aTvlUFqsLyg0rJFPQbptYHX8dC9kg653n5wIwrAHOfTlGKhYRUOQbfRmcxzW X-Received: by 2002:a17:902:c1cd:b0:1b8:400a:48f2 with SMTP id c13-20020a170902c1cd00b001b8400a48f2mr2485270plc.62.1688137626781; Fri, 30 Jun 2023 08:07:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688137626; cv=none; d=google.com; s=arc-20160816; b=ujxFoWwKqB1FMLmuiqDErLXmGaZZuIgyiPQbuViO6lkR/dvBvSFx78zI72tCfxSy99 9nXaQkIOKhIyoURqvyCNvKsD4WXKHe5zBmFFU2kBXAA/nRVzMg4rIXAjL5FE3yHC7aEN 25LJ7HoyEwEhbQssyCFEBOSgnHLYZjachMle2TezYr6ZwAxddA4P0rOKv9Re5ng/i6RL dEclCivKu1C5uXJ5lVygLcdQj0J4gr9TXf8iZUf/DzBtR5cuZkJTiYKMNyg+LyCrxnp2 OK3svhhrhN3ZfsYJYrXCzyyQRyWZln81TQVGH2ya57Fw5QB7wXUZ4+V7urK+tqob6Vcf oRpQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:feedback-id:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from; bh=bDni2XghJmOrN3WYCrkZsMO99cpfJ/hT5P7Fh2m4uvA=; fh=49fx4+cYYT2jkB1G9v6CSOY1nO+RV0JwAuF3mNCzENI=; b=zw7qwohvCBSlpNjzmwMQ/kJILD+6H+/rIiBkf/jdYBdqYN60XIjX3/9tZ0cjp4V4M3 pWjSAowfFipHth0hP+gMt63/PwhMP7I3yydRsUtnSHSUazHevo1T9x7+OQpIxBawwpIS 6Xar0fzPfgX0CioQJuLs++FIfKmSiEqpVMC46s1wLL/agM+JkAiHNYxszg6UJvv5HQXz 7DdXHUFdPApIuPmYo8HgxV8mxoXZAgeoVl2q6HrdbiNybXHU34ivII/wc0tF8oHKwaSg BdnaDr0GoqFNssVi80bCUQTOAAhWgzlwNoSYfJRdpkat9ITskCfyfyi7aZ7ce6eSYCVl KE+g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y6-20020a1709029b8600b001a2513b8e14si12096306plp.84.2023.06.30.08.06.49; Fri, 30 Jun 2023 08:07:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232775AbjF3Oyx (ORCPT + 99 others); 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 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1770140600332022712?= X-GMAIL-MSGID: =?utf-8?q?1770140600332022712?= 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);