Received: by 2002:a05:7412:1e0b:b0:fc:a2b0:25d7 with SMTP id kr11csp702048rdb; Thu, 15 Feb 2024 12:39:27 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCW7RjbOmT72eO1WOIh4Lw0BELWhb4nPmgxFR+6DWihagVEByIh9ODSDuYQnhXs5X5I0Jm5OvdmPcnhqAgy74F+9ltG+PwnBkxxqJRF7iQ== X-Google-Smtp-Source: AGHT+IHe9cr70z8BW8/qrTUvMHe4K+q3BVXW74ozo+uLzfwxPqBO2z5JCfc+WOdB6NjOvQk+J8Dm X-Received: by 2002:a05:622a:1a24:b0:42d:c7da:eb42 with SMTP id f36-20020a05622a1a2400b0042dc7daeb42mr3392701qtb.51.1708029567233; Thu, 15 Feb 2024 12:39:27 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708029567; cv=pass; d=google.com; s=arc-20160816; b=m/ktZaBLh8+31Lq6bjj2RVh8kcbfDxKWl6nQW/01u9Xm57qJpFpYsxC2mXAcY4tOKP Ay2pb3pPy2mHPtMfMTCekUoZkikxHywSLPKGpGFU7vbiYKdtpQALtaM9ybJB9YvKaygv rFbH1cZ1pF/Q7iqdriUqEDBL3dcjM54p1uPkonMDmRod+GliixrLi/cj1sGxpxM6qyLe D3TzP+aPvEcIVDz92r3DR492WLsGAyoLUmn+3GxumBh/Cu20oujc+FzkdON9lgPJdkPH r0x7ylM02aupDvVO6RouqTuuvDMFOBDbhWFeaFqKHudBrAOPsmwm90VkhtStulzThBBE ps1w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=KP8/sXQUg6d+/tAlWscHgJtEUS3CFlZkJ/dGjgcRmF8=; fh=IuWhY7lUs8mn5eodWQHdP5czjrMrErk6TQ15b+TtD1w=; b=NyYbtJ8B64Y3wkqknkG8l8/TEwahn0iOPzf/ChAb25vEI6DAcRPdPOvdgHDVuzJfni lfV8eRbkwgSQ8+dkBlXVWnqgStDBcr+JQtdRuxfK7pbvgHl5WLZ0pA/Cti93MnOc6ug8 k4nojaVM/kpbIGk4KaZUJjxHhVxwqKaXaiqFdz4UlpcAs15uONlfuVIhriKVrbJi7BIs nj4N+qVHCyliTccEDB3hQ5JoXnbJgYqfpUOCiXl5NlLwXSLm6y6OIQfE5w0x4bIwNXjZ nEBKcIF8L/0uLENz7ra08TIoma9XfpYVI+GdwMaBn4o4yA6QklGPCdz5oVpNLmd0bzql tbBA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=f4ejrwaK; 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-67659-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-67659-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id h13-20020ac87d4d000000b0042c7e60b946si2429405qtb.171.2024.02.15.12.39.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 12:39:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-67659-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=f4ejrwaK; 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-67659-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-67659-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 03CA81C219DF for ; Thu, 15 Feb 2024 20:39:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 57E9C13B29E; Thu, 15 Feb 2024 20:39:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="f4ejrwaK" Received: from mail-vk1-f169.google.com (mail-vk1-f169.google.com [209.85.221.169]) (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 F26D613AA42 for ; Thu, 15 Feb 2024 20:39:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.169 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708029560; cv=none; b=r2PhMQC19UH5+hdAx1dNouGW1nx1nlg9K76OQvBTxCINmCjCqQDzkqL4dYwtySg/MO8wukR1XwQ+f1h+h2i5C6EM2vAY4dsdGv9eEnCkxbZfDDjO6WbsSnNf0Y5i2FNEdoKXaZtvjCHfrV7HYcarzx4ZN+jIOuuTOx2GU0k+W5g= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708029560; c=relaxed/simple; bh=oZB9UxxjYJZ4A86GMlPL+c0aJyRyUWLlESSlMqLoAac=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=ogu+o6YHkIUr91QBeIPwAwKVL6kbVv2BPO+zK0wc5Hm3o2vWJMGDwPt2aq8EAcvl6vrV6HkKw69eodOJiLVt7V7HuZadCz/q9Q71IxbST4TSxvbuHc3B+CX1VEOlsl7LtkvN6/2fmxnjctTLdF/lAPY5CA9mQWzZTwJlirEG2WU= 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=f4ejrwaK; arc=none smtp.client-ip=209.85.221.169 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-vk1-f169.google.com with SMTP id 71dfb90a1353d-4c02dfa01a8so411534e0c.1 for ; Thu, 15 Feb 2024 12:39:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708029558; x=1708634358; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=KP8/sXQUg6d+/tAlWscHgJtEUS3CFlZkJ/dGjgcRmF8=; b=f4ejrwaKwRqg7Z5vpUG5eZGZKqz4rZt8PbISZNcAjaTyOJMRoGwib8qO/PLSKxyl7G YdZJR6yo1s02r65Kb0jv6NnaFI6jxw7g82MDPmO6IKlovqu443E5MBCLErBjSLbzgujt 191zPt6AYiPtVbFUqC3O3YB1K2PeV+EKYAQnbr+m7LlvKbOKDkD7CRXTr1NetfTO1f8W tDU9ENPbthhxQ0QjXb02wiXMNgy1SYpQP3NGjdVpvF8BvyCZSiMybN6leWcNLs4st+Re EYjpMRiT7k4OTwFd1cUODf6toyJj4mvIJSmU1QIOi4uYTrRlZNBOj5xHJ260K6UstG3v PFgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708029558; x=1708634358; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=KP8/sXQUg6d+/tAlWscHgJtEUS3CFlZkJ/dGjgcRmF8=; b=DzrvgIOCrmnzhrw7qA4Usyx958T4hGV/3JPYlipJvAuaeynUkGkAfbwqi/vDtXT8RJ CHf1YT2s7vNgvYZur0SGILyWNFTpcDpAqLpSvpqedkEbpvOg3a3hvP3LNiNSn+hmVSiv 4ZtsISBBERm1XVyW/r+WwJULk9JdZYLEqxWGtx1y1z9nzEbIkMoxQNcaDCNKnsL3bbRo NSulEnaS7yfzYTZxvFgXwegrB18wyooz3Uv9YqFlsH8RhzYAXTAqWfhh3FtilvK0Qv/c PQjCFfciTrFrEuXYq/TiGenT45FVt65y9hpAp9SEWC9ObSFMLADB8cJBhb61ihVhj44p NZSg== X-Gm-Message-State: AOJu0YyFNPhhyZ9tODohYh1MVLWwHzAE2gprDkWhI4sb005AyBPNBpbf 7X0Q6VkJ/PYojoEN4+4ytpuwy554PZtP9AWVfC/cmmxPdSGwLlwP4OD0QsJpJDj/8X/Fvfg+B7h NFXy8yG49VSe1NhlFQKTXqRsjc6Q= X-Received: by 2002:a1f:dd04:0:b0:4c0:309b:2755 with SMTP id u4-20020a1fdd04000000b004c0309b2755mr2533048vkg.3.1708029557760; Thu, 15 Feb 2024 12:39:17 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240215201053.2364270-1-daeho43@gmail.com> In-Reply-To: From: Daeho Jeong Date: Thu, 15 Feb 2024 12:39:06 -0800 Message-ID: Subject: Re: [PATCH] f2fs_io: add lseek command to execute lseek() To: Jaegeuk Kim Cc: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, kernel-team@android.com, Daeho Jeong Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, Feb 15, 2024 at 12:36=E2=80=AFPM Jaegeuk Kim w= rote: > > On 02/15, Daeho Jeong wrote: > > From: Daeho Jeong > > > > Added lseek command to support lseek() for SEEK_DATA and SEEK_HOLE. > > > > Signed-off-by: Daeho Jeong > > --- > > tools/f2fs_io/f2fs_io.c | 38 ++++++++++++++++++++++++++++++++++++++ > > 1 file changed, 38 insertions(+) > > > > diff --git a/tools/f2fs_io/f2fs_io.c b/tools/f2fs_io/f2fs_io.c > > index e7d286a..b5c5b97 100644 > > --- a/tools/f2fs_io/f2fs_io.c > > +++ b/tools/f2fs_io/f2fs_io.c > > @@ -1630,6 +1630,43 @@ static void do_removexattr(int argc, char **argv= , const struct cmd_desc *cmd) > > exit(0); > > } > > > > +#define lseek_desc "do lseek for SEEK_DATA or SEEK_HOLE for a file" > > +#define lseek_help \ > > +"f2fs_io lseek [whence] [offset] [file_path]\n\n" \ > > +"Do lseek file data in file_path\n" \ > > +"whence can be\n" \ > > Can we also have all the other options as well? Sounds good. > > > +" data : SEEK_DATA, return the file offset to the next data locat= ion from offset\n"\ > > +" hole : SEEK_HOLE, return the file offset to the next hole from = offset\n" > > + > > +static void do_lseek(int argc, char **argv, const struct cmd_desc *cmd= ) > > +{ > > + int fd, whence; > > + off_t offset, ret; > > + > > + if (argc !=3D 4) { > > + fputs("Excess arguments\n\n", stderr); > > + fputs(cmd->cmd_help, stderr); > > + exit(1); > > + } > > + > > + offset =3D atoi(argv[2]); > > + > > + if (!strcmp(argv[1], "data")) > > + whence =3D SEEK_DATA; > > + else if (!strcmp(argv[1], "hole")) > > + whence =3D SEEK_HOLE; > > + else > > + die("Wrong whence type"); > > + > > + fd =3D xopen(argv[3], O_RDONLY, 0); > > + > > + ret =3D lseek(fd, offset, whence); > > + if (ret < 0) > > + die_errno("lseek failed"); > > + printf("returned offset=3D%ld\n", ret); > > + exit(0); > > +} > > + > > #define CMD_HIDDEN 0x0001 > > #define CMD(name) { #name, do_##name, name##_desc, name##_help, 0 } > > #define _CMD(name) { #name, do_##name, NULL, NULL, CMD_HIDDEN } > > @@ -1671,6 +1708,7 @@ const struct cmd_desc cmd_list[] =3D { > > CMD(listxattr), > > CMD(setxattr), > > CMD(removexattr), > > + CMD(lseek), > > { NULL, NULL, NULL, NULL, 0 } > > }; > > > > -- > > 2.43.0.687.g38aa6559b0-goog > >