Received: by 2002:ab2:68c1:0:b0:1fd:9a81:d0e4 with SMTP id e1csp530812lqp; Sun, 9 Jun 2024 07:17:39 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXU4X//pufhKQlUneHWFJ7XeSzUXCdUiD3ClCeOHFcE4Ft4gZB+tv/DFrF1gb7jsX7ek9bPCJQXjpA9ufZuotIfoDAepIMVtqJNg0iU5w== X-Google-Smtp-Source: AGHT+IFlmfrmtAYXtqqgKWIeM6VU+0bsmCFNT9uPH/KXQleeAoa/H+GvzYFhaUcLYDP3GRNVH6jo X-Received: by 2002:a17:906:c147:b0:a6f:2001:aa50 with SMTP id a640c23a62f3a-a6f2001ab7cmr14341066b.62.1717942659853; Sun, 09 Jun 2024 07:17:39 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717942659; cv=pass; d=google.com; s=arc-20160816; b=LCkyCfyb3MzH4JYzkfDwzKKhccKNSL7XGqzwStOBEXxI621M71aSHlU+3PBax2UGmG dvUJVmh9VQ/Gi+gJg4D3bLt9Z6g1b/+1svDswv21kjW3jp1wqZiK0yDgUhjc+hZKF00w wvTN4axujTZ7ahTZtjtKPa9AbFWI21mwb+vJUc80E6UqGASfkecunr5u62YF35e7MN+w SwJFV++BbUxh4m0soDlAj+6mwOxcEGgrj0U7efOV8dNlEoKbbVZJ+e4Fa1FtYBtBBJJO SjQCORqccGEd+MoilPxS9uiCBZu5GFa6dbwyxJrRqXM1can5wEwHjgVhIc4Z0+ooZvSR zFvA== 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:message-id:date:subject:cc:to :from:dkim-signature; bh=TutpqlrSfL/EF9pT63bvOTQrpOoXNL5CWPlMZU8S7qU=; fh=Z7hwXlJDipyDyWdRNp8NSYBvVaz6RhTEiol99SJCGto=; b=i3smXLGGkXtbyytEHW/G7++QWk+kTvyndzd7u//DnVMMKFCJhejNw+sojMLNYwZ9xf BrRCoztApljXAtY37zC+VQsxWAIS4KHnzkp3GrKNmNiRHJkNWSL6ApK/vsF3R1pZkfDo hWOoKv+vUnaDTbITTIcazuykqTL5eSCeVpcLsuYpQa7wJajkU0B554TXorLjNTwxYUnb JypKg/k4rY1XhTcfnC/4d+exnzzGIe6sDcII+hZYisu20qiRFwY06HaqPkZvo/czjKPE KBGFo8Ypdxj8c2pzuoXhqhbwgrLcWCghX78z7mYEnaoVuzIXnZVWT+ek4UBB0Tzc5FER sUAQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="U8h/UQNi"; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-207380-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-207380-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id a640c23a62f3a-a6e04df9ea1si253475166b.651.2024.06.09.07.17.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Jun 2024 07:17:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-207380-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="U8h/UQNi"; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-207380-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-207380-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.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 am.mirrors.kernel.org (Postfix) with ESMTPS id 893DB1F214E1 for ; Sun, 9 Jun 2024 14:17:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 873464437F; Sun, 9 Jun 2024 14:17:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="U8h/UQNi" Received: from mail-pf1-f174.google.com (mail-pf1-f174.google.com [209.85.210.174]) (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 793911CD3C for ; Sun, 9 Jun 2024 14:17:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.174 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717942651; cv=none; b=T1hp0k5zOwGYcKTUOr16/B1hyIYuDvPsyhd/yeBIBjA6fLyOXQsLP5wExzZsxWcmmiW1Yy5Tur2MEFhgkKcWsF7EKYzCdHnJaO+GaosUqP+MKyUCcJSFyu2TttRjqqOv3wS9+su18MH/6FPijOprp5gIo4kikfkzqYIM/1zFBUg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717942651; c=relaxed/simple; bh=NJDToOELLavN79YkpNHBhxfCYr8Bzt9pRlexqHPJ7XY=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=miSyvtft1KBK2xEmpVLaLYFVWGMPsbpgka7ZjAp9Cl+EP2e6lIXr84XH3GP4IfeGuGwkUNVfPzKSQGdKBgyOFBxbTFOCcBBP4M2JgedsumYdCMLC+T4Q6/nq9o6/l34cNN6anj2ev+T1BpzOvcRDbk1tymDgIctypmHHcchO5Ns= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=U8h/UQNi; arc=none smtp.client-ip=209.85.210.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pf1-f174.google.com with SMTP id d2e1a72fcca58-7041f4553ccso1443953b3a.1 for ; Sun, 09 Jun 2024 07:17:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1717942650; x=1718547450; 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=TutpqlrSfL/EF9pT63bvOTQrpOoXNL5CWPlMZU8S7qU=; b=U8h/UQNiwli2/fRnA5A3ZYhGwmJVO9zJuvs6ki5Zg5nsai4GuLsaIXjapUFaJi/g90 9t0s245GqtUaR2+U+P8Tt9WgH2TKZPtEJd/1FbnWjCey7C69f+mRDtVUn5qNIX7u8eHF 8oWswBY+ue7q0Q3yPWHo5e72zlKQI3fG1P8rgTPXFjnHCnfaguXuJag+RYec+FAzPO6B dW8S3RS6eoKoIGBPP+UmNwvIBLOEHDsac1+G33IcJLLlY6LYibypWdR7HgORoIlQPV5u tEXN431I7J1ld3Ip7ibN5mv7/wsLp2tYM2mjVoTtXyc4FvNUAb38Y5hvQfTD3tBG+3Od 2/IQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717942650; x=1718547450; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=TutpqlrSfL/EF9pT63bvOTQrpOoXNL5CWPlMZU8S7qU=; b=JGuE8/bTnVJ/Y1eSnsHSRKufCToqX3aH6+1l8TRiYC7YRYdhoT3npOXdtX0RdOdUb3 /9v6ZQQlhREcCnntzkI5qnK/Vm2PIxuY1WWFtEwdYpEV1IZLfWGdkI9M82Rz5LrObxWN FYjIgi2XWuuZbUV1Ig9cECn92uH7jmE6uNhUcFqXT7iIFWJehugmQZqYti3ntlD7yMrt 4V74PJx8XR6Fu0kOZbBTQIC0pw+i7gYSW98ijsqwEqo1L8SPIAAcD9evLUqUs0N/y3ZX i8Sivj9dlEUpQ6sG1dUwPsdUzIvKZaI5ZRXX5sTyHcSpYBxXNn6vnKLiEbQc9YZQI9A3 VNPw== X-Forwarded-Encrypted: i=1; AJvYcCVsYNKp+h2kfHRR+hZTJf90WprVZCR84AvgQ8NTh1Xls3d9wnGeAQgyYKdbfZeiTSb1YCjdUHiYVBwLM6GV1ypXIrGkL/ZLMIdBs2vE X-Gm-Message-State: AOJu0YzBGua9N7FnYj1uLQ43rleVZy1YeqBVVgybBPZ4ZX5/oHNB7dcj mfiQR2loJ25DTaafpZ354lbCRYhTdii/zQwgsL82JpfmnlUozeqd X-Received: by 2002:a05:6a20:7490:b0:1b5:97da:dfde with SMTP id adf61e73a8af0-1b597dae2ccmr3868311637.43.1717942649827; Sun, 09 Jun 2024 07:17:29 -0700 (PDT) Received: from dev0.. ([49.43.162.161]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7041ffa7cfasm2767555b3a.112.2024.06.09.07.17.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Jun 2024 07:17:29 -0700 (PDT) From: Abhinav Jain To: agk@redhat.com, snitzer@kernel.org, mpatocka@redhat.com, dm-devel@lists.linux.dev, linux-kernel@vger.kernel.org Cc: skhan@linuxfoundation.org, javier.carrasco.cruz@gmail.com, jain.abhinav177@gmail.com Subject: [PATCH] dm: Add support for escaped characters in str_field_delimit() Date: Sun, 9 Jun 2024 14:17:21 +0000 Message-Id: <20240609141721.52344-1-jain.abhinav177@gmail.com> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Add a new variable for escaped characters. If an escaped character (\) is found before the separator, and if the separator is not found or if the escaped character is located before the separator, then move the separator ahead and continue searching for the next separator. Return the pointer to remainder string after the delimiter. If the separator was found, return a pointer to the character immediately after the delimiter (s + 1). If the separator was not found, return NULL. Signed-off-by: Abhinav Jain --- drivers/md/dm-init.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/drivers/md/dm-init.c b/drivers/md/dm-init.c index 2a71bcdba92d..bef6a582a4ae 100644 --- a/drivers/md/dm-init.c +++ b/drivers/md/dm-init.c @@ -87,11 +87,21 @@ static void __init dm_setup_cleanup(struct list_head *devices) */ static char __init *str_field_delimit(char **str, char separator) { - char *s; + char *s, *escaped; - /* TODO: add support for escaped characters */ *str = skip_spaces(*str); s = strchr(*str, separator); + + /* Check for escaped character */ + escaped = strchr(*str, '\\'); + if (escaped && (s == NULL || escaped < s)) { + /* + * If escaped character comes before the separator, move + * the separator ahead & continue searching for next one. + */ + s = strchr(escaped + 1, separator); + } + /* Delimit the field and remove trailing spaces */ if (s) *s = '\0'; -- 2.34.1