[sheepdog] [PATCH v2 2/7] util: add a helper to purge directory

MORITA Kazutaka morita.kazutaka at lab.ntt.co.jp
Tue Mar 12 06:32:06 CET 2013


>  
> -/* remove directory recursively */
> -int rmdir_r(char *dir_path)
> +/* Purge directory recursively */
> +int purge_directory(char *dir_path)
>  {
>  	int ret;

ret must be initialized with zero.  Otherwise, this funciton can
return an uninitialized value.

Thanks,

Kazutaka

>  	struct stat s;
> @@ -293,13 +293,23 @@ int rmdir_r(char *dir_path)
>  			goto out;
>  		}
>  	}
> -
> -	ret = rmdir(dir_path);
>  out:
>  	closedir(dir);
>  	return ret;
>  }
>  
> +/* remove directory recursively */
> +int rmdir_r(char *dir_path)
> +{
> +	int ret;
> +
> +	ret = purge_directory(dir_path);
> +	if (ret == 0)
> +		ret = rmdir(dir_path);
> +
> +	return ret;
> +}
> +
>  /* Trim zero sectors from the beginning and end of buffer */
>  void trim_zero_sectors(void *buf, uint64_t *offset, uint32_t *len)
>  {
> -- 
> 1.7.9.5
> 
> -- 
> sheepdog mailing list
> sheepdog at lists.wpkg.org
> http://lists.wpkg.org/mailman/listinfo/sheepdog



More information about the sheepdog mailing list