[dm-devel] [PATCH 14/21] libmultipath: update_bindings_file: take filename argument

Benjamin Marzinski bmarzins at redhat.com
Wed Sep 6 22:45:04 UTC 2023


On Fri, Sep 01, 2023 at 08:02:27PM +0200, mwilck at suse.com wrote:
> From: Martin Wilck <mwilck at suse.com>
> 
> This function just uses the file name, no other configuration
> parameters. Also, pass the Bindings argument first to use the
> same convention as the other functions in this file.
> 
Reviewed-by: Benjamin Marzinski <bmarzins at redhat.com>
> Signed-off-by: Martin Wilck <mwilck at suse.com>
> ---
>  libmultipath/alias.c | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/libmultipath/alias.c b/libmultipath/alias.c
> index 5a6cdee..76d852f 100644
> --- a/libmultipath/alias.c
> +++ b/libmultipath/alias.c
> @@ -138,15 +138,15 @@ static int write_bindings_file(const Bindings *bindings, int fd)
>  	return 0;
>  }
>  
> -static int update_bindings_file(const struct config *conf,
> -				const Bindings *bindings)
> +static int update_bindings_file(const Bindings *bindings,
> +				const char *bindings_file)
>  {
>  	int rc;
>  	int fd = -1;
>  	char tempname[PATH_MAX];
>  	mode_t old_umask;
>  
> -	if (safe_sprintf(tempname, "%s.XXXXXX", conf->bindings_file))
> +	if (safe_sprintf(tempname, "%s.XXXXXX", bindings_file))
>  		return -1;
>  	/* coverity: SECURE_TEMP */
>  	old_umask = umask(0077);
> @@ -164,10 +164,10 @@ static int update_bindings_file(const struct config *conf,
>  		unlink(tempname);
>  		return rc;
>  	}
> -	if ((rc = rename(tempname, conf->bindings_file)) == -1)
> +	if ((rc = rename(tempname, bindings_file)) == -1)
>  		condlog(0, "%s: rename: %m", __func__);
>  	else
> -		condlog(1, "updated bindings file %s", conf->bindings_file);
> +		condlog(1, "updated bindings file %s", bindings_file);
>  	return rc;
>  }
>  
> @@ -778,7 +778,7 @@ int check_alias_settings(const struct config *conf)
>  			rc = _check_bindings_file(conf, file, &bindings);
>  			pthread_cleanup_pop(1);
>  			if (rc == -1 && can_write && !conf->bindings_read_only)
> -				rc = update_bindings_file(conf, &bindings);
> +				rc = update_bindings_file(&bindings, conf->bindings_file);
>  			else if (rc == -1)
>  				condlog(0, "ERROR: bad settings in read-only bindings file %s",
>  					conf->bindings_file);
> -- 
> 2.41.0


More information about the dm-devel mailing list