Received: by 2002:ab2:6309:0:b0:1fb:d597:ff75 with SMTP id s9csp808991lqt; Thu, 6 Jun 2024 21:36:47 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUpYC1tGLZLm89ltg69PVluPlJXZto6k+K/YIorI/SmrLsph/ASX2ERDzj6CU+Z8r8P9xcez0DGDgpa1D3L+HbrMinW6W1gNHKKThQNXQ== X-Google-Smtp-Source: AGHT+IEguKEBa9bB8urIfTgdgZHgZQkXcfkfMfl8239HtQCc5HwG2uPQuq1+EuGvQXs7cLW8K0hF X-Received: by 2002:a17:903:22c9:b0:1f3:b9d:87e6 with SMTP id d9443c01a7336-1f6d02cf3cbmr19004175ad.8.1717735007397; Thu, 06 Jun 2024 21:36:47 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717735007; cv=pass; d=google.com; s=arc-20160816; b=X/E6tIbSf7Ybd7Rplw5uz5obb5dHGzND2gvx3XVvwD3A7ITcc0wVg4Se2c6Rf5ILBl wP4IsZ66+TD7v4UBBD2T00j62Mn2OndfVPfpkymk3WDS6NpKyz7g4vCCoBGC1059Rp9b FoTfhfTpJkpx/gEIEHr8xahBppYeyQxjbH+QO+OK7fyCw+msfOQWuY0nk2KEYvPRJKQz 4eylYyRwntCII5rBEsvEYqSie00qwAl4HGFOsKR//Uqe7kjXgFC9WddOvLlr8jywzP3A GQ+eCs5PS0LC5xg1gykAgI0hP387H2UBBFaMt13SqpB4kb/rSZTKVYvIbTS1+4FoWVr9 1m3w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=DX1Klfen353hKHcjBn3sKvc50XqIF978ddhWCMEoQsw=; fh=yXYChwFvQA/NaaLzCC0IJdkW11OhjXgO4DHXzVmnGFw=; b=ooEKju6D/eOZmbJh3ZT27qidTUknLR+vyn5SrPDz5BUKUjUjfSg2Fsf5Crdws1o3Os 8QJZrrtG+NxYWM2WUFWbPc/Qe+eoZWk8vcAfPPcmv7SK82sMaJIdOvLnGOdKmWFEjXxt MKHREhQfVcOz0hgTu6eIQdJDManyBY8dw7emnIXFh2+FMjah9EIDEYTABnKfANOgPDw5 hZsQapXP6zSv3B8LSTGDjj8eETI5R16slqYODeP0AH+/4efuUhYzNSxpg8ls6ke5XBld UqH5TOXr2lpvjpcVe5zY6n9aAKpfK4N6VfRNUTeyg6ov2HZujHzVqaST/VNkBhOyjYr3 C12w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-205305-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-205305-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id d9443c01a7336-1f6bd7d2a06si22944175ad.313.2024.06.06.21.36.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jun 2024 21:36:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-205305-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-205305-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-205305-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id CF790B23E74 for ; Fri, 7 Jun 2024 04:31:56 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9195115279C; Fri, 7 Jun 2024 04:26:59 +0000 (UTC) Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) (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 4ACC4147C85 for ; Fri, 7 Jun 2024 04:26:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.255 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717734418; cv=none; b=EG4C0kpae0oh5l7XphsnrcJolrKwaBxgBjrZX63TNAGlHCvxbV4RfrXNEmEDrakjC70rQ+l1UKcejwJsMiLVEHpyZsB0vexT6HvssgjDvcMwnJU6NKKhxicmKf+l/cRTvZLQRWi80n7DZQEq+ZmYG2CptAqWX0wUEJiWfaBq9fI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717734418; c=relaxed/simple; bh=k1CcI5rFF64l7k3yfUm44s7TxiLl2FG2tTnAxLYCxBM=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=NvDIzUmsTAz7mH+13Arn6cVhTUSxdvJ0MunCj7JPGTTKSequFmhkAjeLVQvnuYgOg70S8EfKZBa93kSG6BSjJF8JHIjgEpZjOU+I5YleesQeTTg/c4yUo8of4WeY/LeY5y5X7ZprRVsdIm7/jOVU7bQN8hpPiclgS3DRxoNtybs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.255 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.88.194]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4VwSjT0fYWz1SB5M; Fri, 7 Jun 2024 12:22:53 +0800 (CST) Received: from kwepemm600013.china.huawei.com (unknown [7.193.23.68]) by mail.maildlp.com (Postfix) with ESMTPS id D01771400D5; Fri, 7 Jun 2024 12:26:51 +0800 (CST) Received: from huawei.com (10.175.104.67) by kwepemm600013.china.huawei.com (7.193.23.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Fri, 7 Jun 2024 12:26:46 +0800 From: Zhihao Cheng To: , , , , , CC: , Subject: [RFC PATCH mtd-utils 026/110] ubifs-utils: Add mutexlock implementations Date: Fri, 7 Jun 2024 12:24:51 +0800 Message-ID: <20240607042615.2069840-27-chengzhihao1@huawei.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240607042615.2069840-1-chengzhihao1@huawei.com> References: <20240607042615.2069840-1-chengzhihao1@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To kwepemm600013.china.huawei.com (7.193.23.68) Add mutexlock implementations, because there are some mutexlocks (eg. c->tnc_mutex, c->log_mutex) used in UBIFS linux kernel libs. The mutexlock is implementated based on pthread mutex. This is a preparation for replacing implementation of UBIFS utils with linux kernel libs. Signed-off-by: Zhihao Cheng --- ubifs-utils/Makemodule.am | 1 + ubifs-utils/common/mutex.h | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 ubifs-utils/common/mutex.h diff --git a/ubifs-utils/Makemodule.am b/ubifs-utils/Makemodule.am index 7849114e..9f33f0db 100644 --- a/ubifs-utils/Makemodule.am +++ b/ubifs-utils/Makemodule.am @@ -6,6 +6,7 @@ common_SOURCES = \ ubifs-utils/common/bitops.h \ ubifs-utils/common/bitops.c \ ubifs-utils/common/spinlock.h \ + ubifs-utils/common/mutex.h \ ubifs-utils/common/kmem.h \ ubifs-utils/common/kmem.c \ ubifs-utils/common/defs.h \ diff --git a/ubifs-utils/common/mutex.h b/ubifs-utils/common/mutex.h new file mode 100644 index 00000000..4bf018b0 --- /dev/null +++ b/ubifs-utils/common/mutex.h @@ -0,0 +1,18 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef __LINUX_MUTEX_H_ +#define __LINUX_MUTEX_H_ + +#include + +struct mutex { + pthread_mutex_t lock; +}; + +#define mutex_init(x) pthread_mutex_init(&(x)->lock, NULL) + +#define mutex_lock(x) pthread_mutex_lock(&(x)->lock) +#define mutex_lock_nested(x, c) pthread_mutex_lock(&(x)->lock) +#define mutex_unlock(x) pthread_mutex_unlock(&(x)->lock) +#define mutex_is_locked(x) (pthread_mutex_trylock(&(x)->lock) == EBUSY) + +#endif -- 2.13.6