summaryrefslogtreecommitdiffstats
path: root/lib/libalpm/sync.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/sync.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/sync.c')
-rw-r--r--lib/libalpm/sync.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c
index 0d6a6ee3..2dad8bf7 100644
--- a/lib/libalpm/sync.c
+++ b/lib/libalpm/sync.c
@@ -22,6 +22,7 @@
#include "config.h"
+#include <sys/types.h> /* off_t */
#include <stdlib.h>
#include <stdio.h>
#include <fcntl.h>
@@ -385,7 +386,7 @@ static int compute_download_size(pmpkg_t *newpkg)
{
const char *fname;
char *fpath;
- unsigned long size = 0;
+ off_t size = 0;
fname = alpm_pkg_get_filename(newpkg);
ASSERT(fname != NULL, RET_ERR(PM_ERR_PKG_INVALID_NAME, -1));
@@ -395,8 +396,8 @@ static int compute_download_size(pmpkg_t *newpkg)
FREE(fpath);
size = 0;
} else if(handle->usedelta) {
- unsigned long dltsize;
- unsigned long pkgsize = alpm_pkg_get_size(newpkg);
+ off_t dltsize;
+ off_t pkgsize = alpm_pkg_get_size(newpkg);
dltsize = _alpm_shortest_delta_path(
alpm_pkg_get_deltas(newpkg),
@@ -417,8 +418,8 @@ static int compute_download_size(pmpkg_t *newpkg)
size = alpm_pkg_get_size(newpkg);
}
- _alpm_log(PM_LOG_DEBUG, "setting download size %ld for pkg %s\n", size,
- alpm_pkg_get_name(newpkg));
+ _alpm_log(PM_LOG_DEBUG, "setting download size %lld for pkg %s\n",
+ (long long)size, alpm_pkg_get_name(newpkg));
newpkg->download_size = size;
return(0);
@@ -670,7 +671,7 @@ cleanup:
* @param newpkg the new package to upgrade to
* @return the size of the download
*/
-unsigned long SYMEXPORT alpm_pkg_download_size(pmpkg_t *newpkg)
+off_t SYMEXPORT alpm_pkg_download_size(pmpkg_t *newpkg)
{
return(newpkg->download_size);
}