548 |
BDRVRawState *s = bs->opaque; |
BDRVRawState *s = bs->opaque; |
549 |
int fd; |
int fd; |
550 |
int64_t size; |
int64_t size; |
551 |
|
#ifdef _BSD |
552 |
|
struct stat sb; |
553 |
|
#endif |
554 |
|
|
555 |
fd = open(filename, O_RDWR | O_BINARY | O_LARGEFILE); |
fd = open(filename, O_RDWR | O_BINARY | O_LARGEFILE); |
556 |
if (fd < 0) { |
if (fd < 0) { |
560 |
bs->read_only = 1; |
bs->read_only = 1; |
561 |
} |
} |
562 |
#ifdef _BSD |
#ifdef _BSD |
563 |
{ |
if (!fstat(fd, &sb) && (S_IFCHR & sb.st_mode)) { |
|
struct stat sb; |
|
|
if (!fstat(fd, &sb) && (S_IFCHR & sb.st_mode)) { |
|
564 |
#ifdef DIOCGMEDIASIZE |
#ifdef DIOCGMEDIASIZE |
565 |
if (ioctl(fd, DIOCGMEDIASIZE, (off_t *)&size)) |
if (ioctl(fd, DIOCGMEDIASIZE, (off_t *)&size)) |
566 |
#endif |
#endif |
567 |
size = lseek(fd, 0LL, SEEK_END); |
size = lseek(fd, 0LL, SEEK_END); |
568 |
} else |
} else |
569 |
#endif |
#endif |
570 |
{ |
{ |