[PATCH] makedumpfile: Check dump file early

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

 



(2013/04/20 0:36), Michael Holzheu wrote:
> On s390 the makedumpfile tool sometimes is used directly by
> users on the command line. Currently the check if the dump
> file already exists is done after the filtering function has
> been called. Therefore, for large dumps the user has to wait
> for filtering and after some time he gets the error message
> "open_dump_file: Can't open the dump file(out). File exists".
>
> This patch improves this by adding an early check for the
> existence of the dump file. In case the -f (force) option has
> been specified it is checked that an existing file is writable.
>
> Signed-off-by: Michael Holzheu <holzheu at linux.vnet.ibm.com>
> ---
>   makedumpfile.c |   37 ++++++++++++++++++++++++++++++++++++-
>   1 file changed, 36 insertions(+), 1 deletion(-)
>
> --- a/makedumpfile.c
> +++ b/makedumpfile.c
> @@ -730,6 +730,24 @@ open_dump_file(void)
>   }
>
>   int
> +check_dump_file(const char *path)
> +{
> +	char *err_str;
> +
> +	if (access(path, F_OK) != 0)
> +		return TRUE; /* File does not exist */
> +	if (info->flag_force) {
> +		if (access(path, W_OK) == 0)
> +			return TRUE; /* We have write permission */
> +		err_str = strerror(errno);
> +	} else {
> +		err_str = "File exists";

How about strerror(EEXIST)? It's better to avoid hard code to use the 
same string as what libc returns.

-- 
Thanks.
HATAYAMA, Daisuke




[Index of Archives]     [LM Sensors]     [Linux Sound]     [ALSA Users]     [ALSA Devel]     [Linux Audio Users]     [Linux Media]     [Kernel]     [Gimp]     [Yosemite News]     [Linux Media]

  Powered by Linux