Re: [PATCH] libtracefs: Fix wrong return value in tracefs_tracing_dir_is_mounted()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, 28 Nov 2022 14:21:06 +0100
Bean Huo <beanhuo@xxxxxxxx> wrote:

> From: Bean Huo <beanhuo@xxxxxxxxxx>
> 
> If it eventually mounts successfully, it should return 1 instead of
> 0, otherwise it will make the caller's verification logic more complicated

The man page shows:

  The tracefs_tracing_dir_is_mounted() returns 1 if the tracing directory is
  already mounted, 0 if it is not, and -1 on error.

If you only want to mount it and not care if it was already mounted then
use tracefs_tracing_dir(), as it will return the path of the mount point
and try to mount it if it is not already, or NULL if it could not mount it.

This function is specifically created to tell the application if it mounted
or not, so that it could unmount it when it is done. We have applications
that do this.

So, no, I'm not taking this change. It breaks the use case for this
function.

-- Steve


> 
> Signed-off-by: Bean Huo <beanhuo@xxxxxxxxxx>
> ---
>  src/tracefs-utils.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/tracefs-utils.c b/src/tracefs-utils.c
> index 777912e..5d6e977 100644
> --- a/src/tracefs-utils.c
> +++ b/src/tracefs-utils.c
> @@ -188,7 +188,7 @@ int tracefs_tracing_dir_is_mounted(bool mount, const char **path)
>  		return -1;
>  	if (path)
>  		*path = dir;
> -	return 0;
> +	return 1;
>  }
>  
>  /**




[Index of Archives]     [Linux USB Development]     [Linux USB Development]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux