=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/cvs/init.c,v retrieving revision 1.33 retrieving revision 1.34 diff -c -r1.33 -r1.34 *** src/usr.bin/cvs/init.c 2008/02/11 20:33:11 1.33 --- src/usr.bin/cvs/init.c 2008/06/10 15:50:31 1.34 *************** *** 1,4 **** ! /* $OpenBSD: init.c,v 1.33 2008/02/11 20:33:11 tobias Exp $ */ /* * Copyright (c) 2004 Jean-Francois Brousseau * Copyright (c) 2006 Xavier Santolaria --- 1,4 ---- ! /* $OpenBSD: init.c,v 1.34 2008/06/10 15:50:31 tobias Exp $ */ /* * Copyright (c) 2004 Jean-Francois Brousseau * Copyright (c) 2006 Xavier Santolaria *************** *** 32,37 **** --- 32,38 ---- #include #include + #include "atomicio.h" #include "cvs.h" #include "init.h" #include "remote.h" *************** *** 39,49 **** void cvs_init_local(void); static void init_mkdir(const char *, mode_t); ! static void init_mkfile(char *, const char *const *); struct cvsroot_file { char *cf_path; ! const char *const *cf_content; }; static const struct cvsroot_file cvsroot_files[] = { --- 40,50 ---- void cvs_init_local(void); static void init_mkdir(const char *, mode_t); ! static void init_mkfile(char *, const char **); struct cvsroot_file { char *cf_path; ! const char **cf_content; }; static const struct cvsroot_file cvsroot_files[] = { *************** *** 137,153 **** } static void ! init_mkfile(char *path, const char *const *content) { BUF *b; size_t len; int fd, openflags, rcsflags; char rpath[MAXPATHLEN]; ! const char *const *p; RCSFILE *file; - len = 0; - fd = -1; openflags = O_WRONLY|O_CREAT|O_EXCL; rcsflags = RCS_RDWR|RCS_CREATE; --- 138,152 ---- } static void ! init_mkfile(char *path, const char **content) { BUF *b; size_t len; int fd, openflags, rcsflags; char rpath[MAXPATHLEN]; ! const char **p; RCSFILE *file; openflags = O_WRONLY|O_CREAT|O_EXCL; rcsflags = RCS_RDWR|RCS_CREATE; *************** *** 157,170 **** if (content != NULL) { for (p = content; *p != NULL; ++p) { len = strlen(*p); ! b = cvs_buf_alloc(len); ! ! cvs_buf_append(b, *p, strlen(*p)); ! ! if (cvs_buf_write_fd(b, fd) < 0) ! fatal("init_mkfile: cvs_buf_write_fd"); ! ! cvs_buf_free(b); } } --- 156,163 ---- if (content != NULL) { for (p = content; *p != NULL; ++p) { len = strlen(*p); ! if (atomicio(vwrite, fd, *p, len) != len) ! fatal("init_mkfile: atomicio failed"); } } *************** *** 175,181 **** if (strcmp(strrchr(CVS_PATH_HISTORY, '/'), strrchr(path, '/')) == 0 || strcmp(strrchr(CVS_PATH_VALTAGS, '/'), strrchr(path, '/')) == 0) { (void)fchmod(fd, 0666); ! goto out; } (void)xsnprintf(rpath, MAXPATHLEN, "%s%s", path, RCS_FILE_EXT); --- 168,175 ---- if (strcmp(strrchr(CVS_PATH_HISTORY, '/'), strrchr(path, '/')) == 0 || strcmp(strrchr(CVS_PATH_VALTAGS, '/'), strrchr(path, '/')) == 0) { (void)fchmod(fd, 0666); ! (void)close(fd); ! return; } (void)xsnprintf(rpath, MAXPATHLEN, "%s%s", path, RCS_FILE_EXT); *************** *** 194,199 **** file->rf_flags &= ~RCS_SYNCED; rcs_close(file); - out: (void)close(fd); } --- 188,192 ----