[sheepdog] [PATCH] farm: use access(2) to check file existence
Liu Yuan
namei.unix at gmail.com
Mon May 21 04:41:19 CEST 2012
On 05/21/2012 12:11 AM, MORITA Kazutaka wrote:
> This simplifies the code a bit.
>
> Signed-off-by: MORITA Kazutaka <morita.kazutaka at lab.ntt.co.jp>
> ---
> sheep/farm/farm.c | 3 +--
> 1 files changed, 1 insertions(+), 2 deletions(-)
>
> diff --git a/sheep/farm/farm.c b/sheep/farm/farm.c
> index d9c63a8..fdb237e 100644
> --- a/sheep/farm/farm.c
> +++ b/sheep/farm/farm.c
> @@ -73,10 +73,9 @@ err:
> static int farm_exist(uint64_t oid)
> {
> char path[PATH_MAX];
> - struct stat s;
>
> sprintf(path, "%s%016"PRIx64, obj_path, oid);
> - if (stat(path, &s) < 0) {
> + if (access(path, R_OK | W_OK) < 0) {
> if (errno != ENOENT)
> eprintf("%m\n");
> return 0;
Applied, thanks.
Yuan
More information about the sheepdog
mailing list