* %End-Header%
*/
+#ifndef _LARGEFILE_SOURCE
#define _LARGEFILE_SOURCE
+#endif
+#ifndef _LARGEFILE64_SOURCE
#define _LARGEFILE64_SOURCE
+#endif
#include "config.h"
#include <stdio.h>
#include <errno.h>
#endif
#include <fcntl.h>
+#ifdef HAVE_SYS_DISK_H
+#include <sys/disk.h>
+#endif
#ifdef HAVE_LINUX_FD_H
#include <sys/ioctl.h>
#include <linux/fd.h>
return 0;
}
#endif
+#ifdef DIOCGSECTORSIZE
+ if (ioctl(fd, DIOCGSECTORSIZE, sectsize) >= 0) {
+ close(fd);
+ return 0;
+ }
+#endif
*sectsize = 0;
close(fd);
return 0;
if (ioctl(fd, BLKSSZGET, &align) < 0)
align = 0;
#endif
+#ifdef DIOCGSECTORSIZE
+ if (align <= 0 &&
+ ioctl(fd, DIOCGSECTORSIZE, &align) < 0)
+ align = 0;
+#endif
#ifdef _SC_PAGESIZE
if (align <= 0)
return 0;
}
#endif
+#ifdef DIOCGSECTORSIZE
+ /* This isn't really the physical sector size, but FreeBSD
+ * doesn't seem to have this concept. */
+ if (ioctl(fd, DIOCGSECTORSIZE, sectsize) >= 0) {
+ close(fd);
+ return 0;
+ }
+#endif
*sectsize = 0;
close(fd);
return 0;