Index: qemu/qemu-mkcow.c @@ -21,6 +21,8 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ +#include "config-host.h" + #include #include #include @@ -36,6 +38,13 @@ #include #include +#ifdef _BSD +#include +#include +#include +#include +#endif + #include "cow.h" #include "bswap.h" @@ -56,6 +64,15 @@ int cow_create(int cow_fd, const char *i perror(image_filename); exit(1); } +#ifdef _BSD + struct stat sb; + if (!fstat(fd,&sb) && (S_IFCHR & sb.st_mode)) { +#ifdef DIOCGMEDIASIZE + if (ioctl(fd, DIOCGMEDIASIZE, (off_t *)&image_sectors)) +#endif + image_sectors = lseek(fd, 0LL, SEEK_END); + } else +#endif image_sectors = lseek64(fd, 0, SEEK_END); if (fstat(fd, &st) != 0) { close(fd);