[PATCH] erofs-utils: lib: simplify s3erofs_prepare_url logic

Gao Xiang hsiangkao at linux.alibaba.com
Tue Sep 30 19:06:50 AEST 2025


Hi Yifan,

On 2025/9/30 16:40, Yifan Zhao wrote:
> From: zhaoyifan <zhaoyifan28 at huawei.com>
> 
> `mkfs.erofs` failed to generate image from Huawei OBS with the following command:
> 
> 	mkfs.erofs --s3=<endpoint>,urlstyle=vhost,sig=2 s3.erofs test-bucket
> 
> because it mistakenly generated a url with repeated '/':
> 
> 	https://test-bucket.<endpoint>//<keyname>
> 
> In fact, the splitting of bucket name and path has already been performed prior
> to the call to `s3erofs_prepare_url`, and this function does not need to handle
> this logic. This patch simplifies this part accordingly and fixes the problem.
> 
> Fixes: 29728ba8f6f6 ("erofs-utils: mkfs: support EROFS meta-only image generation from S3")
> Signed-off-by: Yifan Zhao <zhaoyifan28 at huawei.com>
> ---
>   lib/remotes/s3.c | 35 ++++++++++-------------------------
>   1 file changed, 10 insertions(+), 25 deletions(-)
> 
> diff --git a/lib/remotes/s3.c b/lib/remotes/s3.c
> index 2e7763e..2bd5322 100644
> --- a/lib/remotes/s3.c
> +++ b/lib/remotes/s3.c
> @@ -41,17 +41,16 @@ struct s3erofs_curl_request {
>   
>   static int s3erofs_prepare_url(struct s3erofs_curl_request *req,
>   			       const char *endpoint,
> -			       const char *path, const char *key,

I really think we should at least add a unittest for this.

you could simply add

#ifdef TEST
int main(int argc, char argv[])
{
	testfunc1();		// and use assert() if test fails
	testfunc2();
}
#endif

and use gcc -o s3_test -Iinclude -lcurl lib/remote/s3.c to generate a test program.

Thanks,
Gao Xiang



More information about the Linux-erofs mailing list