svn commit: r313047 - in head/sys/boot: common i386/libi386 uboot/lib usb/storage zfs
Toomas Soome
tsoome at FreeBSD.org
Wed Feb 1 20:10:58 UTC 2017
Author: tsoome
Date: Wed Feb 1 20:10:56 2017
New Revision: 313047
URL: https://svnweb.freebsd.org/changeset/base/313047
Log:
loader: disk/part api needs to use uint64_t offsets
The disk_* and part_* api is using 64bit values for media size and
offsets. However, the current api is using off_t type, which is signed
64-bit int.
In this context the signed media size does not make any sense, and
the offsets are used to mark absolute, not relative locations.
Also, the data from GPT partition table and some other sources is
already using uint64_t data type, so using signed off_t can cause sign
issues.
Reviewed by: imp
Approved by: imp (mentor)
Differential Revision: https://reviews.freebsd.org/D8710
Modified:
head/sys/boot/common/disk.c
head/sys/boot/common/disk.h
head/sys/boot/common/part.c
head/sys/boot/common/part.h
head/sys/boot/i386/libi386/biosdisk.c
head/sys/boot/uboot/lib/disk.c
head/sys/boot/usb/storage/umass_loader.c
head/sys/boot/zfs/zfs.c
Modified: head/sys/boot/common/disk.c
==============================================================================
--- head/sys/boot/common/disk.c Wed Feb 1 19:36:33 2017 (r313046)
+++ head/sys/boot/common/disk.c Wed Feb 1 20:10:56 2017 (r313047)
@@ -45,7 +45,7 @@ __FBSDID("$FreeBSD$");
struct open_disk {
struct ptable *table;
- off_t mediasize;
+ uint64_t mediasize;
u_int sectorsize;
u_int flags;
int rcnt;
@@ -64,7 +64,7 @@ struct dentry {
int d_partition;
struct open_disk *od;
- off_t d_offset;
+ uint64_t d_offset;
STAILQ_ENTRY(dentry) entry;
#ifdef DISK_DEBUG
uint32_t count;
@@ -171,7 +171,7 @@ display_size(uint64_t size, u_int sector
}
int
-ptblread(void *d, void *buf, size_t blocks, off_t offset)
+ptblread(void *d, void *buf, size_t blocks, uint64_t offset)
{
struct disk_devdesc *dev;
struct open_disk *od;
@@ -238,7 +238,7 @@ disk_print(struct disk_devdesc *dev, cha
}
int
-disk_read(struct disk_devdesc *dev, void *buf, off_t offset, u_int blocks)
+disk_read(struct disk_devdesc *dev, void *buf, uint64_t offset, u_int blocks)
{
struct open_disk *od;
int ret;
@@ -251,7 +251,7 @@ disk_read(struct disk_devdesc *dev, void
}
int
-disk_write(struct disk_devdesc *dev, void *buf, off_t offset, u_int blocks)
+disk_write(struct disk_devdesc *dev, void *buf, uint64_t offset, u_int blocks)
{
struct open_disk *od;
int ret;
@@ -274,7 +274,7 @@ disk_ioctl(struct disk_devdesc *dev, u_l
}
int
-disk_open(struct disk_devdesc *dev, off_t mediasize, u_int sectorsize,
+disk_open(struct disk_devdesc *dev, uint64_t mediasize, u_int sectorsize,
u_int flags)
{
struct open_disk *od;
Modified: head/sys/boot/common/disk.h
==============================================================================
--- head/sys/boot/common/disk.h Wed Feb 1 19:36:33 2017 (r313046)
+++ head/sys/boot/common/disk.h Wed Feb 1 20:10:56 2017 (r313047)
@@ -86,7 +86,7 @@ struct disk_devdesc
void *d_opendata;
int d_slice;
int d_partition;
- off_t d_offset;
+ uint64_t d_offset;
};
enum disk_ioctl {
@@ -97,17 +97,17 @@ enum disk_ioctl {
/*
* Parse disk metadata and initialise dev->d_offset.
*/
-extern int disk_open(struct disk_devdesc *dev, off_t mediasize,
+extern int disk_open(struct disk_devdesc *dev, uint64_t mediasize,
u_int sectorsize, u_int flags);
#define DISK_F_NOCACHE 0x0001 /* Do not use metadata caching */
extern int disk_close(struct disk_devdesc *dev);
extern void disk_cleanup(const struct devsw *d_dev);
extern int disk_ioctl(struct disk_devdesc *dev, u_long cmd, void *buf);
-extern int disk_read(struct disk_devdesc *dev, void *buf, off_t offset,
+extern int disk_read(struct disk_devdesc *dev, void *buf, uint64_t offset,
u_int blocks);
-extern int disk_write(struct disk_devdesc *dev, void *buf, off_t offset,
+extern int disk_write(struct disk_devdesc *dev, void *buf, uint64_t offset,
u_int blocks);
-extern int ptblread(void *d, void *buf, size_t blocks, off_t offset);
+extern int ptblread(void *d, void *buf, size_t blocks, uint64_t offset);
/*
* Print information about slices on a disk.
Modified: head/sys/boot/common/part.c
==============================================================================
--- head/sys/boot/common/part.c Wed Feb 1 19:36:33 2017 (r313046)
+++ head/sys/boot/common/part.c Wed Feb 1 20:10:56 2017 (r313047)
@@ -584,7 +584,7 @@ out:
#endif /* LOADER_VTOC8_SUPPORT */
struct ptable*
-ptable_open(void *dev, off_t sectors, uint16_t sectorsize,
+ptable_open(void *dev, uint64_t sectors, uint16_t sectorsize,
diskread_t *dread)
{
struct dos_partition *dp;
Modified: head/sys/boot/common/part.h
==============================================================================
--- head/sys/boot/common/part.h Wed Feb 1 19:36:33 2017 (r313046)
+++ head/sys/boot/common/part.h Wed Feb 1 20:10:56 2017 (r313047)
@@ -62,11 +62,11 @@ struct ptable_entry {
};
/* The offset and size are in sectors */
-typedef int (diskread_t)(void *arg, void *buf, size_t blocks, off_t offset);
+typedef int (diskread_t)(void *arg, void *buf, size_t blocks, uint64_t offset);
typedef int (ptable_iterate_t)(void *arg, const char *partname,
const struct ptable_entry *part);
-struct ptable *ptable_open(void *dev, off_t sectors, uint16_t sectorsize,
+struct ptable *ptable_open(void *dev, uint64_t sectors, uint16_t sectorsize,
diskread_t *dread);
void ptable_close(struct ptable *table);
enum ptable_type ptable_gettype(const struct ptable *table);
Modified: head/sys/boot/i386/libi386/biosdisk.c
==============================================================================
--- head/sys/boot/i386/libi386/biosdisk.c Wed Feb 1 19:36:33 2017 (r313046)
+++ head/sys/boot/i386/libi386/biosdisk.c Wed Feb 1 20:10:56 2017 (r313047)
@@ -493,7 +493,7 @@ bd_ioctl(struct open_file *f, u_long cmd
*(u_int *)data = BD(dev).bd_sectorsize;
break;
case DIOCGMEDIASIZE:
- *(off_t *)data = BD(dev).bd_sectors * BD(dev).bd_sectorsize;
+ *(uint64_t *)data = BD(dev).bd_sectors * BD(dev).bd_sectorsize;
break;
default:
return (ENOTTY);
Modified: head/sys/boot/uboot/lib/disk.c
==============================================================================
--- head/sys/boot/uboot/lib/disk.c Wed Feb 1 19:36:33 2017 (r313046)
+++ head/sys/boot/uboot/lib/disk.c Wed Feb 1 20:10:56 2017 (r313047)
@@ -282,7 +282,7 @@ stor_ioctl(struct open_file *f, u_long c
*(u_int *)data = SI(dev).bsize;
break;
case DIOCGMEDIASIZE:
- *(off_t *)data = SI(dev).bsize * SI(dev).blocks;
+ *(uint64_t *)data = SI(dev).bsize * SI(dev).blocks;
break;
default:
return (ENOTTY);
Modified: head/sys/boot/usb/storage/umass_loader.c
==============================================================================
--- head/sys/boot/usb/storage/umass_loader.c Wed Feb 1 19:36:33 2017 (r313046)
+++ head/sys/boot/usb/storage/umass_loader.c Wed Feb 1 20:10:56 2017 (r313047)
@@ -143,14 +143,14 @@ umass_disk_ioctl(struct open_file *f __u
uint32_t blocksize;
switch (cmd) {
- case IOCTL_GET_BLOCK_SIZE:
- case IOCTL_GET_BLOCKS:
+ case DIOCGSECTORSIZE:
+ case DIOCGMEDIASIZE:
if (usb_msc_read_capacity(umass_uaa.device, 0,
&nblock, &blocksize) != 0)
return (EINVAL);
- if (cmd == IOCTL_GET_BLOCKS)
- *(uint32_t*)buf = nblock;
+ if (cmd == DIOCGMEDIASIZE)
+ *(uint64_t*)buf = nblock;
else
*(uint32_t*)buf = blocksize;
Modified: head/sys/boot/zfs/zfs.c
==============================================================================
--- head/sys/boot/zfs/zfs.c Wed Feb 1 19:36:33 2017 (r313046)
+++ head/sys/boot/zfs/zfs.c Wed Feb 1 20:10:56 2017 (r313047)
@@ -417,7 +417,7 @@ struct zfs_probe_args {
};
static int
-zfs_diskread(void *arg, void *buf, size_t blocks, off_t offset)
+zfs_diskread(void *arg, void *buf, size_t blocks, uint64_t offset)
{
struct zfs_probe_args *ppa;
More information about the svn-src-all
mailing list