summaryrefslogtreecommitdiffstats
path: root/lib/libalpm/be_files.c
diff options
context:
space:
mode:
authorVMiklos <vmiklos@frugalware.org>2007-05-31 21:18:24 +0200
committerDan McGee <dan@archlinux.org>2007-06-09 18:58:12 +0200
commitdfc85cb5f516ffbcff557522e9703c5c7d88b047 (patch)
tree69b491d7ae8f8b70804833b893ed6f722276fb4b /lib/libalpm/be_files.c
parent25c5b39d05cdb8856098429d0fa6f8da595d5af6 (diff)
downloadpacman-dfc85cb5f516ffbcff557522e9703c5c7d88b047.tar.gz
pacman-dfc85cb5f516ffbcff557522e9703c5c7d88b047.tar.xz
Add a alpm_db_test() function to the backend for checking DB consistency
Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'lib/libalpm/be_files.c')
-rw-r--r--lib/libalpm/be_files.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/lib/libalpm/be_files.c b/lib/libalpm/be_files.c
index 2cd14e15..b338af9d 100644
--- a/lib/libalpm/be_files.c
+++ b/lib/libalpm/be_files.c
@@ -65,6 +65,37 @@ int _alpm_db_install(pmdb_t *db, const char *dbfile)
return unlink(dbfile);
}
+alpm_list_t *_alpm_db_test(pmdb_t *db)
+{
+ struct dirent *ent;
+ char path[PATH_MAX];
+ struct stat buf;
+ alpm_list_t *ret = NULL;
+
+ while ((ent = readdir(db->handle)) != NULL) {
+ if(!strcmp(ent->d_name, ".") || !strcmp(ent->d_name, "..")) {
+ continue;
+ }
+ /* check for desc, depends, and files */
+ snprintf(path, PATH_MAX, "%s/%s/desc", db->path, ent->d_name);
+ if(stat(path, &buf)) {
+ snprintf(path, LOG_STR_LEN, _("%s: description file is missing"), ent->d_name);
+ ret = alpm_list_add(ret, strdup(path));
+ }
+ snprintf(path, PATH_MAX, "%s/%s/depends", db->path, ent->d_name);
+ if(stat(path, &buf)) {
+ snprintf(path, LOG_STR_LEN, _("%s: dependency file is missing"), ent->d_name);
+ ret = alpm_list_add(ret, strdup(path));
+ }
+ snprintf(path, PATH_MAX, "%s/%s/files", db->path, ent->d_name);
+ if(stat(path, &buf)) {
+ snprintf(path, LOG_STR_LEN, _("%s: file list is missing"), ent->d_name);
+ ret = alpm_list_add(ret, strdup(path));
+ }
+ }
+ return(ret);
+}
+
int _alpm_db_open(pmdb_t *db)
{
ALPM_LOG_FUNC;