[sheepdog] [PATCH] sheep: allow working direcotry to be specified as storage directory

MORITA Kazutaka morita.kazutaka at lab.ntt.co.jp
Tue Dec 4 06:17:55 CET 2012


At Tue,  4 Dec 2012 10:53:47 +0800,
Liu Yuan wrote:
> 
> From: Liu Yuan <tailai.ly at taobao.com>
> 
> Signed-off-by: Liu Yuan <tailai.ly at taobao.com>
> ---
>  sheep/sheep.c |    7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/sheep/sheep.c b/sheep/sheep.c
> index c201d88..ab0b43f 100644
> --- a/sheep/sheep.c
> +++ b/sheep/sheep.c
> @@ -334,7 +334,8 @@ int main(int argc, char **argv)
>  {
>  	int ch, longindex;
>  	int ret, port = SD_LISTEN_PORT;
> -	const char *dir = DEFAULT_OBJECT_DIR;
> +	const char *dirp = DEFAULT_OBJECT_DIR;
> +	char *dir;
>  	bool is_daemon = true;
>  	bool to_stdout = false;
>  	int log_level = SDOG_INFO;
> @@ -486,8 +487,9 @@ int main(int argc, char **argv)
>  	}
>  
>  	if (optind != argc)
> -		dir = argv[optind];
> +		dirp = argv[optind];
>  
> +	dir = realpath(dirp, NULL);

realpath returns NULL when dirp doesn't exist.

sheep allowed a relative path before the following commit.
  5f6b83a logger: allow sheep dump core file for non-root startup
Perhaps, it is better to change working directory only when absolute
pathname is specified?

Thanks,

Kazutaka



More information about the sheepdog mailing list