partitions: Make 64bit capable
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This commit is contained in:
parent
aece3fb42c
commit
cfcfc66d54
|
@ -42,23 +42,6 @@ struct partition_desc {
|
|||
struct partition parts[8];
|
||||
};
|
||||
|
||||
/**
|
||||
* Reject values which cannot be used in Barebox
|
||||
* @param val Value to be check
|
||||
* @return 0 if value can be used in Barebox, -EINVAL if not
|
||||
*
|
||||
* @note this routine can be removed when Barebox uses file offsets larger
|
||||
* than 32 bit
|
||||
*/
|
||||
static int check_offset_value(uint64_t val)
|
||||
{
|
||||
#if 1 /* until Barebox can handle 64 bit offsets */
|
||||
if (val > (__INT_MAX__ / SECTOR_SIZE))
|
||||
return -EINVAL;
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Guess the size of the disk, based on the partition table entries
|
||||
* @param dev device to create partitions for
|
||||
|
@ -76,12 +59,6 @@ static int disk_guess_size(struct device_d *dev, struct partition_entry *table)
|
|||
size += get_unaligned(&table[i].partition_size);
|
||||
}
|
||||
}
|
||||
/* limit disk sector counts we can't handle due to 32 bit limits */
|
||||
if (check_offset_value(size) != 0) {
|
||||
dev_warn(dev, "Warning: Sector count limited due to 31 bit"
|
||||
"contraints\n");
|
||||
size = __INT_MAX__ / SECTOR_SIZE;
|
||||
}
|
||||
|
||||
return (int)size;
|
||||
}
|
||||
|
@ -126,12 +103,6 @@ static void __maybe_unused try_dos_partition(struct block_device *blk,
|
|||
pentry.first_sec = get_unaligned(&table[i].partition_start);
|
||||
pentry.size = get_unaligned(&table[i].partition_size);
|
||||
|
||||
/* do we have to ignore this partition due to limitations? */
|
||||
if (check_offset_value(pentry.first_sec) != 0)
|
||||
continue;
|
||||
if (check_offset_value(pentry.size) != 0)
|
||||
continue;
|
||||
|
||||
if (pentry.first_sec != 0) {
|
||||
pd->parts[pd->used_entries].first_sec = pentry.first_sec;
|
||||
pd->parts[pd->used_entries].size = pentry.size;
|
||||
|
|
|
@ -227,7 +227,7 @@ int devfs_remove(struct cdev *cdev)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int devfs_add_partition(const char *devname, unsigned long offset, size_t size,
|
||||
int devfs_add_partition(const char *devname, loff_t offset, loff_t size,
|
||||
int flags, const char *name)
|
||||
{
|
||||
struct cdev *cdev, *new;
|
||||
|
|
|
@ -418,7 +418,7 @@ int cdev_erase(struct cdev *cdev, size_t count, loff_t offset);
|
|||
#define DEVFS_PARTITION_READONLY (1 << 1)
|
||||
#define DEVFS_IS_PARTITION (1 << 2)
|
||||
|
||||
int devfs_add_partition(const char *devname, unsigned long offset, size_t size,
|
||||
int devfs_add_partition(const char *devname, loff_t offset, loff_t size,
|
||||
int flags, const char *name);
|
||||
int devfs_del_partition(const char *name);
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ struct partition {
|
|||
|
||||
int flags;
|
||||
|
||||
unsigned long offset;
|
||||
loff_t offset;
|
||||
|
||||
struct device_d *physdev;
|
||||
struct device_d device;
|
||||
|
|
Loading…
Reference in New Issue