ia64/xen-unstable

changeset 10046:08f5adb5058b

Try to create runtime xenstored's directories at startup time.

Signed-off-by: Vincent Hanquez <vincent@xensource.com>
author vhanquez@kneesa.uk.xensource.com
date Thu May 11 15:01:54 2006 +0100 (2006-05-11)
parents fdd64fd51edd
children 891e0d1cf4ab
files tools/xenstore/xenstored_core.c tools/xenstore/xs_lib.c tools/xenstore/xs_lib.h
line diff
     1.1 --- a/tools/xenstore/xenstored_core.c	Thu May 11 13:49:20 2006 +0100
     1.2 +++ b/tools/xenstore/xenstored_core.c	Thu May 11 15:01:54 2006 +0100
     1.3 @@ -1811,6 +1811,21 @@ int main(int argc, char *argv[])
     1.4  
     1.5  	reopen_log();
     1.6  
     1.7 +	/* make sure xenstored directory exists */
     1.8 +	if (mkdir(xs_daemon_rundir(), 0755)) {
     1.9 +		if (errno != EEXIST) {
    1.10 +			perror("error: mkdir daemon rundir");
    1.11 +			exit(-1);
    1.12 +		}
    1.13 +	}
    1.14 +
    1.15 +	if (mkdir(xs_daemon_rootdir(), 0755)) {
    1.16 +		if (errno != EEXIST) {
    1.17 +			perror("error: mkdir daemon rootdir");
    1.18 +			exit(-1);
    1.19 +		}
    1.20 +	}
    1.21 +
    1.22  	if (dofork) {
    1.23  		openlog("xenstored", 0, LOG_DAEMON);
    1.24  		daemonize();
     2.1 --- a/tools/xenstore/xs_lib.c	Thu May 11 13:49:20 2006 +0100
     2.2 +++ b/tools/xenstore/xs_lib.c	Thu May 11 15:01:54 2006 +0100
     2.3 @@ -26,13 +26,13 @@
     2.4  
     2.5  /* Common routines for the Xen store daemon and client library. */
     2.6  
     2.7 -static const char *xs_daemon_rootdir(void)
     2.8 +const char *xs_daemon_rootdir(void)
     2.9  {
    2.10  	char *s = getenv("XENSTORED_ROOTDIR");
    2.11  	return (s ? s : "/var/lib/xenstored");
    2.12  }
    2.13  
    2.14 -static const char *xs_daemon_rundir(void)
    2.15 +const char *xs_daemon_rundir(void)
    2.16  {
    2.17  	char *s = getenv("XENSTORED_RUNDIR");
    2.18  	return (s ? s : "/var/run/xenstored");
     3.1 --- a/tools/xenstore/xs_lib.h	Thu May 11 13:49:20 2006 +0100
     3.2 +++ b/tools/xenstore/xs_lib.h	Thu May 11 15:01:54 2006 +0100
     3.3 @@ -46,6 +46,8 @@ struct xs_permissions
     3.4  #define MAX_STRLEN(x) ((sizeof(x) * CHAR_BIT + CHAR_BIT-1) / 10 * 3 + 2)
     3.5  
     3.6  /* Path for various daemon things: env vars can override. */
     3.7 +const char *xs_daemon_rootdir(void);
     3.8 +const char *xs_daemon_rundir(void);
     3.9  const char *xs_daemon_socket(void);
    3.10  const char *xs_daemon_socket_ro(void);
    3.11  const char *xs_domain_dev(void);