summaryrefslogtreecommitdiffstats
path: root/src
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 /src
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 'src')
-rw-r--r--src/pacman/callback.c9
-rw-r--r--src/pacman/callback.h4
-rw-r--r--src/pacman/util.c2
3 files changed, 9 insertions, 6 deletions
diff --git a/src/pacman/callback.c b/src/pacman/callback.c
index 4c415e1a..1942aefd 100644
--- a/src/pacman/callback.c
+++ b/src/pacman/callback.c
@@ -23,6 +23,7 @@
#include <stdlib.h>
#include <string.h>
#include <sys/time.h>
+#include <sys/types.h> /* off_t */
#include <unistd.h>
#include <dirent.h>
#include <wchar.h>
@@ -36,7 +37,7 @@
/* download progress bar */
static float rate_last;
-static int xfered_last;
+static off_t xfered_last;
static struct timeval initial_time;
/* transaction progress bar */
@@ -410,7 +411,7 @@ void cb_trans_progress(pmtransprog_t event, const char *pkgname, int percent,
}
/* callback to handle display of download progress */
-void cb_dl_progress(const char *filename, int xfered, int total)
+void cb_dl_progress(const char *filename, off_t xfered, off_t total)
{
const int infolen = 50;
const int filenamelen = infolen - 27;
@@ -428,12 +429,12 @@ void cb_dl_progress(const char *filename, int xfered, int total)
return;
}
- /* this is basically a switch on file_xferred: 0, file_total, and
+ /* this is basically a switch on xfered: 0, total, and
* anything else */
if(xfered == 0) {
/* set default starting values */
gettimeofday(&initial_time, NULL);
- xfered_last = 0;
+ xfered_last = (off_t)0;
rate_last = 0.0;
timediff = get_update_timediff(1);
} else if(xfered == total) {
diff --git a/src/pacman/callback.h b/src/pacman/callback.h
index 39d59d8b..28d396e8 100644
--- a/src/pacman/callback.h
+++ b/src/pacman/callback.h
@@ -19,6 +19,8 @@
#ifndef _PM_CALLBACK_H
#define _PM_CALLBACK_H
+#include <sys/types.h> /* off_t */
+
#include <alpm.h>
/* callback to handle messages/notifications from libalpm transactions */
@@ -33,7 +35,7 @@ void cb_trans_progress(pmtransprog_t event, const char *pkgname, int percent,
int howmany, int remain);
/* callback to handle display of download progress */
-void cb_dl_progress(const char *filename, int file_xfered, int file_total);
+void cb_dl_progress(const char *filename, off_t file_xfered, off_t file_total);
/* callback to handle messages/notifications from pacman library */
void cb_log(pmloglevel_t level, char *fmt, va_list args);
diff --git a/src/pacman/util.c b/src/pacman/util.c
index 2e4ee86e..e702886b 100644
--- a/src/pacman/util.c
+++ b/src/pacman/util.c
@@ -493,7 +493,7 @@ void display_targets(const alpm_list_t *syncpkgs, pmdb_t *db_local)
const alpm_list_t *i, *j;
alpm_list_t *targets = NULL, *to_remove = NULL;
/* TODO these are some messy variable names */
- unsigned long isize = 0, rsize = 0, dispsize = 0, dlsize = 0;
+ off_t isize = 0, rsize = 0, dispsize = 0, dlsize = 0;
double mbisize = 0.0, mbrsize = 0.0, mbdispsize = 0.0, mbdlsize = 0.0;
for(i = syncpkgs; i; i = alpm_list_next(i)) {