summaryrefslogtreecommitdiffstats
path: root/lib/libalpm/add.c
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2008-06-02 04:47:31 +0200
committerDan McGee <dan@archlinux.org>2008-06-04 22:38:47 +0200
commit0669c9bfac7aead01f1400444e691d542f7645c2 (patch)
treef5dc76963236bd50126d7b4e570969c14e066a03 /lib/libalpm/add.c
parent62b4195c7680f9d404e175eb0869182efdd09ef2 (diff)
downloadpacman-0669c9bfac7aead01f1400444e691d542f7645c2.tar.gz
pacman-0669c9bfac7aead01f1400444e691d542f7645c2.tar.xz
Use correct C type for file sizes
We have been using unsigned long as a file size type for a while, which works but isn't quite correct and could easily break. Worse was probably our use of int in the download callback functions, which could be restrictive for packages > 2GB in size. Switch all file size variables to use off_t, which is the preferred type for file sizes. Note that at least on Linux, all applications compiled against libalpm must now be sure to use large file support, where _FILE_OFFSET_BITS is defined to be 64 or there will be some weird issues that crop up. Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'lib/libalpm/add.c')
-rw-r--r--lib/libalpm/add.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/lib/libalpm/add.c b/lib/libalpm/add.c
index c5454bab..03698622 100644
--- a/lib/libalpm/add.c
+++ b/lib/libalpm/add.c
@@ -27,6 +27,8 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
+#include <inttypes.h> /* int64_t */
+#include <stdint.h> /* intmax_t */
/* libarchive */
#include <archive.h>
@@ -635,7 +637,6 @@ static int commit_single_pkg(pmpkg_t *newpkg, int pkg_current, int pkg_count,
int i, ret = 0, errors = 0;
char scriptlet[PATH_MAX+1];
int is_upgrade = 0;
- double percent = 0.0;
pmpkg_t *oldpkg = NULL;
ALPM_LOG_FUNC;
@@ -730,17 +731,22 @@ static int commit_single_pkg(pmpkg_t *newpkg, int pkg_current, int pkg_count,
}
for(i = 0; archive_read_next_header(archive, &entry) == ARCHIVE_OK; i++) {
+ double percent;
+
if(newpkg->size != 0) {
/* Using compressed size for calculations here, as newpkg->isize is not
* exact when it comes to comparing to the ACTUAL uncompressed size
* (missing metadata sizes) */
- unsigned long pos = archive_position_compressed(archive);
+ int64_t pos = archive_position_compressed(archive);
percent = (double)pos / (double)newpkg->size;
- _alpm_log(PM_LOG_DEBUG, "decompression progress: %f%% (%ld / %ld)\n",
- percent*100.0, pos, newpkg->size);
+ _alpm_log(PM_LOG_DEBUG, "decompression progress: "
+ "%f%% (%"PRId64" / %jd)\n",
+ percent*100.0, pos, (intmax_t)newpkg->size);
if(percent >= 1.0) {
percent = 1.0;
}
+ } else {
+ percent = 0.0;
}
if(is_upgrade) {