[pacman-dev] [PATCH] Drastically reduce the number of syscalls.

Tim Nieradzik tim.nieradzik at gmx.de
Mon Jul 26 10:17:31 EDT 2010


---
 lib/libalpm/be_files.c |   18 ++----------------
 1 files changed, 2 insertions(+), 16 deletions(-)

diff --git a/lib/libalpm/be_files.c b/lib/libalpm/be_files.c
index adf41aa..ddef742 100644
--- a/lib/libalpm/be_files.c
+++ b/lib/libalpm/be_files.c
@@ -113,8 +113,6 @@ static int dirlist_from_fs(const char *syncdbpath, alpm_list_t **dirlist)
 {
 	DIR *dbdir;
 	struct dirent *ent = NULL;
-	struct stat sbuf;
-	char path[PATH_MAX];
 
 	dbdir = opendir(syncdbpath);
 	if (dbdir != NULL) {
@@ -128,8 +126,7 @@ static int dirlist_from_fs(const char *syncdbpath, alpm_list_t **dirlist)
 			}
 
 			/* stat the entry, make sure it's a directory */
-			snprintf(path, PATH_MAX, "%s%s", syncdbpath, name);
-			if(stat(path, &sbuf) != 0 || !S_ISDIR(sbuf.st_mode)) {
+			if(ent->d_type != DT_DIR) {
 				continue;
 			}
 
@@ -353,8 +350,6 @@ int _alpm_db_populate(pmdb_t *db)
 {
 	int count = 0;
 	struct dirent *ent = NULL;
-	struct stat sbuf;
-	char path[PATH_MAX];
 	const char *dbpath;
 	DIR *dbdir;
 
@@ -374,9 +369,7 @@ int _alpm_db_populate(pmdb_t *db)
 		if(strcmp(name, ".") == 0 || strcmp(name, "..") == 0) {
 			continue;
 		}
-		/* stat the entry, make sure it's a directory */
-		snprintf(path, PATH_MAX, "%s%s", dbpath, name);
-		if(stat(path, &sbuf) != 0 || !S_ISDIR(sbuf.st_mode)) {
+		if(ent->d_type != DT_DIR) {
 			continue;
 		}
 
@@ -475,13 +468,6 @@ int _alpm_db_read(pmdb_t *db, pmpkg_t *info, pmdbinfrq_t inforeq)
 
 	pkgpath = get_pkgpath(db, info);
 
-	if(access(pkgpath, F_OK)) {
-		/* directory doesn't exist or can't be opened */
-		_alpm_log(PM_LOG_DEBUG, "cannot find '%s-%s' in db '%s'\n",
-				info->name, info->version, db->treename);
-		goto error;
-	}
-
 	/* DESC */
 	if(inforeq & INFRQ_DESC) {
 		snprintf(path, PATH_MAX, "%sdesc", pkgpath);
-- 
1.7.2



More information about the pacman-dev mailing list