summaryrefslogtreecommitdiffstats
path: root/lib/libalpm/be_files.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/be_files.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/be_files.c')
-rw-r--r--lib/libalpm/be_files.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/libalpm/be_files.c b/lib/libalpm/be_files.c
index 2302374d..dc644cea 100644
--- a/lib/libalpm/be_files.c
+++ b/lib/libalpm/be_files.c
@@ -25,7 +25,7 @@
#include <stdlib.h>
#include <errno.h>
#include <string.h>
-#include <stdint.h> /* uintmax_t */
+#include <stdint.h> /* uintmax_t, intmax_t */
#include <sys/stat.h>
#include <dirent.h>
#include <ctype.h>
@@ -710,10 +710,10 @@ int _alpm_db_write(pmdb_t *db, pmpkg_t *info, pmdbinfrq_t inforeq)
fprintf(fp, "%%PACKAGER%%\n"
"%s\n\n", info->packager);
}
- if(info->size) {
+ if(info->isize) {
/* only write installed size, csize is irrelevant once installed */
fprintf(fp, "%%SIZE%%\n"
- "%lu\n\n", info->isize);
+ "%ju\n\n", (intmax_t)info->isize);
}
if(info->reason) {
fprintf(fp, "%%REASON%%\n"
@@ -722,11 +722,11 @@ int _alpm_db_write(pmdb_t *db, pmpkg_t *info, pmdbinfrq_t inforeq)
} else {
if(info->size) {
fprintf(fp, "%%CSIZE%%\n"
- "%lu\n\n", info->size);
+ "%ju\n\n", (intmax_t)info->size);
}
if(info->isize) {
fprintf(fp, "%%ISIZE%%\n"
- "%lu\n\n", info->isize);
+ "%ju\n\n", (intmax_t)info->isize);
}
if(info->md5sum) {
fprintf(fp, "%%MD5SUM%%\n"