From: Nikolay Borisov <nborisov@suse.com>
To: sandeen@sandeen.net
Cc: linux-xfs@vger.kernel.org, Nikolay Borisov <nborisov@suse.com>
Subject: [PATCH 2/4] fiemap: Introduce get_extent_count
Date: Wed, 23 Aug 2017 18:11:20 +0300 [thread overview]
Message-ID: <1503501082-16983-2-git-send-email-nborisov@suse.com> (raw)
In-Reply-To: <1503501082-16983-1-git-send-email-nborisov@suse.com>
This function will be used in future patches and will aid in implementing
ranged fiemap queries
Signed-off-by: Nikolay Borisov <nborisov@suse.com>
---
io/fiemap.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/io/fiemap.c b/io/fiemap.c
index d1584aba7818..30c49112e089 100644
--- a/io/fiemap.c
+++ b/io/fiemap.c
@@ -193,6 +193,22 @@ calc_print_format(
}
}
+/* Use ssize so that we can return also an error code in case the ioctl fails */
+static ssize_t
+get_extent_count(int fd, __u64 startoffset, __u64 len)
+{
+ struct fiemap fiemap = { 0 } ;
+ fiemap.fm_start = startoffset;
+ fiemap.fm_length = len;
+ if (ioctl(fd, FS_IOC_FIEMAP, (unsigned long)&fiemap) < 0) {
+ fprintf(stderr, _("%s: Failed to query fiemap extent count.\n"),
+ progname);
+ return -1;
+ }
+
+ return fiemap.fm_mapped_extents;
+}
+
int
fiemap_f(
int argc,
--
2.7.4
next prev parent reply other threads:[~2017-08-23 15:11 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-11 11:55 [PATCH] fiemap: Refactor fiemap + implement range parameters Nikolay Borisov
2017-08-22 6:41 ` Nikolay Borisov
2017-08-22 19:11 ` Eric Sandeen
2017-08-23 8:07 ` Nikolay Borisov
2017-08-23 15:11 ` [PATCH 1/4] fiemap: Move global variables out of function scope Nikolay Borisov
2017-08-23 15:11 ` Nikolay Borisov [this message]
2017-08-23 17:05 ` [PATCH 2/4] fiemap: Introduce get_extent_count Darrick J. Wong
2017-08-23 15:11 ` [PATCH 3/4] fiemap: Simplify internals of fiemap_f Nikolay Borisov
2017-08-23 15:51 ` Eric Sandeen
2017-08-23 17:17 ` Eric Sandeen
2017-08-23 15:11 ` [PATCH 4/4] fiemap: Add support for ranged query Nikolay Borisov
2017-08-23 19:12 ` Eric Sandeen
2017-08-23 15:49 ` [PATCH 1/4] fiemap: Move global variables out of function scope Eric Sandeen
2017-08-23 22:36 ` Eric Sandeen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1503501082-16983-2-git-send-email-nborisov@suse.com \
--to=nborisov@suse.com \
--cc=linux-xfs@vger.kernel.org \
--cc=sandeen@sandeen.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox