=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/cvs/init.c,v retrieving revision 1.20 retrieving revision 1.21 diff -u -r1.20 -r1.21 --- src/usr.bin/cvs/init.c 2006/01/02 08:11:56 1.20 +++ src/usr.bin/cvs/init.c 2006/01/08 18:02:06 1.21 @@ -1,4 +1,4 @@ -/* $OpenBSD: init.c,v 1.20 2006/01/02 08:11:56 xsa Exp $ */ +/* $OpenBSD: init.c,v 1.21 2006/01/08 18:02:06 xsa Exp $ */ /* * Copyright (c) 2004 Jean-Francois Brousseau * All rights reserved. @@ -57,7 +57,7 @@ }; static int cvs_init_pre_exec(struct cvsroot *); -static int cvs_init_create_files(struct cvsroot *); +static void cvs_init_create_files(struct cvsroot *); struct cvs_cmd cvs_cmd_init = { CVS_OP_INIT, CVS_REQ_INIT, "init", @@ -85,10 +85,8 @@ static int cvs_init_pre_exec(struct cvsroot *root) { - if (root->cr_method == CVS_METHOD_LOCAL) { - if (cvs_init_create_files(root) < 0) - return (CVS_EX_FILE); - } + if (root->cr_method == CVS_METHOD_LOCAL) + cvs_init_create_files(root); return (0); } @@ -101,7 +99,7 @@ * Returns 0 on success, -1 on failure. * */ -static int +static void cvs_init_create_files(struct cvsroot *root) { size_t len; @@ -115,9 +113,8 @@ if (mkdir(root->cr_dir, 0777) == -1) { if (!(errno == EEXIST || (errno == EACCES && (stat(root->cr_dir, &st) == 0) && S_ISDIR(st.st_mode)))) { - cvs_log(LP_ERRNO, "cannot make directory %s", - root->cr_dir); - return (CVS_EX_FILE); + fatal("cvs_init_create_files: mkdir: %s: %s", + root->cr_dir, strerror(errno)); } } @@ -126,38 +123,32 @@ len = cvs_path_cat(root->cr_dir, cvsroot_files[i].cf_path, path, sizeof(path)); if (len >= sizeof(path)) - return (-1); + fatal("cvs_init_create_files: path truncation"); if (cvsroot_files[i].cf_type == CFT_DIR) { if (mkdir(path, cvsroot_files[i].cf_mode) == -1) { if (!(errno == EEXIST || (errno == EACCES && (stat(path, &st) == 0) && S_ISDIR(st.st_mode)))) { - cvs_log(LP_ERRNO, - "cannot make directory %s", path); - return (CVS_EX_FILE); + fatal("cvs_init_create_files: mkdir: " + "%s: %s", path, strerror(errno)); } } } else if (cvsroot_files[i].cf_type == CFT_FILE) { fd = open(path, O_WRONLY|O_CREAT|O_EXCL, cvsroot_files[i].cf_mode); - if (fd == -1) { - cvs_log(LP_ERRNO, "failed to create `%s'", - path); - return (CVS_EX_FILE); - } + if (fd == -1) + fatal("cvs_init_create_file: open failed: %s", + strerror(errno)); (void)close(fd); strlcat(path, RCS_FILE_EXT, sizeof(path)); rfp = rcs_open(path, RCS_WRITE|RCS_CREATE, 0640); - if (rfp == NULL) { - return (CVS_EX_DATA); - } + if (rfp == NULL) + return; rcs_close(rfp); } } - - return (0); }