Commit e5484d339114117920753c4045bed75510215862

Authored by bellard
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
... ... @@ -548,6 +548,9 @@ static int raw_open(BlockDriverState *bs, const char *filename)
548 548 BDRVRawState *s = bs->opaque;
549 549 int fd;
550 550 int64_t size;
  551 +#ifdef _BSD
  552 + struct stat sb;
  553 +#endif
551 554  
552 555 fd = open(filename, O_RDWR | O_BINARY | O_LARGEFILE);
553 556 if (fd < 0) {
... ... @@ -557,13 +560,11 @@ static int raw_open(BlockDriverState *bs, const char *filename)
557 560 bs->read_only = 1;
558 561 }
559 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 564 #ifdef DIOCGMEDIASIZE
564   - if (ioctl(fd, DIOCGMEDIASIZE, (off_t *)&size))
  565 + if (ioctl(fd, DIOCGMEDIASIZE, (off_t *)&size))
565 566 #endif
566   - size = lseek(fd, 0LL, SEEK_END);
  567 + size = lseek(fd, 0LL, SEEK_END);
567 568 } else
568 569 #endif
569 570 {
... ...