Received: by 2002:a05:7412:1e0b:b0:fc:a2b0:25d7 with SMTP id kr11csp706722rdb; Thu, 15 Feb 2024 12:52:18 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVTbk+QrsYt0Uasw4X3TxoTEWC6cZxg3mJb/798Mp6hjTHp5xhstt/3VcG9h0myuosN8acFH/gyp9FgcbV7GQkC791MXEnBun5DbIxBOg== X-Google-Smtp-Source: AGHT+IH5lMw2JlIJ1rhF72BocUhsxyS4NCtcLoWzFeuV+d5bMFpwYUGPE79SHW1HQFBlgaZY9iy9 X-Received: by 2002:a05:6a20:28a3:b0:19c:9d37:ec59 with SMTP id q35-20020a056a2028a300b0019c9d37ec59mr2278594pzf.28.1708030337993; Thu, 15 Feb 2024 12:52:17 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708030337; cv=pass; d=google.com; s=arc-20160816; b=KRld/uR5wmXd2GXp81AWLjrkZnuAAoB1LrzEh8XqEruDZYUCwc+9gJ919TWOwfGX/o pa+lrXp+oiCFGzc4tH9tKvPadCetGaO9835WidYUm4a3vf8/fN6xRdQF7OPDGSkgkzn7 tFQ1P1vXpClBk+y7d+nut9BCevhgyHmJciEaKiLvJ4OR/GrmvuLU5owJlIQvPt7WcwPG DkrgZBIR6Bt9mzAYlIp4ORLJmQygp3p1n3SNeEmGTpOgmXatU5xaCtO1be9VgYi3i14l yNhO1FciX0ZzzSRiovuaHNTwyjjjyhNBHu1nXpfanUfbOEexpijRV1hDu14tMkdw2OD2 y99Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=dzgsEb6eUoIk8NVZCmk50DmTxCKxSD50fcQ7xG1THcg=; fh=ZaK2vudNijy95H0GvyYVBWTmhTw8nJYwWXkLewFdkfY=; b=GWv7gqbZkCrHG8RhFxdFHmGVPmwx3fILNFrbB1dawDNlPJ7jSpZIexYKRxcI0891uO Fvy8+kfbMhvi2HZgYfypwcM1U5pHB+UIj430ZQCqyfftKAJvtb16uJGjp1UCVsdjRUa2 0arq0CITGBLShML/+/EER+ndct/9LZNS1Q+QgR/p5xu3s2ieSHcGVZjrEXJNBF7rqB7g vGODgRDc5QEoDd/7F6HLKE73mEJ2OTKkW/hzKSjxTtI7WKP/b8Bp9/rciQv0YMO33UxS UqdKDFdzVeRjRVqdtrNZhVFyzfyyuzzvOwXNERkYa7Z92ZmmOtgOmFJF2wOP/AR1qYhU 63wQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="W8NJAw/Z"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-67657-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-67657-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id b13-20020a65668d000000b005dc892988e1si1666802pgw.509.2024.02.15.12.52.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 12:52:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-67657-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="W8NJAw/Z"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-67657-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-67657-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org 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 A3A54B20F55 for ; Thu, 15 Feb 2024 20:36:37 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1A22813B292; Thu, 15 Feb 2024 20:36:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="W8NJAw/Z" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 3D26713AA4B for ; Thu, 15 Feb 2024 20:36:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708029391; cv=none; b=tYacrbT5bNnejZilxwtVcX4+2Zei5M4i8OuM8QIMhsqYfeLDrDgxtSjAxgJw4HZkoBjDf1o6YPxo5fPMlQ5tjavoTJrCA8h4BAXpfuiT03TQnNcIOGczjnYHzCleZvNMVQisHqQ758s42B/8bj1vpT7xBtIbf65djFE0/5g5g/k= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708029391; c=relaxed/simple; bh=w+4GQYEtYb0/zUI+FYlPpcP4BX3/rQPTNBehFhxJT4E=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=LF6oObycBrW3bgOJVj9XvzgdcHLuupbCJ99qd+cOfn+9lYIJwr9j5FjoqP6WvWviS0x0ySO1PwsxbfNgvHL0D0Z6XQ3vtv2XCsMV8A2siZixhmUkVK5aabp2jie/gTq/8ctn4+GDBfcZoLsr7gdHzvojj6y+cxrxMEQB2Mab1Tg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=W8NJAw/Z; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 98F9FC433F1; Thu, 15 Feb 2024 20:36:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708029390; bh=w+4GQYEtYb0/zUI+FYlPpcP4BX3/rQPTNBehFhxJT4E=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=W8NJAw/Z9xiQYM8H5eWT6FTLuFCAe4wOAiQFGKvaQuhgkvG4bEZRG7cF/Ir4V8Fhk twbzSYtUFp9Z+4aO557z4jvS5Nk/dMhlOQtKVP7fW0Y4VEQg3nqh8GAu2H4/ZVtkOP OM5kJ49BnGHFc5emwzZkZqfAVYwUZl8jw5HtUV9vOJACak+XbyAx27tVrGG2sgYvvA lDkaFdZm6aspUE8yET7bg/WIa896NwL8bTZolSlRclL6BI32coChWkCsUCcCpjkbwQ 4LdScP7jr+oP0f2S4CE++jXGTQ+O45ssMsCa6HlI/bPkuU5w3ImJ/sOGm2hRdWYjSB Q2LUa4YPnUF/w== Date: Thu, 15 Feb 2024 12:36:29 -0800 From: Jaegeuk Kim To: Daeho Jeong Cc: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, kernel-team@android.com, Daeho Jeong Subject: Re: [PATCH] f2fs_io: add lseek command to execute lseek() Message-ID: References: <20240215201053.2364270-1-daeho43@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240215201053.2364270-1-daeho43@gmail.com> 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? > +" data : SEEK_DATA, return the file offset to the next data location 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 != 4) { > + fputs("Excess arguments\n\n", stderr); > + fputs(cmd->cmd_help, stderr); > + exit(1); > + } > + > + offset = atoi(argv[2]); > + > + if (!strcmp(argv[1], "data")) > + whence = SEEK_DATA; > + else if (!strcmp(argv[1], "hole")) > + whence = SEEK_HOLE; > + else > + die("Wrong whence type"); > + > + fd = xopen(argv[3], O_RDONLY, 0); > + > + ret = lseek(fd, offset, whence); > + if (ret < 0) > + die_errno("lseek failed"); > + printf("returned offset=%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[] = { > CMD(listxattr), > CMD(setxattr), > CMD(removexattr), > + CMD(lseek), > { NULL, NULL, NULL, NULL, 0 } > }; > > -- > 2.43.0.687.g38aa6559b0-goog >