librazor/root.c
changeset 428 6707b8b11f55
parent 424 8cbc438cc298
child 439 f28bb31024b4
     1.1 --- a/librazor/root.c	Thu Feb 16 17:33:47 2012 +0000
     1.2 +++ b/librazor/root.c	Mon Feb 20 19:30:23 2012 +0000
     1.3 @@ -77,7 +77,7 @@
     1.4  }
     1.5  
     1.6  RAZOR_EXPORT int
     1.7 -razor_root_create(const char *root)
     1.8 +razor_root_create(const char *root, struct razor_error **error)
     1.9  {
    1.10  	int retval;
    1.11  	struct stat buf;
    1.12 @@ -92,16 +92,12 @@
    1.13  		/* root is file system root */
    1.14  	} else if (stat(root, &buf) < 0) {
    1.15  		if (mkdir(root, 0777) < 0) {
    1.16 -			fprintf(stderr,
    1.17 -				"could not create install root \"%s\"\n",
    1.18 -				root);
    1.19 +			razor_set_error(error, root,
    1.20 +					"Could not create install root");
    1.21  			return -1;
    1.22  		}
    1.23 -		fprintf(stderr, "created install root \"%s\"\n", root);
    1.24  	} else if (!S_ISDIR(buf.st_mode)) {
    1.25 -		fprintf(stderr,
    1.26 -			"install root \"%s\" exists, but is not a directory\n",
    1.27 -			root);
    1.28 +		razor_set_error(error, root, "Not a directory");
    1.29  		return -1;
    1.30  	}
    1.31  
    1.32 @@ -109,8 +105,8 @@
    1.33  	path = razor_concat(root, file, NULL);
    1.34  	retval = !stat(path, &buf);
    1.35  	if (retval) {
    1.36 -		fprintf(stderr,
    1.37 -			"a razor install root is already initialized\n");
    1.38 +		razor_set_error(error, NULL,
    1.39 +				"A razor install root is already initialized");
    1.40  		free(path);
    1.41  		free(file);
    1.42  		return retval;
    1.43 @@ -124,7 +120,8 @@
    1.44  	free(file);
    1.45  	retval = razor_atomic_commit(atomic);
    1.46  	if (retval)
    1.47 -		fprintf(stderr, "could not write initial package set\n");
    1.48 +		razor_set_error(error, NULL,
    1.49 +				"Could not write initial package set");
    1.50  	razor_set_unref(set);
    1.51  	razor_atomic_destroy(atomic);
    1.52