diff options
author | Jean-Francois Brousseau <jfb@cvs.openbsd.org> | 2004-07-29 17:31:24 +0000 |
---|---|---|
committer | Jean-Francois Brousseau <jfb@cvs.openbsd.org> | 2004-07-29 17:31:24 +0000 |
commit | a29f9493eabe8565d36932026e30b8619537cf86 (patch) | |
tree | e69325a425d3189ef530f5573a2981513829dd0e /usr.bin | |
parent | 18a7595ad1fb26858f64a8c4d744d15502a548a0 (diff) |
Loop on the call to getdirentries() until there are no more entries.
Before this, only the first entries of the directory that fit in the
buffer were loaded
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/cvs/file.c | 63 |
1 files changed, 35 insertions, 28 deletions
diff --git a/usr.bin/cvs/file.c b/usr.bin/cvs/file.c index 3eb50d5672a..68c3c949567 100644 --- a/usr.bin/cvs/file.c +++ b/usr.bin/cvs/file.c @@ -1,4 +1,4 @@ -/* $OpenBSD: file.c,v 1.10 2004/07/29 16:59:39 jfb Exp $ */ +/* $OpenBSD: file.c,v 1.11 2004/07/29 17:31:23 jfb Exp $ */ /* * Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org> * All rights reserved. @@ -87,6 +87,10 @@ static const char *cvs_ign_std[] = { }; +/* + * Entries in the CVS/Entries file with a revision of '0' have only been + * added. Compare against this revision to see if this is the case + */ static RCSNUM *cvs_addedrev; @@ -409,7 +413,7 @@ cvs_file_getdir(struct cvs_file *cf, int flags) int nf, ret, fd; long base; void *dp, *ep, *tmp; - char fbuf[1024], pbuf[MAXPATHLEN]; + char fbuf[2048], pbuf[MAXPATHLEN]; struct dirent *ent; struct cvs_file *cfp; struct cvs_dir *cdp; @@ -438,35 +442,38 @@ cvs_file_getdir(struct cvs_file *cf, int flags) cvs_file_freedir(cdp); return (-1); } - ret = getdirentries(fd, fbuf, sizeof(fbuf), &base); - if (ret == -1) { - cvs_log(LP_ERRNO, "failed to get directory entries"); - (void)close(fd); - cvs_file_freedir(cdp); - return (-1); - } - - dp = fbuf; - ep = fbuf + (size_t)ret; - while (dp < ep) { - ent = (struct dirent *)dp; - dp += ent->d_reclen; - if ((flags & CF_IGNORE) && cvs_file_chkign(ent->d_name)) - continue; - - snprintf(pbuf, sizeof(pbuf), "%s/%s", cf->cf_path, ent->d_name); - cfp = cvs_file_get(pbuf, flags); - if (cfp != NULL) { - cfp->cf_parent = cf; + do { + ret = getdirentries(fd, fbuf, sizeof(fbuf), &base); + if (ret == -1) { + cvs_log(LP_ERRNO, "failed to get directory entries"); + (void)close(fd); + cvs_file_freedir(cdp); + return (-1); + } - if (cfp->cf_type == DT_DIR) - TAILQ_INSERT_HEAD(&dirs, cfp, cf_list); - else - TAILQ_INSERT_HEAD(&(cdp->cd_files), cfp, - cf_list); + dp = fbuf; + ep = fbuf + (size_t)ret; + while (dp < ep) { + ent = (struct dirent *)dp; + dp += ent->d_reclen; + + if ((flags & CF_IGNORE) && cvs_file_chkign(ent->d_name)) + continue; + + snprintf(pbuf, sizeof(pbuf), "%s/%s", + cf->cf_path, ent->d_name); + cfp = cvs_file_get(pbuf, flags); + if (cfp != NULL) { + cfp->cf_parent = cf; + if (cfp->cf_type == DT_DIR) + TAILQ_INSERT_HEAD(&dirs, cfp, cf_list); + else + TAILQ_INSERT_HEAD(&(cdp->cd_files), cfp, + cf_list); + } } - } + } while (ret > 0); if (flags & CF_SORT) { cvs_file_sort(&(cdp->cd_files)); |