]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libblkid: use internally uint64_t for offsets and sizes
authorKarel Zak <kzak@redhat.com>
Tue, 12 Jan 2016 17:42:02 +0000 (18:42 +0100)
committerKarel Zak <kzak@redhat.com>
Tue, 12 Jan 2016 17:42:10 +0000 (18:42 +0100)
Signed-off-by: Karel Zak <kzak@redhat.com>
15 files changed:
libblkid/src/blkidP.h
libblkid/src/partitions/gpt.c
libblkid/src/partitions/mac.c
libblkid/src/partitions/partitions.c
libblkid/src/partitions/partitions.h
libblkid/src/partitions/sun.c
libblkid/src/probe.c
libblkid/src/superblocks/befs.c
libblkid/src/superblocks/exfat.c
libblkid/src/superblocks/hfs.c
libblkid/src/superblocks/linux_raid.c
libblkid/src/superblocks/superblocks.c
libblkid/src/superblocks/udf.c
libblkid/src/superblocks/vfat.c
misc-utils/blkid.c

index aaa0574092c6d5a189adbba5ded83d389caecea4..916deb0d59ac71d446ee7ca9e2890b87923a2600 100644 (file)
@@ -167,8 +167,8 @@ struct blkid_idinfo
 
 struct blkid_bufinfo {
        unsigned char           *data;
-       blkid_loff_t            off;
-       blkid_loff_t            len;
+       uint64_t                off;
+       uint64_t                len;
        struct list_head        bufs;   /* list of buffers */
 };
 
@@ -178,8 +178,8 @@ struct blkid_bufinfo {
 struct blkid_struct_probe
 {
        int                     fd;             /* device file descriptor */
-       blkid_loff_t            off;            /* begin of data on the device */
-       blkid_loff_t            size;           /* end of data on the device */
+       uint64_t                off;            /* begin of data on the device */
+       uint64_t                size;           /* end of data on the device */
        size_t                  mmap_granularity; /* minimal size of mmaped buffer (PAGE_SIZE) */
 
        dev_t                   devno;          /* device number (st.st_rdev) */
@@ -190,8 +190,8 @@ struct blkid_struct_probe
        int                     flags;          /* private libray flags */
        int                     prob_flags;     /* always zeroized by blkid_do_*() */
 
-       blkid_loff_t            wipe_off;       /* begin of the wiped area */
-       blkid_loff_t            wipe_size;      /* size of the wiped area */
+       uint64_t                wipe_off;       /* begin of the wiped area */
+       uint64_t                wipe_size;      /* size of the wiped area */
        struct blkid_chain      *wipe_chain;    /* superblock, partition, ... */
 
        struct list_head        buffers;        /* list of buffers */
@@ -386,7 +386,7 @@ extern int blkid_probe_is_cdrom(blkid_probe pr)
                        __attribute__((warn_unused_result));
 
 extern unsigned char *blkid_probe_get_buffer(blkid_probe pr,
-                                blkid_loff_t off, blkid_loff_t len)
+                                uint64_t off, uint64_t len)
                        __attribute__((nonnull))
                        __attribute__((warn_unused_result));
 
@@ -395,15 +395,15 @@ extern unsigned char *blkid_probe_get_sector(blkid_probe pr, unsigned int sector
                        __attribute__((warn_unused_result));
 
 extern int blkid_probe_get_dimension(blkid_probe pr,
-                       blkid_loff_t *off, blkid_loff_t *size)
+                       uint64_t *off, uint64_t *size)
                        __attribute__((nonnull));
 
 extern int blkid_probe_set_dimension(blkid_probe pr,
-                       blkid_loff_t off, blkid_loff_t size)
+                       uint64_t off, uint64_t size)
                        __attribute__((nonnull));
 
 extern int blkid_probe_get_idmag(blkid_probe pr, const struct blkid_idinfo *id,
-                       blkid_loff_t *offset, const struct blkid_idmag **res)
+                       uint64_t *offset, const struct blkid_idmag **res)
                        __attribute__((nonnull(1)));
 
 /* returns superblok according to 'struct blkid_idmag' */
@@ -416,7 +416,7 @@ extern blkid_partlist blkid_probe_get_partlist(blkid_probe pr)
                        __attribute__((warn_unused_result));
 
 extern int blkid_probe_is_covered_by_pt(blkid_probe pr,
-                                       blkid_loff_t offset, blkid_loff_t size)
+                                       uint64_t offset, uint64_t size)
                        __attribute__((warn_unused_result));
 
 extern void blkid_probe_chain_reset_values(blkid_probe pr, struct blkid_chain *chn)
@@ -487,7 +487,7 @@ extern int blkid_probe_sprintf_value(blkid_probe pr, const char *name,
                        __attribute__((nonnull))
                        __attribute__ ((__format__ (__printf__, 3, 4)));
 
-extern int blkid_probe_set_magic(blkid_probe pr, blkid_loff_t offset,
+extern int blkid_probe_set_magic(blkid_probe pr, uint64_t offset,
                                size_t len, unsigned char *magic)
                        __attribute__((nonnull));
 
@@ -503,14 +503,14 @@ extern size_t blkid_rtrim_whitespace(unsigned char *str)
 extern size_t blkid_ltrim_whitespace(unsigned char *str)
                        __attribute__((nonnull));
 
-extern void blkid_probe_set_wiper(blkid_probe pr, blkid_loff_t off,
-                                 blkid_loff_t size)
+extern void blkid_probe_set_wiper(blkid_probe pr, uint64_t off,
+                                 uint64_t size)
                        __attribute__((nonnull));
 extern int blkid_probe_is_wiped(blkid_probe pr, struct blkid_chain **chn,
-                               blkid_loff_t off, blkid_loff_t size)
+                               uint64_t off, uint64_t size)
                        __attribute__((nonnull))
                        __attribute__((warn_unused_result));
-extern void blkid_probe_use_wiper(blkid_probe pr, blkid_loff_t off, blkid_loff_t size)
+extern void blkid_probe_use_wiper(blkid_probe pr, uint64_t off, uint64_t size)
                        __attribute__((nonnull));
 
 /* filter bitmap macros */
index 26f0474426ca04ce5bf757b28e91f5aaf41dcc2a..01b739f520ff9eafd5ba88649b5b265150178b06 100644 (file)
@@ -133,7 +133,7 @@ static void swap_efi_guid(efi_guid_t *uid)
 
 static int last_lba(blkid_probe pr, uint64_t *lba)
 {
-       blkid_loff_t sz = blkid_probe_get_size(pr);
+       uint64_t sz = blkid_probe_get_size(pr);
        unsigned int ssz = blkid_probe_get_sectorsize(pr);
 
        if (sz < ssz)
index 4282605344ea0bac677595c48ef169cca41aeaa3..bbc2fb3c291ef147c38e5422491ba30b8754f6c1 100644 (file)
@@ -61,8 +61,7 @@ static inline unsigned char *get_mac_block(
                                        uint16_t block_size,
                                        uint32_t num)
 {
-       return blkid_probe_get_buffer(pr,
-                       (blkid_loff_t) num * block_size, block_size);
+       return blkid_probe_get_buffer(pr, (uint64_t) num * block_size, block_size);
 }
 
 static inline int has_part_signature(struct mac_partition *p)
index 6e55a8f3ee4f3df4fbc0c536dada0806ed784c0a..0b5e68099bc4c546f81a52b228ab1a11eea42e80 100644 (file)
@@ -163,7 +163,7 @@ const struct blkid_chaindrv partitions_drv = {
 /* exported as opaque type "blkid_parttable" */
 struct blkid_struct_parttable {
        const char      *type;          /* partition table type */
-       blkid_loff_t    offset;         /* begin of the partition table (in bytes) */
+       uint64_t        offset;         /* begin of the partition table (in bytes) */
        int             nparts;         /* number of partitions */
        blkid_partition parent;         /* parent of nested partition table */
        char            id[37];         /* PT identifier (e.g. UUID for GPT) */
@@ -173,8 +173,8 @@ struct blkid_struct_parttable {
 
 /* exported as opaque type "blkid_partition" */
 struct blkid_struct_partition {
-       blkid_loff_t    start;          /* begin of the partition (512-bytes sectors) */
-       blkid_loff_t    size;           /* size of the partitions (512-bytes sectors) */
+       uint64_t        start;          /* begin of the partition (512-bytes sectors) */
+       uint64_t        size;           /* size of the partitions (512-bytes sectors) */
 
        int             type;           /* partition type */
        char            typestr[37];    /* partition type string (GPT and Mac) */
@@ -404,7 +404,7 @@ static void partitions_free_data(blkid_probe pr __attribute__((__unused__)),
 }
 
 blkid_parttable blkid_partlist_new_parttable(blkid_partlist ls,
-                               const char *type, blkid_loff_t offset)
+                               const char *type, uint64_t offset)
 {
        blkid_parttable tab;
 
@@ -450,8 +450,7 @@ static blkid_partition new_partition(blkid_partlist ls, blkid_parttable tab)
 }
 
 blkid_partition blkid_partlist_add_partition(blkid_partlist ls,
-                                       blkid_parttable tab,
-                                       blkid_loff_t start, blkid_loff_t size)
+                                       blkid_parttable tab, uint64_t start, uint64_t size)
 {
        blkid_partition par = new_partition(ls, tab);
 
@@ -462,7 +461,7 @@ blkid_partition blkid_partlist_add_partition(blkid_partlist ls,
        par->size = size;
 
        DBG(LOWPROBE, ul_debug("parts: add partition (%p start=%"
-               PRId64 ", size=%" PRId64 ", table=%p)",
+               PRIu64 ", size=%" PRIu64 ", table=%p)",
                par, par->start, par->size, tab));
        return par;
 }
@@ -514,10 +513,10 @@ int blkid_partitions_get_flags(blkid_probe pr)
 
 /* check if @start and @size are within @par partition */
 int blkid_is_nested_dimension(blkid_partition par,
-                       blkid_loff_t start, blkid_loff_t size)
+                       uint64_t start, uint64_t size)
 {
-       blkid_loff_t pstart;
-       blkid_loff_t psize;
+       uint64_t pstart;
+       uint64_t psize;
 
        if (!par)
                return 0;
@@ -535,7 +534,7 @@ static int idinfo_probe(blkid_probe pr, const struct blkid_idinfo *id,
                        struct blkid_chain *chn)
 {
        const struct blkid_idmag *mag = NULL;
-       blkid_loff_t off;
+       uint64_t off;
        int rc = BLKID_PROBE_NONE;              /* default is nothing */
 
        if (pr->size <= 0 || (id->minsz && id->minsz > pr->size))
@@ -667,7 +666,7 @@ int blkid_partitions_do_subprobe(blkid_probe pr, blkid_partition parent,
        blkid_probe prc;
        int rc;
        blkid_partlist ls;
-       blkid_loff_t sz, off;
+       uint64_t sz, off;
 
        DBG(LOWPROBE, ul_debug(
                "parts: ----> %s subprobe requested (parent=%p)",
@@ -679,8 +678,8 @@ int blkid_partitions_do_subprobe(blkid_probe pr, blkid_partition parent,
                return BLKID_PROBE_NONE;
 
        /* range defined by parent */
-       sz = ((blkid_loff_t) parent->size) << 9;
-       off = ((blkid_loff_t) parent->start) << 9;
+       sz = parent->size << 9;
+       off = parent->start << 9;
 
        if (off < pr->off || pr->off + pr->size < off + sz) {
                DBG(LOWPROBE, ul_debug(
@@ -813,11 +812,11 @@ nothing:
  * @size is covered by any partition.
  */
 int blkid_probe_is_covered_by_pt(blkid_probe pr,
-                                blkid_loff_t offset, blkid_loff_t size)
+                                uint64_t offset, uint64_t size)
 {
        blkid_probe prc = NULL;
        blkid_partlist ls = NULL;
-       blkid_loff_t start, end;
+       uint64_t start, end;
        int nparts, i, rc = 0;
 
        DBG(LOWPROBE, ul_debug(
@@ -1041,8 +1040,8 @@ blkid_partition blkid_partlist_devno_to_partition(blkid_partlist ls, dev_t devno
                         if (partno != blkid_partition_get_partno(par))
                                 continue;
 
-                        if ((blkid_loff_t) size == blkid_partition_get_size(par) ||
-                            (blkid_partition_is_extended(par) && size <= 1024))
+                        if (size == blkid_partition_get_size(par) ||
+                            (blkid_partition_is_extended(par) && size <= 1024ULL))
                                 return par;
 
                 }
@@ -1054,13 +1053,13 @@ blkid_partition blkid_partlist_devno_to_partition(blkid_partlist ls, dev_t devno
        for (i = 0; i < ls->nparts; i++) {
                blkid_partition par = &ls->parts[i];
 
-               if (blkid_partition_get_start(par) == (blkid_loff_t) start &&
-                   blkid_partition_get_size(par) == (blkid_loff_t) size)
+               if (blkid_partition_get_start(par) == start &&
+                   blkid_partition_get_size(par) == size)
                        return par;
 
                /* exception for extended dos partitions */
-               if (blkid_partition_get_start(par) == (blkid_loff_t) start &&
-                   blkid_partition_is_extended(par) && size <= 1024)
+               if (blkid_partition_get_start(par) == start &&
+                   blkid_partition_is_extended(par) && size <= 1024ULL)
                        return par;
 
        }
index 3651bbb4df0b697905d8b24a377bf153cd555675..7ec03b21ddbf6bd1836b78bb2ec44f3972d83869 100644 (file)
@@ -7,14 +7,14 @@
 extern int blkid_partitions_get_flags(blkid_probe pr);
 
 extern blkid_parttable blkid_partlist_new_parttable(blkid_partlist ls,
-                               const char *type, blkid_loff_t offset);
+                               const char *type, uint64_t offset);
 
 extern int blkid_parttable_set_uuid(blkid_parttable tab, const unsigned char *id);
 extern int blkid_parttable_set_id(blkid_parttable tab, const unsigned char *id);
 
 extern blkid_partition blkid_partlist_add_partition(blkid_partlist ls,
                                blkid_parttable tab,
-                               blkid_loff_t start, blkid_loff_t size);
+                               uint64_t start, uint64_t size);
 
 extern int blkid_partlist_set_partno(blkid_partlist ls, int partno);
 extern int blkid_partlist_increment_partno(blkid_partlist ls);
@@ -30,7 +30,7 @@ extern int blkid_partitions_strcpy_ptuuid(blkid_probe pr, char *str);
 
 
 extern int blkid_is_nested_dimension(blkid_partition par,
-                        blkid_loff_t start, blkid_loff_t size);
+                        uint64_t start, uint64_t size);
 
 extern int blkid_partition_set_name(blkid_partition par,
                const unsigned char *name, size_t len);
index 22ee450427679faaa294f673dcd7ddffe21ff005..5c202f76e03fb392835c04d57edd085eec92397d 100644 (file)
@@ -23,7 +23,7 @@ static int probe_sun_pt(blkid_probe pr,
        blkid_parttable tab = NULL;
        blkid_partlist ls;
        uint16_t nparts;
-       blkid_loff_t spc;
+       uint64_t spc;
        int i, use_vtoc;
 
        l = (struct sun_disklabel *) blkid_probe_get_sector(pr, 0);
@@ -75,7 +75,7 @@ static int probe_sun_pt(blkid_probe pr,
 
        for (i = 0, p = l->partitions; i < nparts; i++, p++) {
 
-               blkid_loff_t start, size;
+               uint64_t start, size;
                uint16_t type = 0, flags = 0;
                blkid_partition par;
 
index e7b7bad5d73b9604156b1776181d9d3f566583b3..4efa2bacdaece4892d78e7548e4ec7a91632d9f6 100644 (file)
@@ -590,12 +590,10 @@ int __blkid_probe_filter_types(blkid_probe pr, int chain, int flag, char *names[
 
 #define probe_is_mmap_wanted(p)                (!S_ISCHR((p)->mode))
 
-static struct blkid_bufinfo *mmap_buffer(blkid_probe pr,
-                                        blkid_loff_t real_off,
-                                        blkid_loff_t len)
+static struct blkid_bufinfo *mmap_buffer(blkid_probe pr, uint64_t real_off, uint64_t len)
 {
-       blkid_loff_t map_len;
-       blkid_loff_t map_off = 0;
+       uint64_t map_len;
+       uint64_t map_off = 0;
        struct blkid_bufinfo *bf = NULL;
 
        /*
@@ -609,8 +607,7 @@ static struct blkid_bufinfo *mmap_buffer(blkid_probe pr,
 
        /* begin of the device */
        if (real_off == 0 || real_off + len < PROBE_MMAP_BEGINSIZ) {
-               DBG(BUFFER, ul_debug("\tmapping begin of the device (max size: %ju)",
-                                       (uintmax_t) pr->size));
+               DBG(BUFFER, ul_debug("\tmapping begin of the device (max size: %ju)", pr->size));
                map_off = 0;
                map_len = PROBE_MMAP_BEGINSIZ > pr->size ? pr->size : PROBE_MMAP_BEGINSIZ;
 
@@ -618,15 +615,14 @@ static struct blkid_bufinfo *mmap_buffer(blkid_probe pr,
        /* end of the device */
        } else if (real_off > pr->off + pr->size - PROBE_MMAP_ENDSIZ) {
                DBG(BUFFER, ul_debug("\tmapping end of the device (probing area: "
-                                       "off=%ju, size=%ju)",
-                                       (uintmax_t) pr->off, (uintmax_t) pr->size));
+                                       "off=%ju, size=%ju)", pr->off, pr->size));
 
                map_off = PROBE_ALIGN_OFF(pr, pr->off + pr->size - PROBE_MMAP_ENDSIZ);
                map_len = pr->off + pr->size - map_off;
 
        /* middle of the device */
        } else {
-               blkid_loff_t minlen;
+               uint64_t minlen;
 
                map_off = PROBE_ALIGN_OFF(pr, real_off);
                minlen = real_off + len - map_off;
@@ -660,14 +656,11 @@ static struct blkid_bufinfo *mmap_buffer(blkid_probe pr,
        INIT_LIST_HEAD(&bf->bufs);
 
        DBG(BUFFER, ul_debug("\tmmap  %p: off=%ju, len=%ju (%ju pages)",
-                               bf->data, (uintmax_t) map_off, (uintmax_t) map_len,
-                               (uintmax_t) map_len / pr->mmap_granularity));
+                               bf->data, map_off, map_len, map_len / pr->mmap_granularity));
        return bf;
 }
 
-static struct blkid_bufinfo *read_buffer(blkid_probe pr,
-                                        blkid_loff_t real_off,
-                                        blkid_loff_t len)
+static struct blkid_bufinfo *read_buffer(blkid_probe pr, uint64_t real_off, uint64_t len)
 {
        ssize_t ret;
        struct blkid_bufinfo *bf = NULL;
@@ -695,7 +688,7 @@ static struct blkid_bufinfo *read_buffer(blkid_probe pr,
        bf->off = real_off;
        INIT_LIST_HEAD(&bf->bufs);
 
-       DBG(LOWPROBE, ul_debug("\tread %p: off=%jd len=%jd", bf->data, real_off, len));
+       DBG(LOWPROBE, ul_debug("\tread %p: off=%ju len=%ju", bf->data, real_off, len));
 
        ret = read(pr->fd, bf->data, len);
        if (ret != (ssize_t) len) {
@@ -713,19 +706,18 @@ static struct blkid_bufinfo *read_buffer(blkid_probe pr,
  * Note that @off is offset within probing area, the probing area is defined by
  * pr->off and pr->size.
  */
-unsigned char *blkid_probe_get_buffer(blkid_probe pr,
-                               blkid_loff_t off, blkid_loff_t len)
+unsigned char *blkid_probe_get_buffer(blkid_probe pr, uint64_t off, uint64_t len)
 {
        struct list_head *p;
        struct blkid_bufinfo *bf = NULL;
-       blkid_loff_t real_off = pr->off + off;
+       uint64_t real_off = pr->off + off;
 
        /*
        DBG(BUFFER, ul_debug("\t>>>> off=%ju, real-off=%ju (probe <%ju..%ju>, len=%ju",
                                off, real_off, pr->off, pr->off + pr->size, len));
        */
 
-       if (pr->size <= 0) {
+       if (pr->size == 0) {
                errno = EINVAL;
                return NULL;
        }
@@ -757,9 +749,8 @@ unsigned char *blkid_probe_get_buffer(blkid_probe pr,
                                list_entry(p, struct blkid_bufinfo, bufs);
 
                if (real_off >= x->off && real_off + len <= x->off + x->len) {
-                       DBG(BUFFER, ul_debug("\treuse %p: off=%jd len=%jd (for off=%jd len=%jd)",
-                                               x->data, x->off, x->len,
-                                               real_off, len));
+                       DBG(BUFFER, ul_debug("\treuse %p: off=%ju len=%ju (for off=%ju len=%ju)",
+                                               x->data, x->off, x->len, real_off, len));
                        bf = x;
                        break;
                }
@@ -861,7 +852,7 @@ int blkid_probe_set_device(blkid_probe pr, int fd,
                blkid_loff_t off, blkid_loff_t size)
 {
        struct stat sb;
-       blkid_loff_t devsiz = 0;
+       uint64_t devsiz = 0;
 
        if (!pr)
                return -1;
@@ -877,7 +868,7 @@ int blkid_probe_set_device(blkid_probe pr, int fd,
        pr->flags &= ~BLKID_FL_CDROM_DEV;
        pr->prob_flags = 0;
        pr->fd = fd;
-       pr->off = off;
+       pr->off = (uint64_t) off;
        pr->size = 0;
        pr->devno = 0;
        pr->disk_devno = 0;
@@ -917,7 +908,7 @@ int blkid_probe_set_device(blkid_probe pr, int fd,
 
        if (off && size == 0)
                /* only offset without size specified */
-               pr->size -= off;
+               pr->size -= (uint64_t) off;
 
        if (pr->off + pr->size > devsiz) {
                DBG(LOWPROBE, ul_debug("area specified by offset and size is bigger than device"));
@@ -941,7 +932,7 @@ int blkid_probe_set_device(blkid_probe pr, int fd,
                pr->flags |= BLKID_FL_CDROM_DEV;
 #endif
 
-       DBG(LOWPROBE, ul_debug("ready for low-probing, offset=%jd, size=%jd",
+       DBG(LOWPROBE, ul_debug("ready for low-probing, offset=%ju, size=%ju",
                                pr->off, pr->size));
        DBG(LOWPROBE, ul_debug("whole-disk: %s, regfile: %s",
                blkid_probe_is_wholedisk(pr) ?"YES" : "NO",
@@ -954,8 +945,7 @@ err:
 
 }
 
-int blkid_probe_get_dimension(blkid_probe pr,
-               blkid_loff_t *off, blkid_loff_t *size)
+int blkid_probe_get_dimension(blkid_probe pr, uint64_t *off, uint64_t *size)
 {
        if (!pr)
                return -1;
@@ -965,26 +955,21 @@ int blkid_probe_get_dimension(blkid_probe pr,
        return 0;
 }
 
-int blkid_probe_set_dimension(blkid_probe pr,
-               blkid_loff_t off, blkid_loff_t size)
+int blkid_probe_set_dimension(blkid_probe pr, uint64_t off, uint64_t size)
 {
        if (!pr)
                return -1;
 
        DBG(LOWPROBE, ul_debug(
-               "changing probing area pr=%p: size=%llu, off=%llu "
-               "-to-> size=%llu, off=%llu",
-               pr,
-               (unsigned long long) pr->size,
-               (unsigned long long) pr->off,
-               (unsigned long long) size,
-               (unsigned long long) off));
+               "changing probing area pr=%p: size=%ju, off=%ju "
+               "-to-> size=%ju, off=%ju",
+               pr, pr->size, pr->off, size, off));
 
        pr->off = off;
        pr->size = size;
        pr->flags &= ~BLKID_FL_TINY_DEV;
 
-       if (pr->size <= 1440 * 1024 && !S_ISCHR(pr->mode))
+       if (pr->size <= 1440ULL * 1024ULL && !S_ISCHR(pr->mode))
                pr->flags |= BLKID_FL_TINY_DEV;
 
        blkid_probe_reset_buffer(pr);
@@ -998,10 +983,10 @@ int blkid_probe_set_dimension(blkid_probe pr,
  * or no magic present, or negative value on error.
  */
 int blkid_probe_get_idmag(blkid_probe pr, const struct blkid_idinfo *id,
-                       blkid_loff_t *offset, const struct blkid_idmag **res)
+                       uint64_t *offset, const struct blkid_idmag **res)
 {
        const struct blkid_idmag *mag = NULL;
-       blkid_loff_t off = 0;
+       uint64_t off = 0;
 
        if (id)
                mag = &id->magics[0];
@@ -1190,7 +1175,7 @@ int blkid_do_wipe(blkid_probe pr, int dryrun)
 {
        const char *off = NULL;
        size_t len = 0;
-       loff_t offset, l;
+       uint64_t offset, l;
        char buf[BUFSIZ];
        int fd, rc = 0;
        struct blkid_chain *chn;
@@ -1220,7 +1205,7 @@ int blkid_do_wipe(blkid_probe pr, int dryrun)
        if (rc || len == 0 || off == NULL)
                return 0;
 
-       offset = strtoll(off, NULL, 10);
+       offset = strtoumax(off, NULL, 10);
        fd = blkid_probe_get_fd(pr);
        if (fd < 0)
                return -1;
@@ -1229,10 +1214,10 @@ int blkid_do_wipe(blkid_probe pr, int dryrun)
                len = sizeof(buf);
 
        DBG(LOWPROBE, ul_debug(
-           "do_wipe [offset=0x%jx, len=%zd, chain=%s, idx=%d, dryrun=%s]\n",
-           offset, len, chn->driver->name, chn->idx, dryrun ? "yes" : "not"));
+           "do_wipe [offset=0x%jx (%ju), len=%zd, chain=%s, idx=%d, dryrun=%s]\n",
+           offset, offset, len, chn->driver->name, chn->idx, dryrun ? "yes" : "not"));
 
-       l = lseek(fd, offset, SEEK_SET);
+       l = blkid_llseek(fd, offset, SEEK_SET);
        if (l == (off_t) -1)
                return -1;
 
@@ -1457,7 +1442,7 @@ done:
 unsigned char *blkid_probe_get_sector(blkid_probe pr, unsigned int sector)
 {
        return pr ? blkid_probe_get_buffer(pr,
-                       ((blkid_loff_t) sector) << 9, 0x200) : NULL;
+                       ((uint64_t) sector) << 9, 0x200) : NULL;
 }
 
 struct blkid_prval *blkid_probe_assign_value(
@@ -1552,7 +1537,7 @@ int blkid_probe_sprintf_value(blkid_probe pr, const char *name,
        return rc;
 }
 
-int blkid_probe_set_magic(blkid_probe pr, blkid_loff_t offset,
+int blkid_probe_set_magic(blkid_probe pr, uint64_t offset,
                        size_t len, unsigned char *magic)
 {
        int rc = 0;
@@ -1714,7 +1699,7 @@ blkid_probe blkid_probe_get_wholedisk_probe(blkid_probe pr)
  */
 blkid_loff_t blkid_probe_get_size(blkid_probe pr)
 {
-       return pr ? pr->size : -1;
+       return pr ? (blkid_loff_t) pr->size : -1;
 }
 
 /**
@@ -1727,7 +1712,7 @@ blkid_loff_t blkid_probe_get_size(blkid_probe pr)
  */
 blkid_loff_t blkid_probe_get_offset(blkid_probe pr)
 {
-       return pr ? pr->off : -1;
+       return pr ? (blkid_loff_t) pr->off : -1;
 }
 
 /**
@@ -1771,7 +1756,7 @@ unsigned int blkid_probe_get_sectorsize(blkid_probe pr)
  */
 blkid_loff_t blkid_probe_get_sectors(blkid_probe pr)
 {
-       return pr ? pr->size >> 9 : -1;
+       return pr ? (blkid_loff_t) (pr->size >> 9) : -1;
 }
 
 /**
@@ -1986,7 +1971,7 @@ size_t blkid_ltrim_whitespace(unsigned char *str)
  * Note that there is not relation between _wiper and blkid_to_wipe().
  *
  */
-void blkid_probe_set_wiper(blkid_probe pr, blkid_loff_t off, blkid_loff_t size)
+void blkid_probe_set_wiper(blkid_probe pr, uint64_t off, uint64_t size)
 {
        struct blkid_chain *chn;
 
@@ -2021,8 +2006,7 @@ void blkid_probe_set_wiper(blkid_probe pr, blkid_loff_t off, blkid_loff_t size)
 /*
  * Returns 1 if the <@off,@size> area was wiped
  */
-int blkid_probe_is_wiped(blkid_probe pr, struct blkid_chain **chn,
-                    blkid_loff_t off, blkid_loff_t size)
+int blkid_probe_is_wiped(blkid_probe pr, struct blkid_chain **chn, uint64_t off, uint64_t size)
 {
        if (!pr || !size)
                return 0;
@@ -2039,7 +2023,7 @@ int blkid_probe_is_wiped(blkid_probe pr, struct blkid_chain **chn,
  *  Try to use any area -- if the area has been previously wiped then the
  *  previous probing result should be ignored (reseted).
  */
-void blkid_probe_use_wiper(blkid_probe pr, blkid_loff_t off, blkid_loff_t size)
+void blkid_probe_use_wiper(blkid_probe pr, uint64_t off, uint64_t size)
 {
        struct blkid_chain *chn = NULL;
 
index e4453bc1779718a34bc7567cb577f60c32b54f63..7e9eaf687b07a765a5a3a007abbb8bcfb1edff6f 100644 (file)
@@ -126,12 +126,12 @@ static unsigned char *get_block_run(blkid_probe pr, const struct befs_super_bloc
                                        const struct block_run *br, int fs_le)
 {
        return blkid_probe_get_buffer(pr,
-                       ((blkid_loff_t) FS32_TO_CPU(br->allocation_group, fs_le)
+                       ((uint64_t) FS32_TO_CPU(br->allocation_group, fs_le)
                                        << FS32_TO_CPU(bs->ag_shift, fs_le)
                                        << FS32_TO_CPU(bs->block_shift, fs_le))
-                               + ((blkid_loff_t) FS16_TO_CPU(br->start, fs_le)
+                               + ((uint64_t) FS16_TO_CPU(br->start, fs_le)
                                        << FS32_TO_CPU(bs->block_shift, fs_le)),
-                       (blkid_loff_t) FS16_TO_CPU(br->len, fs_le)
+                       (uint64_t) FS16_TO_CPU(br->len, fs_le)
                                        << FS32_TO_CPU(bs->block_shift, fs_le));
 }
 
@@ -145,10 +145,10 @@ static unsigned char *get_custom_block_run(blkid_probe pr,
                return NULL;
 
        return blkid_probe_get_buffer(pr,
-                       ((blkid_loff_t) FS32_TO_CPU(br->allocation_group, fs_le)
+                       ((uint64_t) FS32_TO_CPU(br->allocation_group, fs_le)
                                        << FS32_TO_CPU(bs->ag_shift, fs_le)
                                        << FS32_TO_CPU(bs->block_shift, fs_le))
-                               + ((blkid_loff_t) FS16_TO_CPU(br->start, fs_le)
+                               + ((uint64_t) FS16_TO_CPU(br->start, fs_le)
                                        << FS32_TO_CPU(bs->block_shift, fs_le))
                                + offset,
                        length);
index b52656036be5f6e6f86743ed8a76f6b6af4b6218..7a16488f0dd761bd48ef0b874e256b0ddb865000 100644 (file)
@@ -45,21 +45,21 @@ struct exfat_entry_label {
 #define EXFAT_ENTRY_EOD                0x00
 #define EXFAT_ENTRY_LABEL      0x83
 
-static blkid_loff_t block_to_offset(const struct exfat_super_block *sb,
-               blkid_loff_t block)
+static uint64_t block_to_offset(const struct exfat_super_block *sb,
+               uint64_t block)
 {
-       return (blkid_loff_t) block << sb->block_bits;
+       return block << sb->block_bits;
 }
 
-static blkid_loff_t cluster_to_block(const struct exfat_super_block *sb,
+static uint64_t cluster_to_block(const struct exfat_super_block *sb,
                uint32_t cluster)
 {
        return le32_to_cpu(sb->cluster_block_start) +
-                       ((blkid_loff_t) (cluster - EXFAT_FIRST_DATA_CLUSTER)
+                       ((uint64_t) (cluster - EXFAT_FIRST_DATA_CLUSTER)
                                        << sb->bpc_bits);
 }
 
-static blkid_loff_t cluster_to_offset(const struct exfat_super_block *sb,
+static uint64_t cluster_to_offset(const struct exfat_super_block *sb,
                uint32_t cluster)
 {
        return block_to_offset(sb, cluster_to_block(sb, cluster));
@@ -69,10 +69,10 @@ static uint32_t next_cluster(blkid_probe pr,
                const struct exfat_super_block *sb, uint32_t cluster)
 {
        uint32_t *next;
-       blkid_loff_t fat_offset;
+       uint64_t fat_offset;
 
        fat_offset = block_to_offset(sb, le32_to_cpu(sb->fat_block_start))
-               + (blkid_loff_t) cluster * sizeof(cluster);
+               + (uint64_t) cluster * sizeof(cluster);
        next = (uint32_t *) blkid_probe_get_buffer(pr, fat_offset,
                        sizeof(uint32_t));
        if (!next)
@@ -84,7 +84,7 @@ static struct exfat_entry_label *find_label(blkid_probe pr,
                const struct exfat_super_block *sb)
 {
        uint32_t cluster = le32_to_cpu(sb->rootdir_cluster);
-       blkid_loff_t offset = cluster_to_offset(sb, cluster);
+       uint64_t offset = cluster_to_offset(sb, cluster);
        uint8_t *entry;
 
        for (;;) {
index 2cbaa63c33821db6b51f7a39129ed80d0e09da5a..ee502cf61f0d12cbba5d6a622c5837511fd04398 100644 (file)
@@ -234,7 +234,7 @@ static int probe_hfsplus(blkid_probe pr, const struct blkid_idmag *mag)
        cat_block = be32_to_cpu(extents[0].start_block);
 
        buf = blkid_probe_get_buffer(pr,
-                       off + ((blkid_loff_t) cat_block * blocksize), 0x2000);
+                       off + ((uint64_t) cat_block * blocksize), 0x2000);
        if (!buf)
                return errno ? -errno : 0;
 
@@ -268,7 +268,7 @@ static int probe_hfsplus(blkid_probe pr, const struct blkid_idmag *mag)
        leaf_off = ((uint64_t) ext_block_start + leaf_block) * blocksize;
 
        buf = blkid_probe_get_buffer(pr,
-                               (blkid_loff_t) off + leaf_off,
+                               (uint64_t) off + leaf_off,
                                leaf_node_size);
        if (!buf)
                return errno ? -errno : 0;
index cf29141c6014c5ce02ce3e5193892d0cee5482bb..dee293b4142b5201989a8434d5e684deb8d5b554 100644 (file)
@@ -99,7 +99,7 @@ struct mdp1_super_block {
 #define MD_RESERVED_BYTES              0x10000
 #define MD_SB_MAGIC                    0xa92b4efc
 
-static int probe_raid0(blkid_probe pr, blkid_loff_t off)
+static int probe_raid0(blkid_probe pr, uint64_t off)
 {
        struct mdp0_super_block *mdp0;
        union {
index 0d970f1341f0013cce3e45f320d9510eb965712f..2b850305daec1c6acae9cd7666d7d31913ee6189 100644 (file)
@@ -361,7 +361,7 @@ static int superblocks_probe(blkid_probe pr, struct blkid_chain *chn)
        for ( ; i < ARRAY_SIZE(idinfos); i++) {
                const struct blkid_idinfo *id;
                const struct blkid_idmag *mag = NULL;
-               blkid_loff_t off = 0;
+               uint64_t off = 0;
 
                chn->idx = i;
                id = idinfos[i];
index 3e9d48e4caf13069a0dc247967e5469ced91d63e..fc258cd1ea716e16c0186b6f5998cda55b0e813b 100644 (file)
@@ -166,7 +166,7 @@ nsr:
        for (b = 0; b < 64; b++) {
                vsd = (struct volume_structure_descriptor *)
                        blkid_probe_get_buffer(pr,
-                                       UDF_VSD_OFFSET + ((blkid_loff_t) b * 0x800),
+                                       UDF_VSD_OFFSET + ((uint64_t) b * 0x800),
                                        sizeof(*vsd));
                if (!vsd)
                        return errno ? -errno : 1;
@@ -205,7 +205,7 @@ real_blksz:
        for (b = 0; b < count; b++) {
                vd = (struct volume_descriptor *)
                        blkid_probe_get_buffer(pr,
-                                       (blkid_loff_t) (loc + b) * bs,
+                                       (uint64_t) (loc + b) * bs,
                                        sizeof(*vd));
                if (!vd)
                        return errno ? -errno : 1;
@@ -225,7 +225,7 @@ real_blksz:
        for (b = 0; b < count; b++) {
                vd = (struct volume_descriptor *)
                        blkid_probe_get_buffer(pr,
-                                       (blkid_loff_t) (loc + b) * bs,
+                                       (uint64_t) (loc + b) * bs,
                                        sizeof(*vd));
                if (!vd)
                        return errno ? -errno : 1;
index 00df4cb7dc5e9daad5edeb021908f4590cf5da76..50a71c9cfbbb3e3d4031d2db8efc59ee6bea37b5 100644 (file)
@@ -132,7 +132,7 @@ static unsigned char *search_fat_label(blkid_probe pr,
                dir = (struct vfat_dir_entry *)
                        blkid_probe_get_buffer(pr,
                                        offset,
-                                       (blkid_loff_t) entries *
+                                       (uint64_t) entries *
                                                sizeof(struct vfat_dir_entry));
                if (!dir)
                        return NULL;
@@ -147,7 +147,7 @@ static unsigned char *search_fat_label(blkid_probe pr,
                if (!dir)
                        ent = (struct vfat_dir_entry *)
                                blkid_probe_get_buffer(pr,
-                                       (blkid_loff_t) offset + (i *
+                                       (uint64_t) offset + (i *
                                                sizeof(struct vfat_dir_entry)),
                                        sizeof(struct vfat_dir_entry));
                else
@@ -395,7 +395,7 @@ static int probe_vfat(blkid_probe pr, const struct blkid_idmag *mag)
                        struct fat32_fsinfo *fsinfo;
 
                        buf = blkid_probe_get_buffer(pr,
-                                       (blkid_loff_t) fsinfo_sect * sector_size,
+                                       (uint64_t) fsinfo_sect * sector_size,
                                        sizeof(struct fat32_fsinfo));
                        if (buf == NULL)
                                return errno ? -errno : 1;
index eca35aa889d2509a3ac0422045b62ed51630bdc8..4ecbb5d3d3682bdb6699b8ccce06b6a8c9fa9a2a 100644 (file)
@@ -474,7 +474,7 @@ static int lowprobe_topology(blkid_probe pr)
 
 static int lowprobe_device(blkid_probe pr, const char *devname,
                        int chain, char *show[], int output,
-                       blkid_loff_t offset, blkid_loff_t size)
+                       uint64_t offset, uint64_t size)
 {
        const char *data;
        const char *name;
@@ -848,8 +848,8 @@ int main(int argc, char **argv)
                for (i = 0; i < numdev; i++) {
                        err = lowprobe_device(pr, devices[i], lowprobe, show,
                                        output_format,
-                                       (blkid_loff_t) offset,
-                                       (blkid_loff_t) size);
+                                       (uint64_t) offset,
+                                       (uint64_t) size);
                        if (err)
                                break;
                }