d870f0e26e
guests operating systems on a single machine. Guest OSes (also called "domains") require a modified kernel which supports Xen hypercalls in replacement to access to the physical hardware. At boot, the xen kernel is loaded along with the guest kernel for the first domain (called domain0). domain0 has privileges to access the physical hardware (PCI and ISA devices), administrate other domains and provide virtual devices (disks and network) to other domains. xenkernel45 and xentools45 contains the kernel and tools from the Xen 4.5.x branch
38 lines
686 B
C
38 lines
686 B
C
#include <inttypes.h>
|
|
#include <sys/ioctl.h>
|
|
#include <sys/disklabel.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;
|
|
}
|