summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/cvs/file.c43
-rw-r--r--usr.bin/cvs/file.h6
2 files changed, 28 insertions, 21 deletions
diff --git a/usr.bin/cvs/file.c b/usr.bin/cvs/file.c
index bd3c98c0165..5774b78515b 100644
--- a/usr.bin/cvs/file.c
+++ b/usr.bin/cvs/file.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: file.c,v 1.114 2005/08/17 08:35:53 xsa Exp $ */
+/* $OpenBSD: file.c,v 1.115 2005/08/17 16:23:19 joris Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -114,7 +114,8 @@ static int cvs_file_sort(struct cvs_flist *, u_int);
static int cvs_file_cmp(const void *, const void *);
static int cvs_file_cmpname(const char *, const char *);
static CVSFILE *cvs_file_alloc(const char *, u_int);
-static CVSFILE *cvs_file_lget(const char *, int, CVSFILE *, struct cvs_ent *);
+static CVSFILE *cvs_file_lget(const char *, int, CVSFILE *, CVSENTRIES *,
+ struct cvs_ent *);
/*
@@ -392,7 +393,7 @@ cvs_file_getspec(char **fspec, int fsn, int flags, int (*cb)(CVSFILE *, void *),
* Fetch the needed information about ".", so we can setup a few
* things to get ourselfs going.
*/
- cf = cvs_file_lget(".", 0, NULL, NULL);
+ cf = cvs_file_lget(".", 0, NULL, NULL, NULL);
if (cf == NULL) {
cvs_log(LP_ERR, "arrrr i failed captain!");
return (-1);
@@ -523,7 +524,7 @@ cvs_file_loadinfo(char *path, int flags, int (*cb)(CVSFILE *, void *),
* There might not be an Entries file, so do not fail if there
* is none available to get the info from.
*/
- entf = cvs_ent_open(parent, O_RDONLY);
+ entf = cvs_ent_open(parent, O_RDWR);
/*
* Load the Entry if we successfully opened the Entries file.
@@ -552,9 +553,9 @@ cvs_file_loadinfo(char *path, int flags, int (*cb)(CVSFILE *, void *),
* <path> for a directory.
*/
if (type == DT_DIR)
- base = cvs_file_lget(path, flags, NULL, ent);
+ base = cvs_file_lget(path, flags, NULL, entf, ent);
else
- base = cvs_file_lget(parent, flags, NULL, NULL);
+ base = cvs_file_lget(parent, flags, NULL, entf, NULL);
if (base == NULL) {
cvs_log(LP_ERR, "failed to obtain directory info for '%s'",
@@ -582,7 +583,7 @@ cvs_file_loadinfo(char *path, int flags, int (*cb)(CVSFILE *, void *),
* to the base.
*/
if (type != DT_DIR) {
- cf = cvs_file_lget(path, flags, base, ent);
+ cf = cvs_file_lget(path, flags, base, entf, ent);
if (cf == NULL) {
cvs_error = CVS_EX_DATA;
goto fail;
@@ -591,11 +592,6 @@ cvs_file_loadinfo(char *path, int flags, int (*cb)(CVSFILE *, void *),
cvs_file_attach(base, cf);
}
- if (entf != NULL) {
- cvs_ent_close(entf);
- entf = NULL;
- }
-
/*
* Always pass the base directory, unless:
* - we are running in server or local mode and the path is not "."
@@ -608,6 +604,11 @@ cvs_file_loadinfo(char *path, int flags, int (*cb)(CVSFILE *, void *),
((cvs_error = cb(base, arg)) != CVS_EX_OK))
goto fail;
+ if (entf != NULL) {
+ cvs_ent_close(entf);
+ entf = NULL;
+ }
+
/*
* If we have a normal file, pass it as well.
*/
@@ -830,7 +831,7 @@ cvs_file_getdir(CVSFILE *cf, int flags, int (*cb)(CVSFILE *, void *),
}
ret = -1;
- entf = cvs_ent_open(fpath, O_RDONLY);
+ entf = cvs_ent_open(fpath, O_RDWR);
while ((de = readdir(dp)) != NULL) {
if (!strcmp(de->d_name, ".") ||
!strcmp(de->d_name, ".."))
@@ -863,7 +864,7 @@ cvs_file_getdir(CVSFILE *cf, int flags, int (*cb)(CVSFILE *, void *),
else
ent = NULL;
- cfp = cvs_file_lget(pbuf, flags, cf, ent);
+ cfp = cvs_file_lget(pbuf, flags, cf, entf, ent);
if (cfp == NULL) {
cvs_log(LP_ERR, "failed to get '%s'", pbuf);
goto done;
@@ -923,7 +924,7 @@ cvs_file_getdir(CVSFILE *cf, int flags, int (*cb)(CVSFILE *, void *),
if (len >= sizeof(pbuf))
goto done;
- cfp = cvs_file_lget(pbuf, flags, cf, ent);
+ cfp = cvs_file_lget(pbuf, flags, cf, entf, ent);
if (cfp == NULL) {
cvs_log(LP_ERR, "failed to fetch '%s'", pbuf);
goto done;
@@ -1180,7 +1181,8 @@ cvs_file_alloc(const char *path, u_int type)
* failure.
*/
static CVSFILE *
-cvs_file_lget(const char *path, int flags, CVSFILE *parent, struct cvs_ent *ent)
+cvs_file_lget(const char *path, int flags, CVSFILE *parent, CVSENTRIES *pent,
+ struct cvs_ent *ent)
{
int ret;
u_int type;
@@ -1195,6 +1197,7 @@ cvs_file_lget(const char *path, int flags, CVSFILE *parent, struct cvs_ent *ent)
if ((cfp = cvs_file_alloc(path, type)) == NULL)
return (NULL);
cfp->cf_parent = parent;
+ cfp->cf_entry = pent;
if ((cfp->cf_type == DT_DIR) && (cfp->cf_parent == NULL))
cfp->cf_flags |= CVS_DIRF_BASE;
@@ -1276,9 +1279,11 @@ cvs_file_lget(const char *path, int flags, CVSFILE *parent, struct cvs_ent *ent)
}
}
- if ((cfp->cf_type == DT_DIR) && (cvs_load_dirinfo(cfp, flags) < 0)) {
- cvs_file_free(cfp);
- return (NULL);
+ if (cfp->cf_type == DT_DIR) {
+ if (cvs_load_dirinfo(cfp, flags) < 0) {
+ cvs_file_free(cfp);
+ return (NULL);
+ }
}
if ((cfp->cf_repo != NULL) && (cfp->cf_type == DT_DIR) &&
diff --git a/usr.bin/cvs/file.h b/usr.bin/cvs/file.h
index 6e0a1f2f34b..5926514dc46 100644
--- a/usr.bin/cvs/file.h
+++ b/usr.bin/cvs/file.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: file.h,v 1.27 2005/07/31 21:08:17 joris Exp $ */
+/* $OpenBSD: file.h,v 1.28 2005/08/17 16:23:19 joris Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -84,6 +84,9 @@ typedef struct cvs_file {
const char *cf_name;
const char *cf_dir;
+ /* pointer to the parent directory's entry file */
+ void *cf_entry;
+
mode_t cf_mode;
u_int8_t cf_cvstat; /* cvs status of the file */
u_int8_t cf_type; /* uses values from dirent.h */
@@ -120,7 +123,6 @@ typedef struct cvs_file {
#define cf_root cf_td.cf_dir.cd_root
-
#define CVS_DIRF_STATIC 0x01
#define CVS_DIRF_STICKY 0x02
#define CVS_DIRF_BASE 0x04