[PATCH] Shows an error about wrong permissions

Jef Driesen jef at libdivecomputer.org
Fri Nov 14 04:43:49 PST 2014


On 2014-11-12 21:09, Salvo 'LtWorf' Tomaselli wrote:
> If an import fails, the permissions of the device are tested and an
> error message that mentions permissions is shown to the user.
> ---
>  libdivecomputer.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/libdivecomputer.c b/libdivecomputer.c
> index 981061b..fca1562 100644
> --- a/libdivecomputer.c
> +++ b/libdivecomputer.c
> @@ -870,7 +870,9 @@ const char *do_libdivecomputer_import(device_data_t 
> *data)
>  		err = do_device_import(data);
>  		/* TODO: Show the logfile to the user on error. */
>  		dc_device_close(data->device);
> -	}
> +	} else if (access(data->devname, R_OK | W_OK) != 0)
> +		err = translate("gettextFromC", "Insufficient privileges to open
> the device %s %s (%s)");

For the long term, I think a better solution would be to use the 
libdivecomputer return value. There are specific error codes for "device 
not found" (DC_STATUS_NODEVICE) and "access denied" 
(DC_STATUS_NOACCESS). The only catch here, is that at the moment these 
error codes are currently never returned because the serial backend just 
returns -1, and not some more specific error code. Changing that is 
something that has been on my todo list for quite a while already.

Jef


More information about the subsurface mailing list