aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2023-12-11 17:37:38 +0100
committerCarlos Maiolino <cem@kernel.org>2023-12-18 14:57:49 +0100
commit652683748da1333dee33f6d8634f33d294923bb8 (patch)
tree835cfd5d7a097add86283e0008f6ff1e03344ac4
parent4f112cb17c0ddcc670cb4df07d3f32f6846ff430 (diff)
downloadxfsprogs-dev-652683748da1333dee33f6d8634f33d294923bb8.tar.gz
libxfs: return the opened fd from libxfs_device_open
So that the caller can stash it away without having to call xfs_device_to_fd. 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--libxfs/init.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/libxfs/init.c b/libxfs/init.c
index 13ad7899c7..866e5f425f 100644
--- a/libxfs/init.c
+++ b/libxfs/init.c
@@ -93,7 +93,7 @@ libxfs_device_to_fd(dev_t device)
* open a device and return its device number
*/
static dev_t
-libxfs_device_open(char *path, int creat, int xflags, int setblksize)
+libxfs_device_open(char *path, int creat, int xflags, int setblksize, int *fdp)
{
dev_t dev;
int fd, d, flags;
@@ -151,6 +151,7 @@ retry:
if (!dev_map[d].dev) {
dev_map[d].dev = dev;
dev_map[d].fd = fd;
+ *fdp = fd;
return dev;
}
@@ -307,16 +308,14 @@ libxfs_init(struct libxfs_init *a)
if (!a->disfile && !check_open(dname, a->flags))
goto done;
a->ddev = libxfs_device_open(dname, a->dcreat, a->flags,
- a->setblksize);
- a->dfd = libxfs_device_to_fd(a->ddev);
+ a->setblksize, &a->dfd);
platform_findsizes(dname, a->dfd, &a->dsize, &a->dbsize);
}
if (logname) {
if (!a->lisfile && !check_open(logname, a->flags))
goto done;
a->logdev = libxfs_device_open(logname, a->lcreat, a->flags,
- a->setblksize);
- a->logfd = libxfs_device_to_fd(a->logdev);
+ a->setblksize, &a->logfd);
platform_findsizes(logname, a->logfd, &a->logBBsize,
&a->lbsize);
}
@@ -324,8 +323,7 @@ libxfs_init(struct libxfs_init *a)
if (a->risfile && !check_open(rtname, a->flags))
goto done;
a->rtdev = libxfs_device_open(rtname, a->rcreat, a->flags,
- a->setblksize);
- a->rtfd = libxfs_device_to_fd(a->rtdev);
+ a->setblksize, &a->rtfd);
platform_findsizes(dname, a->rtfd, &a->rtsize, &a->rtbsize);
}