diff --git a/block.c b/block.c index cbe07a9d8f6035edd060f2c1d0d54284ae8b598c..ce1c388b972595399061044defe2c3c037388d95 100644 --- a/block.c +++ b/block.c @@ -548,6 +548,9 @@ static int raw_open(BlockDriverState *bs, const char *filename) BDRVRawState *s = bs->opaque; int fd; int64_t size; +#ifdef _BSD + struct stat sb; +#endif fd = open(filename, O_RDWR | O_BINARY | O_LARGEFILE); if (fd < 0) { @@ -557,13 +560,11 @@ static int raw_open(BlockDriverState *bs, const char *filename) bs->read_only = 1; } #ifdef _BSD - { - struct stat sb; - if (!fstat(fd, &sb) && (S_IFCHR & sb.st_mode)) { + if (!fstat(fd, &sb) && (S_IFCHR & sb.st_mode)) { #ifdef DIOCGMEDIASIZE - if (ioctl(fd, DIOCGMEDIASIZE, (off_t *)&size)) + if (ioctl(fd, DIOCGMEDIASIZE, (off_t *)&size)) #endif - size = lseek(fd, 0LL, SEEK_END); + size = lseek(fd, 0LL, SEEK_END); } else #endif {