mirror of
https://github.com/xen-project/xen.git
synced 2026-10-29 10:40:03 +01:00
- Use standard off_t and lseek() instead of non-portable off64_t and lseek64() - Use uuid API as documented in DCE 1.1 RPC specification - Add NetBSD implementation for blk_getimagesize() and blk_getsectorsize() - Use blk_getimagesize() and blk_getsectorsize() - Fix uuid header check Signed-off-by: Christoph Egger <Christoph.Egger@amd.com> Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
42 lines
729 B
C
42 lines
729 B
C
#include <sys/param.h>
|
|
#include <sys/ioctl.h>
|
|
#include <sys/disklabel.h>
|
|
#include <errno.h>
|
|
#include <inttypes.h>
|
|
#include "tapdisk.h"
|
|
#include "blk.h"
|
|
|
|
int blk_getimagesize(int fd, uint64_t *size)
|
|
{
|
|
int rc;
|
|
struct disklabel dl;
|
|
|
|
*size = 0;
|
|
rc = ioctl(fd, DIOCGDINFO, &dl);
|
|
if (rc) {
|
|
DPRINTF("ERR: DIOCGDINFO failed, couldn't stat image");
|
|
return -EINVAL;
|
|
}
|
|
|
|
*size = dl.d_secsize * dl.d_secpercyl;
|
|
|
|
return 0;
|
|
}
|
|
|
|
int blk_getsectorsize(int fd, uint64_t *sector_size)
|
|
{
|
|
int rc;
|
|
struct disklabel dl;
|
|
|
|
*sector_size = DEV_BSIZE;
|
|
rc = ioctl(fd, DIOCGDINFO, &dl);
|
|
if (rc) {
|
|
DPRINTF("ERR: DIOCGDINFO failed, couldn't stat image");
|
|
return 0; /* fallback to DEV_BSIZE */
|
|
}
|
|
|
|
*sector_size = dl.d_secsize;
|
|
return 0;
|
|
}
|
|
|