ia64/xen-unstable

changeset 8644:c0a8a0b64f65

add some checking of opening and read in dom0_init and return -1 if error.
instead of crashing, it now prints a more meaningful error message.

Signed-off-by: Vincent Hanquez <vincent@xensource.com>
author vhanquez@kneesa.uk.xensource.com
date Tue Jan 24 13:14:42 2006 +0000 (2006-01-24)
parents 068857a7133d
children 1f87f39aa0e1
files tools/xenstore/xenstored_domain.c
line diff
     1.1 --- a/tools/xenstore/xenstored_domain.c	Tue Jan 24 12:06:48 2006 +0000
     1.2 +++ b/tools/xenstore/xenstored_domain.c	Tue Jan 24 13:14:42 2006 +0000
     1.3 @@ -468,28 +468,38 @@ static int dom0_init(void)
     1.4          struct domain *dom0; 
     1.5          
     1.6          fd = open(XENSTORED_PROC_MFN, O_RDONLY); 
     1.7 +	if (fd == -1)
     1.8 +		return -1;
     1.9          
    1.10          rc = read(fd, str, sizeof(str)); 
    1.11 +	if (rc == -1)
    1.12 +		goto outfd;
    1.13          str[rc] = '\0'; 
    1.14          mfn = strtoul(str, NULL, 0); 
    1.15          
    1.16          close(fd); 
    1.17          
    1.18          fd = open(XENSTORED_PROC_PORT, O_RDONLY); 
    1.19 +	if (fd == -1)
    1.20 +		return -1;
    1.21          
    1.22          rc = read(fd, str, sizeof(str)); 
    1.23 +	if (rc == -1)
    1.24 +		goto outfd;
    1.25          str[rc] = '\0'; 
    1.26          port = strtoul(str, NULL, 0); 
    1.27          
    1.28          close(fd); 
    1.29          
    1.30 -        
    1.31          dom0 = new_domain(NULL, 0, mfn, port); 
    1.32          talloc_steal(dom0->conn, dom0); 
    1.33  
    1.34          evtchn_notify(dom0->port); 
    1.35  
    1.36          return 0; 
    1.37 +outfd:
    1.38 +	close(fd);
    1.39 +	return -1;
    1.40  }
    1.41  
    1.42