diff options
author | Dan McGee <dan@archlinux.org> | 2008-06-01 21:47:31 -0500 |
---|---|---|
committer | Dan McGee <dan@archlinux.org> | 2008-06-04 15:38:47 -0500 |
commit | 0669c9bfac7aead01f1400444e691d542f7645c2 (patch) | |
tree | f5dc76963236bd50126d7b4e570969c14e066a03 | |
parent | 62b4195c7680f9d404e175eb0869182efdd09ef2 (diff) | |
download | pacman-0669c9bfac7aead01f1400444e691d542f7645c2.tar.gz pacman-0669c9bfac7aead01f1400444e691d542f7645c2.zip |
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>
-rw-r--r-- | lib/libalpm/add.c | 14 | ||||
-rw-r--r-- | lib/libalpm/alpm.h | 14 | ||||
-rw-r--r-- | lib/libalpm/be_files.c | 10 | ||||
-rw-r--r-- | lib/libalpm/db.c | 1 | ||||
-rw-r--r-- | lib/libalpm/delta.c | 16 | ||||
-rw-r--r-- | lib/libalpm/delta.h | 8 | ||||
-rw-r--r-- | lib/libalpm/dload.c | 6 | ||||
-rw-r--r-- | lib/libalpm/graph.h | 4 | ||||
-rw-r--r-- | lib/libalpm/package.c | 4 | ||||
-rw-r--r-- | lib/libalpm/package.h | 11 | ||||
-rw-r--r-- | lib/libalpm/sync.c | 13 | ||||
-rw-r--r-- | src/pacman/callback.c | 9 | ||||
-rw-r--r-- | src/pacman/callback.h | 4 | ||||
-rw-r--r-- | src/pacman/util.c | 2 |
14 files changed, 66 insertions, 50 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 @@ | |||
27 | #include <sys/types.h> | 27 | #include <sys/types.h> |
28 | #include <sys/stat.h> | 28 | #include <sys/stat.h> |
29 | #include <unistd.h> | 29 | #include <unistd.h> |
30 | #include <inttypes.h> /* int64_t */ | ||
31 | #include <stdint.h> /* intmax_t */ | ||
30 | 32 | ||
31 | /* libarchive */ | 33 | /* libarchive */ |
32 | #include <archive.h> | 34 | #include <archive.h> |
@@ -635,7 +637,6 @@ static int commit_single_pkg(pmpkg_t *newpkg, int pkg_current, int pkg_count, | |||
635 | int i, ret = 0, errors = 0; | 637 | int i, ret = 0, errors = 0; |
636 | char scriptlet[PATH_MAX+1]; | 638 | char scriptlet[PATH_MAX+1]; |
637 | int is_upgrade = 0; | 639 | int is_upgrade = 0; |
638 | double percent = 0.0; | ||
639 | pmpkg_t *oldpkg = NULL; | 640 | pmpkg_t *oldpkg = NULL; |
640 | 641 | ||
641 | ALPM_LOG_FUNC; | 642 | ALPM_LOG_FUNC; |
@@ -730,17 +731,22 @@ static int commit_single_pkg(pmpkg_t *newpkg, int pkg_current, int pkg_count, | |||
730 | } | 731 | } |
731 | 732 | ||
732 | for(i = 0; archive_read_next_header(archive, &entry) == ARCHIVE_OK; i++) { | 733 | for(i = 0; archive_read_next_header(archive, &entry) == ARCHIVE_OK; i++) { |
734 | double percent; | ||
735 | |||
733 | if(newpkg->size != 0) { | 736 | if(newpkg->size != 0) { |
734 | /* Using compressed size for calculations here, as newpkg->isize is not | 737 | /* Using compressed size for calculations here, as newpkg->isize is not |
735 | * exact when it comes to comparing to the ACTUAL uncompressed size | 738 | * exact when it comes to comparing to the ACTUAL uncompressed size |
736 | * (missing metadata sizes) */ | 739 | * (missing metadata sizes) */ |
737 | unsigned long pos = archive_position_compressed(archive); | 740 | int64_t pos = archive_position_compressed(archive); |
738 | percent = (double)pos / (double)newpkg->size; | 741 | percent = (double)pos / (double)newpkg->size; |
739 | _alpm_log(PM_LOG_DEBUG, "decompression progress: %f%% (%ld / %ld)\n", | 742 | _alpm_log(PM_LOG_DEBUG, "decompression progress: " |
740 | percent*100.0, pos, newpkg->size); | 743 | "%f%% (%"PRId64" / %jd)\n", |
744 | percent*100.0, pos, (intmax_t)newpkg->size); | ||
741 | if(percent >= 1.0) { | 745 | if(percent >= 1.0) { |
742 | percent = 1.0; | 746 | percent = 1.0; |
743 | } | 747 | } |
748 | } else { | ||
749 | percent = 0.0; | ||
744 | } | 750 | } |
745 | 751 | ||
746 | if(is_upgrade) { | 752 | if(is_upgrade) { |
diff --git a/lib/libalpm/alpm.h b/lib/libalpm/alpm.h index 62a517b4..fd3be0d3 100644 --- a/lib/libalpm/alpm.h +++ b/lib/libalpm/alpm.h | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * alpm.h | 2 | * alpm.h |
3 | * | 3 | * |
4 | * Copyright (c) 2002-2007 by Judd Vinet <jvinet@zeroflux.org> | 4 | * Copyright (c) 2002-2008 by Judd Vinet <jvinet@zeroflux.org> |
5 | * Copyright (c) 2005 by Aurelien Foret <orelien@chez.com> | 5 | * Copyright (c) 2005 by Aurelien Foret <orelien@chez.com> |
6 | * Copyright (c) 2005 by Christian Hamar <krics@linuxforum.hu> | 6 | * Copyright (c) 2005 by Christian Hamar <krics@linuxforum.hu> |
7 | * Copyright (c) 2005, 2006 by Miklos Vajna <vmiklos@frugalware.org> | 7 | * Copyright (c) 2005, 2006 by Miklos Vajna <vmiklos@frugalware.org> |
@@ -26,6 +26,7 @@ | |||
26 | extern "C" { | 26 | extern "C" { |
27 | #endif | 27 | #endif |
28 | 28 | ||
29 | #include <sys/types.h> /* for off_t */ | ||
29 | #include <time.h> /* for time_t */ | 30 | #include <time.h> /* for time_t */ |
30 | #include <stdarg.h> /* for va_list */ | 31 | #include <stdarg.h> /* for va_list */ |
31 | 32 | ||
@@ -79,7 +80,8 @@ int alpm_logaction(char *fmt, ...); | |||
79 | * Downloading | 80 | * Downloading |
80 | */ | 81 | */ |
81 | 82 | ||
82 | typedef void (*alpm_cb_download)(const char *filename, int xfered, int total); | 83 | typedef void (*alpm_cb_download)(const char *filename, |
84 | off_t xfered, off_t total); | ||
83 | 85 | ||
84 | /* | 86 | /* |
85 | * Options | 87 | * Options |
@@ -201,8 +203,8 @@ time_t alpm_pkg_get_installdate(pmpkg_t *pkg); | |||
201 | const char *alpm_pkg_get_packager(pmpkg_t *pkg); | 203 | const char *alpm_pkg_get_packager(pmpkg_t *pkg); |
202 | const char *alpm_pkg_get_md5sum(pmpkg_t *pkg); | 204 | const char *alpm_pkg_get_md5sum(pmpkg_t *pkg); |
203 | const char *alpm_pkg_get_arch(pmpkg_t *pkg); | 205 | const char *alpm_pkg_get_arch(pmpkg_t *pkg); |
204 | unsigned long alpm_pkg_get_size(pmpkg_t *pkg); | 206 | off_t alpm_pkg_get_size(pmpkg_t *pkg); |
205 | unsigned long alpm_pkg_get_isize(pmpkg_t *pkg); | 207 | off_t alpm_pkg_get_isize(pmpkg_t *pkg); |
206 | pmpkgreason_t alpm_pkg_get_reason(pmpkg_t *pkg); | 208 | pmpkgreason_t alpm_pkg_get_reason(pmpkg_t *pkg); |
207 | alpm_list_t *alpm_pkg_get_licenses(pmpkg_t *pkg); | 209 | alpm_list_t *alpm_pkg_get_licenses(pmpkg_t *pkg); |
208 | alpm_list_t *alpm_pkg_get_groups(pmpkg_t *pkg); | 210 | alpm_list_t *alpm_pkg_get_groups(pmpkg_t *pkg); |
@@ -221,7 +223,7 @@ size_t alpm_pkg_changelog_read(void *ptr, size_t size, | |||
221 | int alpm_pkg_changelog_close(const pmpkg_t *pkg, void *fp); | 223 | int alpm_pkg_changelog_close(const pmpkg_t *pkg, void *fp); |
222 | unsigned short alpm_pkg_has_scriptlet(pmpkg_t *pkg); | 224 | unsigned short alpm_pkg_has_scriptlet(pmpkg_t *pkg); |
223 | 225 | ||
224 | unsigned long alpm_pkg_download_size(pmpkg_t *newpkg); | 226 | off_t alpm_pkg_download_size(pmpkg_t *newpkg); |
225 | 227 | ||
226 | /* | 228 | /* |
227 | * Deltas | 229 | * Deltas |
@@ -233,7 +235,7 @@ const char *alpm_delta_get_to(pmdelta_t *delta); | |||
233 | const char *alpm_delta_get_to_md5sum(pmdelta_t *delta); | 235 | const char *alpm_delta_get_to_md5sum(pmdelta_t *delta); |
234 | const char *alpm_delta_get_filename(pmdelta_t *delta); | 236 | const char *alpm_delta_get_filename(pmdelta_t *delta); |
235 | const char *alpm_delta_get_md5sum(pmdelta_t *delta); | 237 | const char *alpm_delta_get_md5sum(pmdelta_t *delta); |
236 | unsigned long alpm_delta_get_size(pmdelta_t *delta); | 238 | off_t alpm_delta_get_size(pmdelta_t *delta); |
237 | 239 | ||
238 | /* | 240 | /* |
239 | * Groups | 241 | * Groups |
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 @@ | |||
25 | #include <stdlib.h> | 25 | #include <stdlib.h> |
26 | #include <errno.h> | 26 | #include <errno.h> |
27 | #include <string.h> | 27 | #include <string.h> |
28 | #include <stdint.h> /* uintmax_t */ | 28 | #include <stdint.h> /* uintmax_t, intmax_t */ |
29 | #include <sys/stat.h> | 29 | #include <sys/stat.h> |
30 | #include <dirent.h> | 30 | #include <dirent.h> |
31 | #include <ctype.h> | 31 | #include <ctype.h> |
@@ -710,10 +710,10 @@ int _alpm_db_write(pmdb_t *db, pmpkg_t *info, pmdbinfrq_t inforeq) | |||
710 | fprintf(fp, "%%PACKAGER%%\n" | 710 | fprintf(fp, "%%PACKAGER%%\n" |
711 | "%s\n\n", info->packager); | 711 | "%s\n\n", info->packager); |
712 | } | 712 | } |
713 | if(info->size) { | 713 | if(info->isize) { |
714 | /* only write installed size, csize is irrelevant once installed */ | 714 | /* only write installed size, csize is irrelevant once installed */ |
715 | fprintf(fp, "%%SIZE%%\n" | 715 | fprintf(fp, "%%SIZE%%\n" |
716 | "%lu\n\n", info->isize); | 716 | "%ju\n\n", (intmax_t)info->isize); |
717 | } | 717 | } |
718 | if(info->reason) { | 718 | if(info->reason) { |
719 | fprintf(fp, "%%REASON%%\n" | 719 | fprintf(fp, "%%REASON%%\n" |
@@ -722,11 +722,11 @@ int _alpm_db_write(pmdb_t *db, pmpkg_t *info, pmdbinfrq_t inforeq) | |||
722 | } else { | 722 | } else { |
723 | if(info->size) { | 723 | if(info->size) { |
724 | fprintf(fp, "%%CSIZE%%\n" | 724 | fprintf(fp, "%%CSIZE%%\n" |
725 | "%lu\n\n", info->size); | 725 | "%ju\n\n", (intmax_t)info->size); |
726 | } | 726 | } |
727 | if(info->isize) { | 727 | if(info->isize) { |
728 | fprintf(fp, "%%ISIZE%%\n" | 728 | fprintf(fp, "%%ISIZE%%\n" |
729 | "%lu\n\n", info->isize); | 729 | "%ju\n\n", (intmax_t)info->isize); |
730 | } | 730 | } |
731 | if(info->md5sum) { | 731 | if(info->md5sum) { |
732 | fprintf(fp, "%%MD5SUM%%\n" | 732 | fprintf(fp, "%%MD5SUM%%\n" |
diff --git a/lib/libalpm/db.c b/lib/libalpm/db.c index df16c3c9..0be81cb1 100644 --- a/lib/libalpm/db.c +++ b/lib/libalpm/db.c | |||
@@ -28,7 +28,6 @@ | |||
28 | #include <stdlib.h> | 28 | #include <stdlib.h> |
29 | #include <errno.h> | 29 | #include <errno.h> |
30 | #include <string.h> | 30 | #include <string.h> |
31 | #include <stdint.h> /* uintmax_t */ | ||
32 | #include <sys/stat.h> | 31 | #include <sys/stat.h> |
33 | #include <dirent.h> | 32 | #include <dirent.h> |
34 | #include <regex.h> | 33 | #include <regex.h> |
diff --git a/lib/libalpm/delta.c b/lib/libalpm/delta.c index fdb4d99b..22d9beb4 100644 --- a/lib/libalpm/delta.c +++ b/lib/libalpm/delta.c | |||
@@ -71,7 +71,7 @@ const char SYMEXPORT *alpm_delta_get_md5sum(pmdelta_t *delta) | |||
71 | return(delta->delta_md5); | 71 | return(delta->delta_md5); |
72 | } | 72 | } |
73 | 73 | ||
74 | unsigned long SYMEXPORT alpm_delta_get_size(pmdelta_t *delta) | 74 | off_t SYMEXPORT alpm_delta_get_size(pmdelta_t *delta) |
75 | { | 75 | { |
76 | ASSERT(delta != NULL, return(-1)); | 76 | ASSERT(delta != NULL, return(-1)); |
77 | return(delta->delta_size); | 77 | return(delta->delta_size); |
@@ -89,7 +89,7 @@ static alpm_list_t *delta_graph_init(alpm_list_t *deltas) | |||
89 | pmgraph_t *v = _alpm_graph_new(); | 89 | pmgraph_t *v = _alpm_graph_new(); |
90 | pmdelta_t *vdelta = i->data; | 90 | pmdelta_t *vdelta = i->data; |
91 | vdelta->download_size = vdelta->delta_size; | 91 | vdelta->download_size = vdelta->delta_size; |
92 | v->weight = ULONG_MAX; | 92 | v->weight = LONG_MAX; |
93 | 93 | ||
94 | /* determine whether the delta file already exists */ | 94 | /* determine whether the delta file already exists */ |
95 | fpath = _alpm_filecache_find(vdelta->delta); | 95 | fpath = _alpm_filecache_find(vdelta->delta); |
@@ -139,7 +139,7 @@ static alpm_list_t *delta_graph_init(alpm_list_t *deltas) | |||
139 | return(vertices); | 139 | return(vertices); |
140 | } | 140 | } |
141 | 141 | ||
142 | static unsigned long delta_vert(alpm_list_t *vertices, | 142 | static off_t delta_vert(alpm_list_t *vertices, |
143 | const char *to, const char *to_md5, alpm_list_t **path) { | 143 | const char *to, const char *to_md5, alpm_list_t **path) { |
144 | alpm_list_t *i; | 144 | alpm_list_t *i; |
145 | pmgraph_t *v; | 145 | pmgraph_t *v; |
@@ -157,7 +157,7 @@ static unsigned long delta_vert(alpm_list_t *vertices, | |||
157 | v = v_i; | 157 | v = v_i; |
158 | } | 158 | } |
159 | } | 159 | } |
160 | if(v == NULL || v->weight == ULONG_MAX) { | 160 | if(v == NULL || v->weight == LONG_MAX) { |
161 | break; | 161 | break; |
162 | } | 162 | } |
163 | 163 | ||
@@ -178,7 +178,7 @@ static unsigned long delta_vert(alpm_list_t *vertices, | |||
178 | } | 178 | } |
179 | 179 | ||
180 | v = NULL; | 180 | v = NULL; |
181 | unsigned long bestsize = 0; | 181 | off_t bestsize = 0; |
182 | 182 | ||
183 | for(i = vertices; i; i = i->next) { | 183 | for(i = vertices; i; i = i->next) { |
184 | pmgraph_t *v_i = i->data; | 184 | pmgraph_t *v_i = i->data; |
@@ -214,14 +214,14 @@ static unsigned long delta_vert(alpm_list_t *vertices, | |||
214 | * @param path the pointer to a list location where pmdelta_t * objects that | 214 | * @param path the pointer to a list location where pmdelta_t * objects that |
215 | * have the smallest size are placed. NULL is set if there is no path | 215 | * have the smallest size are placed. NULL is set if there is no path |
216 | * possible with the files available. | 216 | * possible with the files available. |
217 | * @return the size of the path stored, or ULONG_MAX if path is unfindable | 217 | * @return the size of the path stored, or LONG_MAX if path is unfindable |
218 | */ | 218 | */ |
219 | unsigned long _alpm_shortest_delta_path(alpm_list_t *deltas, | 219 | off_t _alpm_shortest_delta_path(alpm_list_t *deltas, |
220 | const char *to, const char *to_md5, alpm_list_t **path) | 220 | const char *to, const char *to_md5, alpm_list_t **path) |
221 | { | 221 | { |
222 | alpm_list_t *bestpath = NULL; | 222 | alpm_list_t *bestpath = NULL; |
223 | alpm_list_t *vertices; | 223 | alpm_list_t *vertices; |
224 | unsigned long bestsize = ULONG_MAX; | 224 | off_t bestsize = LONG_MAX; |
225 | 225 | ||
226 | ALPM_LOG_FUNC; | 226 | ALPM_LOG_FUNC; |
227 | 227 | ||
diff --git a/lib/libalpm/delta.h b/lib/libalpm/delta.h index 33d47e1e..5bb86b94 100644 --- a/lib/libalpm/delta.h +++ b/lib/libalpm/delta.h | |||
@@ -19,6 +19,8 @@ | |||
19 | #ifndef _ALPM_DELTA_H | 19 | #ifndef _ALPM_DELTA_H |
20 | #define _ALPM_DELTA_H | 20 | #define _ALPM_DELTA_H |
21 | 21 | ||
22 | #include <sys/types.h> /* off_t */ | ||
23 | |||
22 | #include "alpm.h" | 24 | #include "alpm.h" |
23 | 25 | ||
24 | struct __pmdelta_t { | 26 | struct __pmdelta_t { |
@@ -35,14 +37,14 @@ struct __pmdelta_t { | |||
35 | /** md5sum of the delta file */ | 37 | /** md5sum of the delta file */ |
36 | char *delta_md5; | 38 | char *delta_md5; |
37 | /** filesize of the delta file */ | 39 | /** filesize of the delta file */ |
38 | unsigned long delta_size; | 40 | off_t delta_size; |
39 | /** download filesize of the delta file */ | 41 | /** download filesize of the delta file */ |
40 | unsigned long download_size; | 42 | off_t download_size; |
41 | }; | 43 | }; |
42 | 44 | ||
43 | pmdelta_t *_alpm_delta_parse(char *line); | 45 | pmdelta_t *_alpm_delta_parse(char *line); |
44 | void _alpm_delta_free(pmdelta_t *delta); | 46 | void _alpm_delta_free(pmdelta_t *delta); |
45 | unsigned long _alpm_shortest_delta_path(alpm_list_t *deltas, | 47 | off_t _alpm_shortest_delta_path(alpm_list_t *deltas, |
46 | const char *to, const char *to_md5, alpm_list_t **path); | 48 | const char *to, const char *to_md5, alpm_list_t **path); |
47 | 49 | ||
48 | #endif /* _ALPM_DELTA_H */ | 50 | #endif /* _ALPM_DELTA_H */ |
diff --git a/lib/libalpm/dload.c b/lib/libalpm/dload.c index 44acec70..b5f0b876 100644 --- a/lib/libalpm/dload.c +++ b/lib/libalpm/dload.c | |||
@@ -112,7 +112,7 @@ static int download_internal(const char *url, const char *localpath, | |||
112 | struct url_stat ust; | 112 | struct url_stat ust; |
113 | struct stat st; | 113 | struct stat st; |
114 | int chk_resume = 0; | 114 | int chk_resume = 0; |
115 | int dl_thisfile = 0; | 115 | size_t dl_thisfile = 0; |
116 | char *tempfile, *destfile, *filename; | 116 | char *tempfile, *destfile, *filename; |
117 | int ret = 0; | 117 | int ret = 0; |
118 | struct url *fileurl = url_for_string(url); | 118 | struct url *fileurl = url_for_string(url); |
@@ -200,7 +200,7 @@ static int download_internal(const char *url, const char *localpath, | |||
200 | handle->dlcb(filename, 0, ust.size); | 200 | handle->dlcb(filename, 0, ust.size); |
201 | } | 201 | } |
202 | 202 | ||
203 | int nread = 0; | 203 | size_t nread = 0; |
204 | char buffer[PM_DLBUF_LEN]; | 204 | char buffer[PM_DLBUF_LEN]; |
205 | while((nread = fread(buffer, 1, PM_DLBUF_LEN, dlf)) > 0) { | 205 | while((nread = fread(buffer, 1, PM_DLBUF_LEN, dlf)) > 0) { |
206 | if(ferror(dlf)) { | 206 | if(ferror(dlf)) { |
@@ -211,7 +211,7 @@ static int download_internal(const char *url, const char *localpath, | |||
211 | goto cleanup; | 211 | goto cleanup; |
212 | } | 212 | } |
213 | 213 | ||
214 | int nwritten = 0; | 214 | size_t nwritten = 0; |
215 | while(nwritten < nread) { | 215 | while(nwritten < nread) { |
216 | nwritten += fwrite(buffer, 1, (nread - nwritten), localf); | 216 | nwritten += fwrite(buffer, 1, (nread - nwritten), localf); |
217 | if(ferror(localf)) { | 217 | if(ferror(localf)) { |
diff --git a/lib/libalpm/graph.h b/lib/libalpm/graph.h index 3078e25f..72a7136f 100644 --- a/lib/libalpm/graph.h +++ b/lib/libalpm/graph.h | |||
@@ -17,6 +17,8 @@ | |||
17 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 17 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
18 | */ | 18 | */ |
19 | 19 | ||
20 | #include <sys/types.h> /* off_t */ | ||
21 | |||
20 | #include "alpm_list.h" | 22 | #include "alpm_list.h" |
21 | #include "util.h" /* MALLOC() */ | 23 | #include "util.h" /* MALLOC() */ |
22 | #include "alpm.h" | 24 | #include "alpm.h" |
@@ -24,7 +26,7 @@ | |||
24 | struct __pmgraph_t { | 26 | struct __pmgraph_t { |
25 | char state; /* 0: untouched, -1: entered, other: leaving time */ | 27 | char state; /* 0: untouched, -1: entered, other: leaving time */ |
26 | void *data; | 28 | void *data; |
27 | unsigned long int weight; /* weight of the node */ | 29 | off_t weight; /* weight of the node */ |
28 | struct __pmgraph_t *parent; /* where did we come from? */ | 30 | struct __pmgraph_t *parent; /* where did we come from? */ |
29 | alpm_list_t *children; | 31 | alpm_list_t *children; |
30 | alpm_list_t *childptr; /* points to a child in children list */ | 32 | alpm_list_t *childptr; /* points to a child in children list */ |
diff --git a/lib/libalpm/package.c b/lib/libalpm/package.c index 685a411f..3708a58a 100644 --- a/lib/libalpm/package.c +++ b/lib/libalpm/package.c | |||
@@ -225,7 +225,7 @@ const char SYMEXPORT *alpm_pkg_get_arch(pmpkg_t *pkg) | |||
225 | return pkg->arch; | 225 | return pkg->arch; |
226 | } | 226 | } |
227 | 227 | ||
228 | unsigned long SYMEXPORT alpm_pkg_get_size(pmpkg_t *pkg) | 228 | off_t SYMEXPORT alpm_pkg_get_size(pmpkg_t *pkg) |
229 | { | 229 | { |
230 | ALPM_LOG_FUNC; | 230 | ALPM_LOG_FUNC; |
231 | 231 | ||
@@ -239,7 +239,7 @@ unsigned long SYMEXPORT alpm_pkg_get_size(pmpkg_t *pkg) | |||
239 | return pkg->size; | 239 | return pkg->size; |
240 | } | 240 | } |
241 | 241 | ||
242 | unsigned long SYMEXPORT alpm_pkg_get_isize(pmpkg_t *pkg) | 242 | off_t SYMEXPORT alpm_pkg_get_isize(pmpkg_t *pkg) |
243 | { | 243 | { |
244 | ALPM_LOG_FUNC; | 244 | ALPM_LOG_FUNC; |
245 | 245 | ||
diff --git a/lib/libalpm/package.h b/lib/libalpm/package.h index ddf1d073..d06cf150 100644 --- a/lib/libalpm/package.h +++ b/lib/libalpm/package.h | |||
@@ -23,7 +23,8 @@ | |||
23 | #ifndef _ALPM_PACKAGE_H | 23 | #ifndef _ALPM_PACKAGE_H |
24 | #define _ALPM_PACKAGE_H | 24 | #define _ALPM_PACKAGE_H |
25 | 25 | ||
26 | #include <time.h> | 26 | #include <sys/types.h> /* off_t */ |
27 | #include <time.h> /* time_t */ | ||
27 | 28 | ||
28 | #include "alpm.h" | 29 | #include "alpm.h" |
29 | #include "db.h" | 30 | #include "db.h" |
@@ -44,8 +45,9 @@ struct __pmpkg_t { | |||
44 | char *packager; | 45 | char *packager; |
45 | char *md5sum; | 46 | char *md5sum; |
46 | char *arch; | 47 | char *arch; |
47 | unsigned long size; | 48 | off_t size; |
48 | unsigned long isize; | 49 | off_t isize; |
50 | off_t download_size; | ||
49 | unsigned short scriptlet; | 51 | unsigned short scriptlet; |
50 | unsigned short force; | 52 | unsigned short force; |
51 | pmpkgreason_t reason; | 53 | pmpkgreason_t reason; |
@@ -59,6 +61,7 @@ struct __pmpkg_t { | |||
59 | alpm_list_t *conflicts; | 61 | alpm_list_t *conflicts; |
60 | alpm_list_t *provides; | 62 | alpm_list_t *provides; |
61 | alpm_list_t *deltas; | 63 | alpm_list_t *deltas; |
64 | alpm_list_t *delta_path; | ||
62 | /* internal */ | 65 | /* internal */ |
63 | pmpkgfrom_t origin; | 66 | pmpkgfrom_t origin; |
64 | /* Replaced 'void *data' with this union as follows: | 67 | /* Replaced 'void *data' with this union as follows: |
@@ -70,8 +73,6 @@ struct __pmpkg_t { | |||
70 | char *file; | 73 | char *file; |
71 | } origin_data; | 74 | } origin_data; |
72 | pmdbinfrq_t infolevel; | 75 | pmdbinfrq_t infolevel; |
73 | unsigned long download_size; | ||
74 | alpm_list_t *delta_path; | ||
75 | }; | 76 | }; |
76 | 77 | ||
77 | pmpkg_t* _alpm_pkg_new(void); | 78 | pmpkg_t* _alpm_pkg_new(void); |
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 @@ | |||
22 | 22 | ||
23 | #include "config.h" | 23 | #include "config.h" |
24 | 24 | ||
25 | #include <sys/types.h> /* off_t */ | ||
25 | #include <stdlib.h> | 26 | #include <stdlib.h> |
26 | #include <stdio.h> | 27 | #include <stdio.h> |
27 | #include <fcntl.h> | 28 | #include <fcntl.h> |
@@ -385,7 +386,7 @@ static int compute_download_size(pmpkg_t *newpkg) | |||
385 | { | 386 | { |
386 | const char *fname; | 387 | const char *fname; |
387 | char *fpath; | 388 | char *fpath; |
388 | unsigned long size = 0; | 389 | off_t size = 0; |
389 | 390 | ||
390 | fname = alpm_pkg_get_filename(newpkg); | 391 | fname = alpm_pkg_get_filename(newpkg); |
391 | ASSERT(fname != NULL, RET_ERR(PM_ERR_PKG_INVALID_NAME, -1)); | 392 | ASSERT(fname != NULL, RET_ERR(PM_ERR_PKG_INVALID_NAME, -1)); |
@@ -395,8 +396,8 @@ static int compute_download_size(pmpkg_t *newpkg) | |||
395 | FREE(fpath); | 396 | FREE(fpath); |
396 | size = 0; | 397 | size = 0; |
397 | } else if(handle->usedelta) { | 398 | } else if(handle->usedelta) { |
398 | unsigned long dltsize; | 399 | off_t dltsize; |
399 | unsigned long pkgsize = alpm_pkg_get_size(newpkg); | 400 | off_t pkgsize = alpm_pkg_get_size(newpkg); |
400 | 401 | ||
401 | dltsize = _alpm_shortest_delta_path( | 402 | dltsize = _alpm_shortest_delta_path( |
402 | alpm_pkg_get_deltas(newpkg), | 403 | alpm_pkg_get_deltas(newpkg), |
@@ -417,8 +418,8 @@ static int compute_download_size(pmpkg_t *newpkg) | |||
417 | size = alpm_pkg_get_size(newpkg); | 418 | size = alpm_pkg_get_size(newpkg); |
418 | } | 419 | } |
419 | 420 | ||
420 | _alpm_log(PM_LOG_DEBUG, "setting download size %ld for pkg %s\n", size, | 421 | _alpm_log(PM_LOG_DEBUG, "setting download size %lld for pkg %s\n", |
421 | alpm_pkg_get_name(newpkg)); | 422 | (long long)size, alpm_pkg_get_name(newpkg)); |
422 | 423 | ||
423 | newpkg->download_size = size; | 424 | newpkg->download_size = size; |
424 | return(0); | 425 | return(0); |
@@ -670,7 +671,7 @@ cleanup: | |||
670 | * @param newpkg the new package to upgrade to | 671 | * @param newpkg the new package to upgrade to |
671 | * @return the size of the download | 672 | * @return the size of the download |
672 | */ | 673 | */ |
673 | unsigned long SYMEXPORT alpm_pkg_download_size(pmpkg_t *newpkg) | 674 | off_t SYMEXPORT alpm_pkg_download_size(pmpkg_t *newpkg) |
674 | { | 675 | { |
675 | return(newpkg->download_size); | 676 | return(newpkg->download_size); |
676 | } | 677 | } |
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 @@ | |||
23 | #include <stdlib.h> | 23 | #include <stdlib.h> |
24 | #include <string.h> | 24 | #include <string.h> |
25 | #include <sys/time.h> | 25 | #include <sys/time.h> |
26 | #include <sys/types.h> /* off_t */ | ||
26 | #include <unistd.h> | 27 | #include <unistd.h> |
27 | #include <dirent.h> | 28 | #include <dirent.h> |
28 | #include <wchar.h> | 29 | #include <wchar.h> |
@@ -36,7 +37,7 @@ | |||
36 | 37 | ||
37 | /* download progress bar */ | 38 | /* download progress bar */ |
38 | static float rate_last; | 39 | static float rate_last; |
39 | static int xfered_last; | 40 | static off_t xfered_last; |
40 | static struct timeval initial_time; | 41 | static struct timeval initial_time; |
41 | 42 | ||
42 | /* transaction progress bar */ | 43 | /* transaction progress bar */ |
@@ -410,7 +411,7 @@ void cb_trans_progress(pmtransprog_t event, const char *pkgname, int percent, | |||
410 | } | 411 | } |
411 | 412 | ||
412 | /* callback to handle display of download progress */ | 413 | /* callback to handle display of download progress */ |
413 | void cb_dl_progress(const char *filename, int xfered, int total) | 414 | void cb_dl_progress(const char *filename, off_t xfered, off_t total) |
414 | { | 415 | { |
415 | const int infolen = 50; | 416 | const int infolen = 50; |
416 | const int filenamelen = infolen - 27; | 417 | const int filenamelen = infolen - 27; |
@@ -428,12 +429,12 @@ void cb_dl_progress(const char *filename, int xfered, int total) | |||
428 | return; | 429 | return; |
429 | } | 430 | } |
430 | 431 | ||
431 | /* this is basically a switch on file_xferred: 0, file_total, and | 432 | /* this is basically a switch on xfered: 0, total, and |
432 | * anything else */ | 433 | * anything else */ |
433 | if(xfered == 0) { | 434 | if(xfered == 0) { |
434 | /* set default starting values */ | 435 | /* set default starting values */ |
435 | gettimeofday(&initial_time, NULL); | 436 | gettimeofday(&initial_time, NULL); |
436 | xfered_last = 0; | 437 | xfered_last = (off_t)0; |
437 | rate_last = 0.0; | 438 | rate_last = 0.0; |
438 | timediff = get_update_timediff(1); | 439 | timediff = get_update_timediff(1); |
439 | } else if(xfered == total) { | 440 | } 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 @@ | |||
19 | #ifndef _PM_CALLBACK_H | 19 | #ifndef _PM_CALLBACK_H |
20 | #define _PM_CALLBACK_H | 20 | #define _PM_CALLBACK_H |
21 | 21 | ||
22 | #include <sys/types.h> /* off_t */ | ||
23 | |||
22 | #include <alpm.h> | 24 | #include <alpm.h> |
23 | 25 | ||
24 | /* callback to handle messages/notifications from libalpm transactions */ | 26 | /* callback to handle messages/notifications from libalpm transactions */ |
@@ -33,7 +35,7 @@ void cb_trans_progress(pmtransprog_t event, const char *pkgname, int percent, | |||
33 | int howmany, int remain); | 35 | int howmany, int remain); |
34 | 36 | ||
35 | /* callback to handle display of download progress */ | 37 | /* callback to handle display of download progress */ |
36 | void cb_dl_progress(const char *filename, int file_xfered, int file_total); | 38 | void cb_dl_progress(const char *filename, off_t file_xfered, off_t file_total); |
37 | 39 | ||
38 | /* callback to handle messages/notifications from pacman library */ | 40 | /* callback to handle messages/notifications from pacman library */ |
39 | void cb_log(pmloglevel_t level, char *fmt, va_list args); | 41 | 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) | |||
493 | const alpm_list_t *i, *j; | 493 | const alpm_list_t *i, *j; |
494 | alpm_list_t *targets = NULL, *to_remove = NULL; | 494 | alpm_list_t *targets = NULL, *to_remove = NULL; |
495 | /* TODO these are some messy variable names */ | 495 | /* TODO these are some messy variable names */ |
496 | unsigned long isize = 0, rsize = 0, dispsize = 0, dlsize = 0; | 496 | off_t isize = 0, rsize = 0, dispsize = 0, dlsize = 0; |
497 | double mbisize = 0.0, mbrsize = 0.0, mbdispsize = 0.0, mbdlsize = 0.0; | 497 | double mbisize = 0.0, mbrsize = 0.0, mbdispsize = 0.0, mbdlsize = 0.0; |
498 | 498 | ||
499 | for(i = syncpkgs; i; i = alpm_list_next(i)) { | 499 | for(i = syncpkgs; i; i = alpm_list_next(i)) { |