head 1.2; access; symbols pkgsrc-2016Q4:1.1.0.46 pkgsrc-2016Q4-base:1.1 pkgsrc-2016Q3:1.1.0.44 pkgsrc-2016Q3-base:1.1 pkgsrc-2016Q2:1.1.0.42 pkgsrc-2016Q2-base:1.1 pkgsrc-2016Q1:1.1.0.40 pkgsrc-2016Q1-base:1.1 pkgsrc-2015Q4:1.1.0.38 pkgsrc-2015Q4-base:1.1 pkgsrc-2015Q3:1.1.0.36 pkgsrc-2015Q3-base:1.1 pkgsrc-2015Q2:1.1.0.34 pkgsrc-2015Q2-base:1.1 pkgsrc-2015Q1:1.1.0.32 pkgsrc-2015Q1-base:1.1 pkgsrc-2014Q4:1.1.0.30 pkgsrc-2014Q4-base:1.1 pkgsrc-2014Q3:1.1.0.28 pkgsrc-2014Q3-base:1.1 pkgsrc-2014Q2:1.1.0.26 pkgsrc-2014Q2-base:1.1 pkgsrc-2014Q1:1.1.0.24 pkgsrc-2014Q1-base:1.1 pkgsrc-2013Q4:1.1.0.22 pkgsrc-2013Q4-base:1.1 pkgsrc-2013Q3:1.1.0.20 pkgsrc-2013Q3-base:1.1 pkgsrc-2013Q2:1.1.0.18 pkgsrc-2013Q2-base:1.1 pkgsrc-2013Q1:1.1.0.16 pkgsrc-2013Q1-base:1.1 pkgsrc-2012Q4:1.1.0.14 pkgsrc-2012Q4-base:1.1 pkgsrc-2012Q3:1.1.0.12 pkgsrc-2012Q3-base:1.1 pkgsrc-2012Q2:1.1.0.10 pkgsrc-2012Q2-base:1.1 pkgsrc-2012Q1:1.1.0.8 pkgsrc-2012Q1-base:1.1 pkgsrc-2011Q4:1.1.0.6 pkgsrc-2011Q4-base:1.1 pkgsrc-2011Q3:1.1.0.4 pkgsrc-2011Q3-base:1.1 pkgsrc-2011Q2:1.1.0.2 pkgsrc-2011Q2-base:1.1; locks; strict; comment @# @; 1.2 date 2016.12.29.19.13.03; author wiz; state dead; branches; next 1.1; commitid kFYPk8EnajcmFUzz; 1.1 date 2011.05.20.17.09.21; author bouyer; state Exp; branches; next ; desc @@ 1.2 log @Remove xenkernel and tools versions 3, 33, and 41. As discussed on pkgsrc-users. @ text @$NetBSD: patch-qemu-phy-devices,v 1.1 2011/05/20 17:09:21 bouyer Exp $ This does 2 things: - use the correct way to get the size of a disk device or partition (from haad@@NetBSD.org) - if given a block device, use the character device instead. --- ioemu/block-raw.c.orig 2009-08-06 14:56:33.000000000 +0200 +++ ioemu/block-raw.c 2011-05-20 18:55:59.000000000 +0200 @@@@ -63,6 +63,13 @@@@ #include #include #endif +#if defined(__NetBSD__) +#include +#include +#include +#include +#include +#endif //#define DEBUG_FLOPPY @@@@ -101,6 +108,33 @@@@ { BDRVRawState *s = bs->opaque; int fd, open_flags, ret; +#ifdef __NetBSD__ + struct stat sb; + static char namebuf[MAXPATHLEN]; + const char *dp; + + if (lstat(filename, &sb) < 0) { + fprintf(stderr, "%s: stat failed: %s\n", filename, strerror(errno)); + return -errno; + } + if (S_ISLNK(sb.st_mode)) { + fprintf(stderr, "%s: symolink links not supported by qemu-dm\n", + filename); + return -EINVAL; + } + if (S_ISBLK(sb.st_mode)) { + dp = strrchr(filename, '/'); + if (dp == NULL) { + snprintf(namebuf, MAXPATHLEN, "r%s", filename); + } else { + snprintf(namebuf, MAXPATHLEN, "%.*s/r%s", + (int)(dp - filename), filename, dp + 1); + } + fprintf(stderr, "%s is a block device", filename); + filename = namebuf; + fprintf(stderr, ", using %s\n", filename); + } +#endif s->lseek_err_cnt = 0; @@@@ -533,7 +567,7 @@@@ return 0; } -#ifdef __OpenBSD__ +#if defined(__OpenBSD__) || defined(__NetBSD__) static int64_t raw_getlength(BlockDriverState *bs) { int fd = ((BDRVRawState*)bs->opaque)->fd; @@@@ -541,11 +575,24 @@@@ if(fstat(fd, &st)) return -1; if(S_ISCHR(st.st_mode) || S_ISBLK(st.st_mode)){ +#ifdef __OpenBSD__ struct disklabel dl; if(ioctl(fd, DIOCGDINFO, &dl)) return -1; return (uint64_t)dl.d_secsize * dl.d_partitions[DISKPART(st.st_rdev)].p_size; +#else + struct dkwedge_info dkw; + if (ioctl(fd, DIOCGWEDGEINFO, &dkw) != -1) { + return dkw.dkw_size * 512; + } else { + struct disklabel dl; + if(ioctl(fd, DIOCGDINFO, &dl)) + return -1; + return (uint64_t)dl.d_secsize * + dl.d_partitions[DISKPART(st.st_rdev)].p_size; + } +#endif }else return st.st_size; } @ 1.1 log @Add a patch which fixes 2 problems: - use the correct way to get the size of a disk device or partition (from haad@@NetBSD.org) - if given a block device, use the character device instead (the block device is already in use by the backend driver). With this I could succeffully boot a HVMPV FreeBSD kernel using a phy: virtual disk. @ text @d1 1 a1 1 $NetBSD: $ @