aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2023-12-11 17:37:40 +0100
committerCarlos Maiolino <cem@kernel.org>2023-12-18 14:57:49 +0100
commit28cd682bef015170584ac6aa3fc0223cfd7c164f (patch)
tree1965224a7419222106042a53b2e36b3256805706
parent024b577aa8e7b43217e57f25585dc2617c1cc17b (diff)
downloadxfsprogs-dev-28cd682bef015170584ac6aa3fc0223cfd7c164f.tar.gz
xfs_repair: remove various libxfs_device_to_fd calls
A few places in xfs_repair call libxfs_device_to_fd to get the data device fd from the data device dev_t stored in the libxfs_init structure. Just use the file descriptor stored right there directly. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Darrick J. Wong <djwong@kernel.org> Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com> Signed-off-by: Carlos Maiolino <cem@kernel.org>
-rw-r--r--repair/xfs_repair.c13
1 files changed, 5 insertions, 8 deletions
diff --git a/repair/xfs_repair.c b/repair/xfs_repair.c
index 8a6cf31b4e..cdbdbe855f 100644
--- a/repair/xfs_repair.c
+++ b/repair/xfs_repair.c
@@ -724,13 +724,11 @@ static void
check_fs_vs_host_sectsize(
struct xfs_sb *sb)
{
- int fd, ret;
+ int ret;
long old_flags;
struct xfs_fsop_geom geom = { 0 };
- fd = libxfs_device_to_fd(x.ddev);
-
- ret = -xfrog_geometry(fd, &geom);
+ ret = -xfrog_geometry(x.dfd, &geom);
if (ret) {
do_log(_("Cannot get host filesystem geometry.\n"
"Repair may fail if there is a sector size mismatch between\n"
@@ -739,8 +737,8 @@ check_fs_vs_host_sectsize(
}
if (sb->sb_sectsize < geom.sectsize) {
- old_flags = fcntl(fd, F_GETFL, 0);
- if (fcntl(fd, F_SETFL, old_flags & ~O_DIRECT) < 0) {
+ old_flags = fcntl(x.dfd, F_GETFL, 0);
+ if (fcntl(x.dfd, F_SETFL, old_flags & ~O_DIRECT) < 0) {
do_warn(_(
"Sector size on host filesystem larger than image sector size.\n"
"Cannot turn off direct IO, so exiting.\n"));
@@ -986,10 +984,9 @@ main(int argc, char **argv)
/* -f forces this, but let's be nice and autodetect it, as well. */
if (!isa_file) {
- int fd = libxfs_device_to_fd(x.ddev);
struct stat statbuf;
- if (fstat(fd, &statbuf) < 0)
+ if (fstat(x.dfd, &statbuf) < 0)
do_warn(_("%s: couldn't stat \"%s\"\n"),
progname, fs_name);
else if (S_ISREG(statbuf.st_mode))