Commit e5484d339114117920753c4045bed75510215862
1 parent
7674e7bf
BSD fix
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1413 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
1 changed file
with
6 additions
and
5 deletions
block.c
| @@ -548,6 +548,9 @@ static int raw_open(BlockDriverState *bs, const char *filename) | @@ -548,6 +548,9 @@ static int raw_open(BlockDriverState *bs, const char *filename) | ||
| 548 | BDRVRawState *s = bs->opaque; | 548 | BDRVRawState *s = bs->opaque; |
| 549 | int fd; | 549 | int fd; |
| 550 | int64_t size; | 550 | int64_t size; |
| 551 | +#ifdef _BSD | ||
| 552 | + struct stat sb; | ||
| 553 | +#endif | ||
| 551 | 554 | ||
| 552 | fd = open(filename, O_RDWR | O_BINARY | O_LARGEFILE); | 555 | fd = open(filename, O_RDWR | O_BINARY | O_LARGEFILE); |
| 553 | if (fd < 0) { | 556 | if (fd < 0) { |
| @@ -557,13 +560,11 @@ static int raw_open(BlockDriverState *bs, const char *filename) | @@ -557,13 +560,11 @@ static int raw_open(BlockDriverState *bs, const char *filename) | ||
| 557 | bs->read_only = 1; | 560 | bs->read_only = 1; |
| 558 | } | 561 | } |
| 559 | #ifdef _BSD | 562 | #ifdef _BSD |
| 560 | - { | ||
| 561 | - struct stat sb; | ||
| 562 | - if (!fstat(fd, &sb) && (S_IFCHR & sb.st_mode)) { | 563 | + if (!fstat(fd, &sb) && (S_IFCHR & sb.st_mode)) { |
| 563 | #ifdef DIOCGMEDIASIZE | 564 | #ifdef DIOCGMEDIASIZE |
| 564 | - if (ioctl(fd, DIOCGMEDIASIZE, (off_t *)&size)) | 565 | + if (ioctl(fd, DIOCGMEDIASIZE, (off_t *)&size)) |
| 565 | #endif | 566 | #endif |
| 566 | - size = lseek(fd, 0LL, SEEK_END); | 567 | + size = lseek(fd, 0LL, SEEK_END); |
| 567 | } else | 568 | } else |
| 568 | #endif | 569 | #endif |
| 569 | { | 570 | { |