diff options
author | Guillem Jover <guillem@debian.org> | 2011-03-14 02:15:38 +0100 |
---|---|---|
committer | Guillem Jover <guillem@debian.org> | 2011-03-14 07:21:57 +0100 |
commit | 86cbf575b13d049504402f72d221fa1538c2e53b (patch) | |
tree | 1bf3ac618206bb08bf0a170c495d44bd6a824bd8 /dpkg-split | |
parent | 74dc50b34d45e906ecdf664634ad491f2ffac43e (diff) | |
download | dpkg-86cbf575b13d049504402f72d221fa1538c2e53b.tar.gz |
Use off_t and %jd or %jx to handle file sizes and offsets
This allows to support large files on 32-bit systems were a ‘long int’
type might not be of at least 64-bits. For printing %jd or %jx is used,
and the value is cast to intmax_t.
Diffstat (limited to 'dpkg-split')
-rw-r--r-- | dpkg-split/dpkg-split.h | 12 | ||||
-rw-r--r-- | dpkg-split/info.c | 20 | ||||
-rw-r--r-- | dpkg-split/main.c | 4 | ||||
-rw-r--r-- | dpkg-split/queue.c | 9 | ||||
-rw-r--r-- | dpkg-split/split.c | 10 |
5 files changed, 29 insertions, 26 deletions
diff --git a/dpkg-split/dpkg-split.h b/dpkg-split/dpkg-split.h index cd2d6bb71..f8903a4aa 100644 --- a/dpkg-split/dpkg-split.h +++ b/dpkg-split/dpkg-split.h @@ -31,13 +31,13 @@ struct partinfo { const char *package; const char *version; const char *md5sum; - unsigned long orglength; + off_t orglength; unsigned int thispartn, maxpartn; - unsigned long maxpartlen; - unsigned long thispartoffset; - size_t thispartlen; + off_t maxpartlen; + off_t thispartoffset; + off_t thispartlen; /* Size of header in part file. */ - size_t headerlen; + off_t headerlen; off_t filesize; }; @@ -52,7 +52,7 @@ struct partqueue { extern struct partqueue *queue; -extern long opt_maxpartsize; +extern off_t opt_maxpartsize; extern const char *opt_depotdir; extern const char *opt_outputfile; extern int opt_npquiet; diff --git a/dpkg-split/info.c b/dpkg-split/info.c index f01661d51..3f09dceab 100644 --- a/dpkg-split/info.c +++ b/dpkg-split/info.c @@ -204,24 +204,24 @@ void print_info(const struct partinfo *pi) { " Part of package: %s\n" " ... version: %s\n" " ... MD5 checksum: %s\n" - " ... length: %lu bytes\n" - " ... split every: %lu bytes\n" + " ... length: %jd bytes\n" + " ... split every: %jd bytes\n" " Part number: %d/%d\n" - " Part length: %zi bytes\n" - " Part offset: %lu bytes\n" - " Part file size (used portion): %lu bytes\n\n"), + " Part length: %jd bytes\n" + " Part offset: %jd bytes\n" + " Part file size (used portion): %jd bytes\n\n"), pi->filename, pi->fmtversion, pi->package, pi->version, pi->md5sum, - pi->orglength, - pi->maxpartlen, + (intmax_t)pi->orglength, + (intmax_t)pi->maxpartlen, pi->thispartn, pi->maxpartn, - pi->thispartlen, - pi->thispartoffset, - (unsigned long)pi->filesize); + (intmax_t)pi->thispartlen, + (intmax_t)pi->thispartoffset, + (intmax_t)pi->filesize); } void do_info(const char *const *argv) { diff --git a/dpkg-split/main.c b/dpkg-split/main.c index 98926da87..8b8672ac8 100644 --- a/dpkg-split/main.c +++ b/dpkg-split/main.c @@ -99,7 +99,7 @@ const char printforhelp[]= N_("Type dpkg-split --help for help."); struct partqueue *queue= NULL; -long opt_maxpartsize = SPLITPARTDEFMAX; +off_t opt_maxpartsize = SPLITPARTDEFMAX; const char *opt_depotdir = ADMINDIR "/" PARTSDIR; const char *opt_outputfile = NULL; int opt_npquiet = 0; @@ -111,7 +111,7 @@ void rerreof(FILE *f, const char *fn) { } static void setpartsize(const struct cmdinfo *cip, const char *value) { - long newpartsize; + off_t newpartsize; char *endp; newpartsize = strtoimax(value, &endp, 10); diff --git a/dpkg-split/queue.c b/dpkg-split/queue.c index b61159b89..a5f41ce90 100644 --- a/dpkg-split/queue.c +++ b/dpkg-split/queue.c @@ -30,6 +30,7 @@ #include <fcntl.h> #include <dirent.h> #include <unistd.h> +#include <stdint.h> #include <stdlib.h> #include <stdio.h> @@ -168,7 +169,7 @@ void do_auto(const char *const *argv) { char *p, *q; m_asprintf(&p, "%st.%lx", opt_depotdir, (long)getpid()); - m_asprintf(&q, "%s%s.%lx.%x.%x", opt_depotdir, refi->md5sum, + m_asprintf(&q, "%s%s.%jx.%x.%x", (intmax_t)opt_depotdir, refi->md5sum, refi->maxpartlen, refi->thispartn, refi->maxpartn); fd_src = open(partfile, O_RDONLY); @@ -219,7 +220,7 @@ void do_queue(const char *const *argv) { struct partqueue *pq; const char *head; struct stat stab; - unsigned long bytes; + off_t bytes; if (*argv) badusage(_("--%s takes no arguments"), cipaction->olong); @@ -233,7 +234,7 @@ void do_queue(const char *const *argv) { ohshit(_("unable to stat `%.250s'"),pq->info.filename); if (S_ISREG(stab.st_mode)) { bytes= stab.st_size; - printf(_(" %s (%lu bytes)\n"),pq->info.filename,bytes); + printf(_(" %s (%jd bytes)\n"), pq->info.filename, (intmax_t)bytes); } else { printf(_(" %s (not a plain file)\n"),pq->info.filename); } @@ -268,7 +269,7 @@ void do_queue(const char *const *argv) { qq->info.md5sum = NULL; } } - printf(_("(total %lu bytes)\n"),bytes); + printf(_("(total %jd bytes)\n"), (intmax_t)bytes); } m_output(stdout, _("<standard output>")); } diff --git a/dpkg-split/split.c b/dpkg-split/split.c index 7e6047a77..6727ed56f 100644 --- a/dpkg-split/split.c +++ b/dpkg-split/split.c @@ -33,6 +33,7 @@ #include <ctype.h> #include <time.h> #include <unistd.h> +#include <stdint.h> #include <stdlib.h> #include <stdio.h> @@ -109,7 +110,7 @@ clean_msdos_filename(char *filename) } static int -mksplit(const char *file_src, const char *prefix, size_t maxpartsize, +mksplit(const char *file_src, const char *prefix, off_t maxpartsize, bool msdos) { int fd_src; @@ -187,7 +188,7 @@ mksplit(const char *file_src, const char *prefix, size_t maxpartsize, if (curpart == nparts) partsize = last_partsize; - if ((size_t)partsize > maxpartsize) { + if (partsize > maxpartsize) { ohshit(_("Header is too long, making part too long. " "Your package name or version\n" "numbers must be extraordinarily long, " @@ -203,9 +204,10 @@ mksplit(const char *file_src, const char *prefix, size_t maxpartsize, dpkg_ar_put_magic(file_dst.buf, fd_dst); /* Write the debian-split part. */ - varbuf_printf(&partmagic, "%s\n%s\n%s\n%s\n%zu\n%zu\n%d/%d\n", + varbuf_printf(&partmagic, "%s\n%s\n%s\n%s\n%jd\n%jd\n%d/%d\n", SPLITVERSION, package, version, hash, - st.st_size, partsize, curpart, nparts); + (intmax_t)st.st_size, (intmax_t)partsize, + curpart, nparts); dpkg_ar_member_put_mem(file_dst.buf, fd_dst, PARTMAGIC, partmagic.buf, partmagic.used); varbuf_reset(&partmagic); |