Enabled block device size recognition with sg-libcdio on Linux

This commit is contained in:
Thomas Schmitt 2010-01-01 12:43:15 +00:00
parent ed972271ec
commit 758a197d06
2 changed files with 11 additions and 3 deletions

View File

@ -1 +1 @@
#define Cdrskin_timestamP "2010.01.01.124042" #define Cdrskin_timestamP "2010.01.01.124415"

View File

@ -98,6 +98,11 @@ Send feedback to libburn-hackers@pykix.org .
#include <sys/statvfs.h> #include <sys/statvfs.h>
#endif /* Libburn_os_has_stavtfS */ #endif /* Libburn_os_has_stavtfS */
#ifdef __linux
/* for ioctl(BLKGETSIZE) */
#include <sys/ioctl.h>
#include <linux/fs.h>
#endif
#include <cdio/cdio.h> #include <cdio/cdio.h>
#include <cdio/logging.h> #include <cdio/logging.h>
@ -710,9 +715,12 @@ int burn_os_stdio_capacity(char *path, off_t *bytes)
if (stat(testpath, &stbuf) == -1) if (stat(testpath, &stbuf) == -1)
return -1; return -1;
#ifdef Libburn_if_this_was_linuX #ifdef __linux
/* Linux specific determination of block device size */
} else if(S_ISBLK(stbuf.st_mode)) { } else if(S_ISBLK(stbuf.st_mode)) {
int open_mode = O_RDONLY, fd, ret;
fd = open(path, open_mode); fd = open(path, open_mode);
if (fd == -1) if (fd == -1)
return -2; return -2;
@ -722,7 +730,7 @@ int burn_os_stdio_capacity(char *path, off_t *bytes)
return -2; return -2;
*bytes = ((off_t) blocks) * (off_t) 512; *bytes = ((off_t) blocks) * (off_t) 512;
#endif /* Libburn_if_this_was_linuX */ #endif /* __linux */
} else if(S_ISREG(stbuf.st_mode)) { } else if(S_ISREG(stbuf.st_mode)) {
add_size = stbuf.st_blocks * (off_t) 512; add_size = stbuf.st_blocks * (off_t) 512;