All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sasha Khapyorsky <sashak-smomgflXvOZWk0Htik3J/w@public.gmane.org>
To: Al Chu <chu11-i2BcT+NCU+M@public.gmane.org>
Cc: "linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
	<linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
Subject: Re: [infiniband-diags] [1/2] support libibnetdisc caching overwrite flag
Date: Mon, 19 Apr 2010 18:04:10 +0300	[thread overview]
Message-ID: <20100419150410.GA23994@me> (raw)
In-Reply-To: <1271375547.17987.178.camel-X2zTWyBD0EhliZ7u+bvwcg@public.gmane.org>

Hi Al,

On 16:52 Thu 15 Apr     , Al Chu wrote:
> diff --git a/infiniband-diags/libibnetdisc/src/ibnetdisc_cache.c b/infiniband-diags/libibnetdisc/src/ibnetdisc_cache.c
> index 480a0a2..6cf7d4d 100644
> --- a/infiniband-diags/libibnetdisc/src/ibnetdisc_cache.c
> +++ b/infiniband-diags/libibnetdisc/src/ibnetdisc_cache.c
> @@ -876,9 +876,20 @@ int ibnd_cache_fabric(ibnd_fabric_t * fabric, const char *file,
>  		return -1;
>  	}
>  
> -	if (!stat(file, &statbuf)) {
> -		IBND_DEBUG("file '%s' already exists\n", file);
> -		return -1;
> +	if (flags & IBND_CACHE_FABRIC_FLAG_OVERWRITE) {
> +		if (!stat(file, &statbuf)) {
> +			if (unlink(file) < 0) {
> +				IBND_DEBUG("error removing '%s': %s\n",
> +					   file, strerror(errno));
> +				return -1;
> +			}
> +		}
> +	}
> +	else {
> +		if (!stat(file, &statbuf)) {
> +			IBND_DEBUG("file '%s' already exists\n", file);
> +			return -1;
> +		}
>  	}

Wouldn't it be better to make it in opposite direction - overwrite file
by default and drop an error when "exclusive" flag is specified?

For me it looks as more "intuitive" behavior (similar to other
editors).

Sasha
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  parent reply	other threads:[~2010-04-19 15:04 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-15 23:52 [infiniband-diags] [1/2] support libibnetdisc caching overwrite flag Al Chu
     [not found] ` <1271375547.17987.178.camel-X2zTWyBD0EhliZ7u+bvwcg@public.gmane.org>
2010-04-19 15:04   ` Sasha Khapyorsky [this message]
2010-04-19 16:40     ` Al Chu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20100419150410.GA23994@me \
    --to=sashak-smomgflxvozwk0htik3j/w@public.gmane.org \
    --cc=chu11-i2BcT+NCU+M@public.gmane.org \
    --cc=linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.