[PATCH v2] contrib/vhost-user-blk: Replace lseek64 with lseek

Khem Raj posted 1 patch 1 year, 4 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20221218220740.315839-1-raj.khem@gmail.com
Maintainers: Raphael Norwitz <raphael.norwitz@nutanix.com>, "Michael S. Tsirkin" <mst@redhat.com>
contrib/vhost-user-blk/vhost-user-blk.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
[PATCH v2] contrib/vhost-user-blk: Replace lseek64 with lseek
Posted by Khem Raj 1 year, 4 months ago
64bit off_t is already in use since build uses _FILE_OFFSET_BITS=64
already. Using lseek/off_t also makes it work with latest musl without
using _LARGEFILE64_SOURCE macro. This macro is implied with _GNU_SOURCE
when using glibc but not with musl.

Signed-off-by: Khem Raj <raj.khem@gmail.com>
Cc: Michael S. Tsirkin <mst@redhat.com>
CC: Raphael Norwitz <raphael.norwitz@nutanix.com>
---
v2: Fix typo must->musl

 contrib/vhost-user-blk/vhost-user-blk.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/contrib/vhost-user-blk/vhost-user-blk.c b/contrib/vhost-user-blk/vhost-user-blk.c
index aa99877fcd..7941694e53 100644
--- a/contrib/vhost-user-blk/vhost-user-blk.c
+++ b/contrib/vhost-user-blk/vhost-user-blk.c
@@ -532,9 +532,9 @@ vub_get_blocksize(int fd)
 static void
 vub_initialize_config(int fd, struct virtio_blk_config *config)
 {
-    off64_t capacity;
+    off_t capacity;
 
-    capacity = lseek64(fd, 0, SEEK_END);
+    capacity = lseek(fd, 0, SEEK_END);
     config->capacity = capacity >> 9;
     config->blk_size = vub_get_blocksize(fd);
     config->size_max = 65536;
-- 
2.39.0
Re: [PATCH v2] contrib/vhost-user-blk: Replace lseek64 with lseek
Posted by Raphael Norwitz 1 year, 4 months ago

> On Dec 19, 2022, at 12:07 AM, Khem Raj <raj.khem@gmail.com> wrote:
> 
> 64bit off_t is already in use since build uses _FILE_OFFSET_BITS=64
> already. Using lseek/off_t also makes it work with latest musl without
> using _LARGEFILE64_SOURCE macro. This macro is implied with _GNU_SOURCE
> when using glibc but not with musl.
> 
> Signed-off-by: Khem Raj <raj.khem@gmail.com>
> Cc: Michael S. Tsirkin <mst@redhat.com>
> CC: Raphael Norwitz <raphael.norwitz@nutanix.com>
> ---
> v2: Fix typo must->musl
> 
> contrib/vhost-user-blk/vhost-user-blk.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/contrib/vhost-user-blk/vhost-user-blk.c b/contrib/vhost-user-blk/vhost-user-blk.c
> index aa99877fcd..7941694e53 100644
> --- a/contrib/vhost-user-blk/vhost-user-blk.c
> +++ b/contrib/vhost-user-blk/vhost-user-blk.c
> @@ -532,9 +532,9 @@ vub_get_blocksize(int fd)
> static void
> vub_initialize_config(int fd, struct virtio_blk_config *config)
> {
> -    off64_t capacity;
> +    off_t capacity;
> 
> -    capacity = lseek64(fd, 0, SEEK_END);
> +    capacity = lseek(fd, 0, SEEK_END);
>     config->capacity = capacity >> 9;
>     config->blk_size = vub_get_blocksize(fd);
>     config->size_max = 65536;
> -- 
> 2.39.0
> 


Reviewed-by: Raphael Norwitz <raphael.norwitz@nutanix.com>
Re: [PATCH v2] contrib/vhost-user-blk: Replace lseek64 with lseek
Posted by Philippe Mathieu-Daudé 1 year, 4 months ago
On 18/12/22 23:07, Khem Raj wrote:
> 64bit off_t is already in use since build uses _FILE_OFFSET_BITS=64
> already. Using lseek/off_t also makes it work with latest musl without
> using _LARGEFILE64_SOURCE macro. This macro is implied with _GNU_SOURCE
> when using glibc but not with musl.
> 
> Signed-off-by: Khem Raj <raj.khem@gmail.com>
> Cc: Michael S. Tsirkin <mst@redhat.com>
> CC: Raphael Norwitz <raphael.norwitz@nutanix.com>
> ---
> v2: Fix typo must->musl
> 
>   contrib/vhost-user-blk/vhost-user-blk.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/contrib/vhost-user-blk/vhost-user-blk.c b/contrib/vhost-user-blk/vhost-user-blk.c
> index aa99877fcd..7941694e53 100644
> --- a/contrib/vhost-user-blk/vhost-user-blk.c
> +++ b/contrib/vhost-user-blk/vhost-user-blk.c
> @@ -532,9 +532,9 @@ vub_get_blocksize(int fd)
>   static void
>   vub_initialize_config(int fd, struct virtio_blk_config *config)
>   {
> -    off64_t capacity;
> +    off_t capacity;
>   
> -    capacity = lseek64(fd, 0, SEEK_END);
> +    capacity = lseek(fd, 0, SEEK_END);
>       config->capacity = capacity >> 9;
>       config->blk_size = vub_get_blocksize(fd);
>       config->size_max = 65536;

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>