diff options
-rw-r--r-- | lib/libalpm/add.c | 4 | ||||
-rw-r--r-- | lib/libalpm/conflict.c | 2 | ||||
-rw-r--r-- | lib/libalpm/diskspace.c | 2 | ||||
-rw-r--r-- | lib/libalpm/remove.c | 2 | ||||
-rw-r--r-- | lib/libalpm/util.c | 25 | ||||
-rw-r--r-- | lib/libalpm/util.h | 2 | ||||
-rw-r--r-- | src/common/util-common.c | 25 | ||||
-rw-r--r-- | src/common/util-common.h | 4 |
8 files changed, 34 insertions, 32 deletions
diff --git a/lib/libalpm/add.c b/lib/libalpm/add.c index 4f557a47..bbf2a511 100644 --- a/lib/libalpm/add.c +++ b/lib/libalpm/add.c @@ -209,7 +209,7 @@ static int extract_single_file(alpm_handle_t *handle, struct archive *archive, * F/N | 3 | 4 * D | 5 | 6 * - * 1,2- extract, no magic necessary. lstat (_alpm_lstat) will fail here. + * 1,2- extract, no magic necessary. lstat (llstat) will fail here. * 3,4- conflict checks should have caught this. either overwrite * or backup the file. * 5- file replacing directory- don't allow it. @@ -217,7 +217,7 @@ static int extract_single_file(alpm_handle_t *handle, struct archive *archive, */ struct stat lsbuf; - if(_alpm_lstat(filename, &lsbuf) != 0) { + if(llstat(filename, &lsbuf) != 0) { /* cases 1,2: file doesn't exist, skip all backup checks */ } else { if(S_ISDIR(lsbuf.st_mode)) { diff --git a/lib/libalpm/conflict.c b/lib/libalpm/conflict.c index 2611aefc..961e3a74 100644 --- a/lib/libalpm/conflict.c +++ b/lib/libalpm/conflict.c @@ -495,7 +495,7 @@ alpm_list_t *_alpm_db_find_fileconflicts(alpm_handle_t *handle, relative_path = path + rootlen; /* stat the file - if it exists, do some checks */ - if(_alpm_lstat(path, &lsbuf) != 0) { + if(llstat(path, &lsbuf) != 0) { continue; } diff --git a/lib/libalpm/diskspace.c b/lib/libalpm/diskspace.c index d07b188d..606f2dcc 100644 --- a/lib/libalpm/diskspace.c +++ b/lib/libalpm/diskspace.c @@ -235,7 +235,7 @@ static int calculate_removed_size(alpm_handle_t *handle, const char *filename = file->name; snprintf(path, PATH_MAX, "%s%s", handle->root, filename); - _alpm_lstat(path, &st); + llstat(path, &st); /* skip directories and symlinks to be consistent with libarchive that * reports them to be zero size */ diff --git a/lib/libalpm/remove.c b/lib/libalpm/remove.c index 5cbeeb96..dd061e5e 100644 --- a/lib/libalpm/remove.c +++ b/lib/libalpm/remove.c @@ -457,7 +457,7 @@ static int unlink_file(alpm_handle_t *handle, alpm_pkg_t *oldpkg, return 1; } - if(_alpm_lstat(file, &buf)) { + if(llstat(file, &buf)) { _alpm_log(handle, ALPM_LOG_DEBUG, "file %s does not exist\n", file); return 1; } diff --git a/lib/libalpm/util.c b/lib/libalpm/util.c index d9f741b3..6dab0de2 100644 --- a/lib/libalpm/util.c +++ b/lib/libalpm/util.c @@ -742,31 +742,6 @@ const char *_alpm_filecache_setup(alpm_handle_t *handle) return cachedir; } -/** lstat wrapper that treats /path/dirsymlink/ the same as /path/dirsymlink. - * Linux lstat follows POSIX semantics and still performs a dereference on - * the first, and for uses of lstat in libalpm this is not what we want. - * @param path path to file to lstat - * @param buf structure to fill with stat information - * @return the return code from lstat - */ -int _alpm_lstat(const char *path, struct stat *buf) -{ - int ret; - size_t len = strlen(path); - - /* strip the trailing slash if one exists */ - if(len != 0 && path[len - 1] == '/') { - char *newpath = strdup(path); - newpath[len - 1] = '\0'; - ret = lstat(newpath, buf); - free(newpath); - } else { - ret = lstat(path, buf); - } - - return ret; -} - #ifdef HAVE_LIBSSL /** Compute the MD5 message digest of a file. * @param path file path of file to compute MD5 digest of diff --git a/lib/libalpm/util.h b/lib/libalpm/util.h index 20f63f64..6f47073b 100644 --- a/lib/libalpm/util.h +++ b/lib/libalpm/util.h @@ -35,7 +35,6 @@ #include <stdarg.h> #include <stddef.h> /* size_t */ #include <sys/types.h> -#include <sys/stat.h> /* struct stat */ #include <math.h> /* fabs */ #include <float.h> /* DBL_EPSILON */ #include <fcntl.h> /* open, close */ @@ -128,7 +127,6 @@ int _alpm_ldconfig(alpm_handle_t *handle); int _alpm_str_cmp(const void *s1, const void *s2); char *_alpm_filecache_find(alpm_handle_t *handle, const char *filename); const char *_alpm_filecache_setup(alpm_handle_t *handle); -int _alpm_lstat(const char *path, struct stat *buf); int _alpm_test_checksum(const char *filepath, const char *expected, alpm_pkgvalidation_t type); int _alpm_archive_fgets(struct archive *a, struct archive_read_buffer *b); int _alpm_splitname(const char *target, char **name, char **version, diff --git a/src/common/util-common.c b/src/common/util-common.c index c5097ddf..e6f95194 100644 --- a/src/common/util-common.c +++ b/src/common/util-common.c @@ -73,6 +73,31 @@ char *mdirname(const char *path) return strdup("."); } +/** lstat wrapper that treats /path/dirsymlink/ the same as /path/dirsymlink. + * Linux lstat follows POSIX semantics and still performs a dereference on + * the first, and for uses of lstat in libalpm this is not what we want. + * @param path path to file to lstat + * @param buf structure to fill with stat information + * @return the return code from lstat + */ +int llstat(const char *path, struct stat *buf) +{ + int ret; + size_t len = strlen(path); + + /* strip the trailing slash if one exists */ + if(len != 0 && path[len - 1] == '/') { + char *newpath = strdup(path); + newpath[len - 1] = '\0'; + ret = lstat(newpath, buf); + free(newpath); + } else { + ret = lstat(path, buf); + } + + return ret; +} + #ifndef HAVE_STRNDUP /* A quick and dirty implementation derived from glibc */ /** Determines the length of a fixed-size string. diff --git a/src/common/util-common.h b/src/common/util-common.h index e28c60d9..5f04b00c 100644 --- a/src/common/util-common.h +++ b/src/common/util-common.h @@ -20,9 +20,13 @@ #ifndef _PM_UTIL_COMMON_H #define _PM_UTIL_COMMON_H +#include <sys/stat.h> /* struct stat */ + const char *mbasename(const char *path); char *mdirname(const char *path); +int llstat(const char *path, struct stat *buf); + #ifndef HAVE_STRNDUP char *strndup(const char *s, size_t n); #endif |