#include <sys/processor.h>
#include <sys/zfs_context.h>
#include <sys/utsname.h>
+#include <sys/time.h>
+#include <sys/mount.h> /* for BLKGETSIZE64 */
#include <sys/systeminfo.h>
/*
* for its size. So -- gag -- we open the block device to get
* its size, and remember it for subsequent VOP_GETATTR().
*/
+#if defined(__sun__) || defined(__sun)
if (strncmp(path, "/dev/", 5) == 0) {
+#else
+ if (0) {
+#endif
char *dsk;
fd = open64(path, O_RDONLY);
if (fd == -1) {
}
}
+ if (!(flags & FCREAT) && S_ISBLK(st.st_mode)) {
+#ifdef __linux__
+ flags |= O_DIRECT;
+#endif
+ /* We shouldn't be writing to block devices in userspace */
+ VERIFY(!(flags & FWRITE));
+ }
+
if (flags & FCREAT)
old_umask = umask(0);
return (err);
}
+#ifdef __linux__
+ /* In Linux, use an ioctl to get the size of a block device. */
+ if (S_ISBLK(st.st_mode)) {
+ if (ioctl(fd, BLKGETSIZE64, &st.st_size) != 0) {
+ err = errno;
+ close(fd);
+ return (err);
+ }
+ }
+#endif
(void) fcntl(fd, F_SETFD, FD_CLOEXEC);
*vpp = vp = umem_zalloc(sizeof (vnode_t), UMEM_NOFAIL);
}
}
+#ifdef __linux__
+ if (rc == -1 && errno == EINVAL) {
+ /*
+ * Under Linux, this most likely means an alignment issue
+ * (memory or disk) due to O_DIRECT, so we abort() in order to
+ * catch the offender.
+ */
+ abort();
+ }
+#endif
if (rc == -1)
return (errno);