index : pacman | |
Archlinux32 fork of pacman | gitolite user |
summaryrefslogtreecommitdiff |
author | Andrew Gregory <andrew.gregory.8@gmail.com> | 2013-08-09 09:15:40 -0400 |
---|---|---|
committer | Allan McRae <allan@archlinux.org> | 2013-08-21 11:13:46 +1000 |
commit | d8c2ab0e6f52d9a790b608c254761ab4888bd547 (patch) | |
tree | 8757702b8b428337c06056f8e3e24efc6d7664c4 /lib/libalpm/conflict.c | |
parent | 15b667ef36c1720e12160f2ca983f9783ddaf3e4 (diff) |
-rw-r--r-- | lib/libalpm/conflict.c | 16 |
diff --git a/lib/libalpm/conflict.c b/lib/libalpm/conflict.c index a00efe5c..54ed25e7 100644 --- a/lib/libalpm/conflict.c +++ b/lib/libalpm/conflict.c @@ -323,7 +323,7 @@ static int dir_belongsto_pkgs(alpm_handle_t *handle, const char *dirpath, while((ent = readdir(dir)) != NULL) { const char *name = ent->d_name; - int owned = 0; + int owned = 0, is_dir = 0; alpm_list_t *i; struct stat sbuf; @@ -331,8 +331,16 @@ static int dir_belongsto_pkgs(alpm_handle_t *handle, const char *dirpath, continue; } - snprintf(path, PATH_MAX, "%s%s", dirpath, name); - snprintf(full_path, PATH_MAX, "%s%s", handle->root, path); + snprintf(full_path, PATH_MAX, "%s%s%s", handle->root, dirpath, name); + + if(lstat(full_path, &sbuf) != 0) { + _alpm_log(handle, ALPM_LOG_DEBUG, "could not stat %s\n", full_path); + closedir(dir); + return 0; + } + is_dir = S_ISDIR(sbuf.st_mode); + + snprintf(path, PATH_MAX, "%s%s%s", dirpath, name, is_dir ? "/" : ""); for(i = pkgs; i && !owned; i = i->next) { if(alpm_filelist_contains(alpm_pkg_get_files(i->data), path)) { @@ -340,7 +348,7 @@ static int dir_belongsto_pkgs(alpm_handle_t *handle, const char *dirpath, } } - if(owned && stat(full_path, &sbuf) != 0 && S_ISDIR(sbuf.st_mode)) { + if(owned && is_dir) { owned = dir_belongsto_pkgs(handle, path, pkgs); } |