diff mbox series

[19/23] libxfs: return the opened fd from libxfs_device_open

Message ID 20231211163742.837427-20-hch@lst.de (mailing list archive)
State Accepted
Headers show
Series [01/23] libxfs: remove the unused icache_flags member from struct libxfs_xinit | expand

Commit Message

Christoph Hellwig Dec. 11, 2023, 4:37 p.m. UTC
So that the caller can stash it away without having to call
xfs_device_to_fd.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 libxfs/init.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

Comments

Carlos Maiolino Dec. 18, 2023, 12:53 p.m. UTC | #1
On Mon, Dec 11, 2023 at 05:37:38PM +0100, Christoph Hellwig wrote:
> 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: Carlos Maiolino <cmaiolino@redhat.com>

> ---
>  libxfs/init.c | 12 +++++-------
>  1 file changed, 5 insertions(+), 7 deletions(-)
> 
> diff --git a/libxfs/init.c b/libxfs/init.c
> index 13ad7899c..866e5f425 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);
>  	}
> 
> --
> 2.39.2
> 
>
diff mbox series

Patch

diff --git a/libxfs/init.c b/libxfs/init.c
index 13ad7899c..866e5f425 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);
 	}