summaryrefslogtreecommitdiff
path: root/usr.bin/cvs
diff options
context:
space:
mode:
authorXavier Santolaria <xsa@cvs.openbsd.org>2005-06-07 07:23:42 +0000
committerXavier Santolaria <xsa@cvs.openbsd.org>2005-06-07 07:23:42 +0000
commit9dc111a7a22f4eaf193e3e7260f2bcd5cba7ec72 (patch)
tree9296e10ea18cfef9a6ca245e24fc5b8886b0dc0d /usr.bin/cvs
parent8e50e9947d0a355ca0701c231824311f3a884d0a (diff)
only display the ``cannot open ./CVS/Entries'' error message when
appropriate ... ok joris@.
Diffstat (limited to 'usr.bin/cvs')
-rw-r--r--usr.bin/cvs/entries.c27
1 files changed, 22 insertions, 5 deletions
diff --git a/usr.bin/cvs/entries.c b/usr.bin/cvs/entries.c
index 4ad91495a61..2c93ffa7490 100644
--- a/usr.bin/cvs/entries.c
+++ b/usr.bin/cvs/entries.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: entries.c,v 1.35 2005/06/02 20:19:30 joris Exp $ */
+/* $OpenBSD: entries.c,v 1.36 2005/06/07 07:23:41 xsa Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -53,16 +53,32 @@ CVSENTRIES*
cvs_ent_open(const char *dir, int flags)
{
size_t len;
- int exists;
- char entpath[MAXPATHLEN], ebuf[128], mode[4];
+ int exists, nodir;
+ char cdpath[MAXPATHLEN], entpath[MAXPATHLEN], ebuf[128], mode[4];
FILE *fp;
struct stat st;
struct cvs_ent *ent;
CVSENTRIES *ep;
exists = 0;
+ nodir = 1;
memset(mode, 0, sizeof(mode));
+ /*
+ * Check if the CVS/ dir does exist. If it does,
+ * maybe the Entries file was deleted by accident,
+ * display error message. Else we might be doing a fresh
+ * update or checkout of a module.
+ */
+ len = cvs_path_cat(dir, CVS_PATH_CVSDIR, cdpath, sizeof(cdpath));
+ if (len >= sizeof(cdpath)) {
+ errno = ENAMETOOLONG;
+ cvs_log(LP_ERRNO, "%s", cdpath);
+ return (NULL);
+ }
+ if ((stat(cdpath, &st) == 0) && S_ISDIR(st.st_mode))
+ nodir = 0; /* the CVS/ directory does exist */
+
len = cvs_path_cat(dir, CVS_PATH_ENTRIES, entpath, sizeof(entpath));
if (len >= sizeof(entpath))
return (NULL);
@@ -87,8 +103,9 @@ cvs_ent_open(const char *dir, int flags)
fp = fopen(entpath, mode);
if (fp == NULL) {
- cvs_log(LP_ERRNO, "cannot open %s for %s", entpath,
- mode[1] == '+' ? "writing" : "reading");
+ if (!nodir)
+ cvs_log(LP_ERRNO, "cannot open %s for %s", entpath,
+ mode[1] == '+' ? "writing" : "reading");
return (NULL);
}