unreliable in Linux 2.4. (Addresses Debian Bug #236528).
Fix typo in the ioctl used for Mac OS X.
+2004-03-08 Theodore Ts'o <tytso@mit.edu>
+
+ * getsize.c (blkid_get_dev_size): Only use the BLKGETSIZE64 ioctl
+ on Linux 2.6 since it is unreliable in Linux 2.4..
+ (Addresses Debian Bug #236528) Fix typo in the ioctl used
+ for Mac OS X.
+
2004-03-04 Theodore Ts'o <tytso@mit.edu>
* probe.c (probe_ocfs), probe.h: Add support for the Oracle
#include <sys/disklabel.h>
#include <sys/stat.h>
#endif /* HAVE_SYS_DISKLABEL_H */
+#ifdef __linux__
+#include <sys/utsname.h>
+#endif
#include "blkidP.h"
*/
blkid_loff_t blkid_get_dev_size(int fd)
{
+ int valid_blkgetsize64 = 1;
+#ifdef __linux__
+ struct utsname ut;
+#endif
unsigned long long size64;
unsigned long size;
blkid_loff_t high, low;
#endif /* HAVE_SYS_DISKLABEL_H */
#ifdef DKIOCGETBLOCKCOUNT /* For Apple Darwin */
- if (ioctl(fd, BLKGETSIZE64, &size64) >= 0) {
+ if (ioctl(fd, DKIOCGETBLOCKCOUNT, &size64) >= 0) {
if ((sizeof(blkid_loff_t) < sizeof(unsigned long long))
&& ((size64 / (blocksize / 512)) > 0xFFFFFFFF))
return 0; /* EFBIG */
#endif
#ifdef BLKGETSIZE64
- if (ioctl(fd, BLKGETSIZE64, &size64) >= 0) {
+#ifdef __linux__
+ if ((uname(&ut) == 0) &&
+ ((ut.release[0] == '2') && (ut.release[1] == '.') &&
+ (ut.release[2] < '6') && (ut.release[3] == '.')))
+ valid_blkgetsize64 = 0;
+#endif
+ if (valid_blkgetsize64 &&
+ ioctl(fd, BLKGETSIZE64, &size64) >= 0) {
if ((sizeof(blkid_loff_t) < sizeof(unsigned long long))
&& ((size64) > 0xFFFFFFFF))
return 0; /* EFBIG */
+2004-03-08 Theodore Ts'o <tytso@mit.edu>
+
+ * getsize.c (ext2fs_get_device_size): Only use the BLKGETSIZE64
+ ioctl on Linux 2.6 since it is unreliable in Linux 2.4.
+ (Addresses Debian Bug #236528). Fix typo in the ioctl
+ used for Mac OS X.
+
2004-03-02 Theodore Ts'o <tytso@mit.edu>
* getsize.c (ext2fs_get_device_size): Update getsize functions to
#include <sys/queue.h> /* for LIST_HEAD */
#include <sys/disk.h>
#endif /* HAVE_SYS_DISK_H */
+#ifdef __linux__
+#include <sys/utsname.h>
+#endif
#if defined(__linux__) && defined(_IO) && !defined(BLKGETSIZE)
#define BLKGETSIZE _IO(0x12,96) /* return device size */
blk_t *retblocks)
{
int fd;
+ int valid_blkgetsize64 = 1;
+#ifdef __linux__
+ struct utsname ut;
+#endif
unsigned long long size64;
unsigned long size;
ext2_loff_t high, low;
return errno;
#ifdef DKIOCGETBLOCKCOUNT /* For Apple Darwin */
- if (ioctl(fd, BLKGETSIZE64, &size64) >= 0) {
+ if (ioctl(fd, DKIOCGETBLOCKCOUNT, &size64) >= 0) {
if ((sizeof(*retblocks) < sizeof(unsigned long long))
&& ((size64 / (blocksize / 512)) > 0xFFFFFFFF))
return EFBIG;
#endif
#ifdef BLKGETSIZE64
- if (ioctl(fd, BLKGETSIZE64, &size64) >= 0) {
+#ifdef __linux__
+ if ((uname(&ut) == 0) &&
+ ((ut.release[0] == '2') && (ut.release[1] == '.') &&
+ (ut.release[2] < '6') && (ut.release[3] == '.')))
+ valid_blkgetsize64 = 0;
+#endif
+ if (valid_blkgetsize64 &&
+ ioctl(fd, BLKGETSIZE64, &size64) >= 0) {
if ((sizeof(*retblocks) < sizeof(unsigned long long))
&& ((size64 / blocksize) > 0xFFFFFFFF))
return EFBIG;