From mboxrd@z Thu Jan 1 00:00:00 1970 From: Al Boldi Subject: Re: FILE_FLAG_WRITE_THROUGH Date: Wed, 5 Apr 2006 16:43:06 +0300 Message-ID: <200604051643.06825.a1426z@gawab.com> References: <4432B296.8050408@gmail.com> <17459.16716.938764.154497@cerise.gclements.plus.com> <6a00c8d50604050031w3b30032bm73cefeab84119024@mail.gmail.com> Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <6a00c8d50604050031w3b30032bm73cefeab84119024@mail.gmail.com> Content-Disposition: inline Sender: linux-c-programming-owner@vger.kernel.org List-Id: Content-Type: text/plain; charset="us-ascii" To: linux-c-programming@vger.kernel.org Steve Graegert wrote: > On 4/5/06, Glynn Clements wrote: > > Rebelde wrote: > > > On Windows XP I can write directly to disk whitout cache write using > > > the CreateFile function with FILE_FLAG_WRITE_THROUGH. Could someone > > > tell me how to make this on Linux? > > > > Pass the O_SYNC flag to open(). This will cause write() calls to block > > until the data has been sent to the drive. > > > > The O_DIRECT flag suggested by Steve is probably overkill. It requires > > that the buffer start address, buffer size and file offset are all > > multiples of the filesystem's block size, and only works on some > > filesystems. > > Well, the O_SYNC flag causes, i.e. write(2), to block until the data > has been physically written to disk, but it does not prevent the C > library/kernel from caching the bytes. O_DIRECT, on the other hand, > circumvents the caching mechanisms and allows for raw access, although > it may degrade performance. Or increase performance because dcache costs dear cpu-cycles? Thanks! -- Al