lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-Id: <1329788890-26351-1-git-send-email-tytso@mit.edu>
Date:	Mon, 20 Feb 2012 20:48:10 -0500
From:	Theodore Ts'o <tytso@....edu>
To:	Ext4 Developers List <linux-ext4@...r.kernel.org>
Cc:	Theodore Ts'o <tytso@....edu>
Subject: [PATCH] libext2fs: support O_DIRECT functionality for Mac OS X

Darwin uses fcntl(fd, F_NOCACHE, 1) instead of the O_DIRECT flag.

Addresses-SourceForge-Bug: #3140289

Signed-off-by: "Theodore Ts'o" <tytso@....edu>
---
 lib/ext2fs/unix_io.c |   12 +++++++++++-
 1 files changed, 11 insertions(+), 1 deletions(-)

diff --git a/lib/ext2fs/unix_io.c b/lib/ext2fs/unix_io.c
index 5337022..9f0613a 100644
--- a/lib/ext2fs/unix_io.c
+++ b/lib/ext2fs/unix_io.c
@@ -445,6 +445,7 @@ static errcode_t unix_open(const char *name, int flags, io_channel *channel)
 	struct unix_private_data *data = NULL;
 	errcode_t	retval;
 	int		open_flags, zeroes = 0;
+	int		f_nocache = 0;
 	ext2fs_struct_stat st;
 #ifdef __linux__
 	struct 		utsname ut;
@@ -480,9 +481,12 @@ static errcode_t unix_open(const char *name, int flags, io_channel *channel)
 	open_flags = (flags & IO_FLAG_RW) ? O_RDWR : O_RDONLY;
 	if (flags & IO_FLAG_EXCLUSIVE)
 		open_flags |= O_EXCL;
-#ifdef O_DIRECT
+#if defined(O_DIRECT)
 	if (flags & IO_FLAG_DIRECT_IO)
 		open_flags |= O_DIRECT;
+#elif defined(F_NOCACHE)
+	if (flags & IO_FLAG_DIRECT_IO)
+		f_nocache = F_NOCACHE;
 #endif
 	data->flags = flags;
 
@@ -491,6 +495,12 @@ static errcode_t unix_open(const char *name, int flags, io_channel *channel)
 		retval = errno;
 		goto cleanup;
 	}
+	if (f_nocache) {
+		if (fcntl(data->dev, f_nocache, 1) < 0) {
+			retval = errno;
+			goto cleanup;
+		}
+	}
 
 	/*
 	 * If the device is really a block device, then set the
-- 
1.7.9.107.g97f9a

--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ