*BSD News Article 70565


Return to BSD News archive

Path: euryale.cc.adfa.oz.au!newshost.anu.edu.au!harbinger.cc.monash.edu.au!news.rmit.EDU.AU!news.unimelb.EDU.AU!munnari.OZ.AU!news.hawaii.edu!news.uoregon.edu!arclight.uoregon.edu!dispatch.news.demon.net!demon!microl4.microlise.UUCP!news
From: andrewg@microlise.co.uk   (Andrew Gierth)
Newsgroups: comp.unix.programmer,comp.os.linux.development.apps,comp.unix.solaris,comp.unix.bsd
Subject: Re: How to flush write buffer ?
Date: 10 Jun 1996 04:16:59 GMT
Organization: Microlise Engineering Ltd.
Lines: 41
Message-ID: <4pg7jr$3ni@microl4.microlise.UUCP>
References: <4pg43b$hru@samba.rahul.net>
Reply-To: andrewg@microlise.co.uk  (Andrew Gierth)
NNTP-Posting-Host: andrewg.microlise.uucp
X-NNTP-Posting-Host: microl.demon.co.uk
X-Newsreader: IBM NewsReader/2 v1.2
Xref: euryale.cc.adfa.oz.au comp.unix.programmer:38277 comp.os.linux.development.apps:17387 comp.unix.solaris:71361 comp.unix.bsd:16798

In <4pg43b$hru@samba.rahul.net>, Mike Humski <mhk@rahul.net> writes:
>
>Could some one let me know how to flush the write buffer of kernel?
>
>I know you can flush the buffer at each call of "write" by selecting
>O_SYNC as the second argumnet of "open" system call.
>
>But what I would like to do is to flush the buffer when I want to.

fsync(fd)

>Only possibility that I know of is "fcntl" with O_SYNC argumnet. But it
>seems to be effective only from the next call of "write" and not to the 
>currently pending buffer contents.

I believe you are correct here.

>By the way I understand that fflush function of the standard lib does just
>flushing from the lib's buffer to kernel, not from kernel's buffer.
>Am I right ?

Yes.

>I wish to use this technique with Solaris2.x (SunOS5.x), SunOS4.x, BSDs, and
>LINUX.

Can't comment. I have so far encountered only one platform that lacked
fsync(), which was SCO Unix (prior to 3.2v5). Some versions of the 
development system did have a function called fsync(), but all it did
was call sync(), which isn't very useful.

>Thank you for your help in advance.

Hope this helps

-- Andrew (andrewg@microlise.co.uk)

"Usenet is like a herd of performing elephants with diarrhea; massive,
difficult to redirect, awe-inspiring, entertaining, and a source of
mind-boggling amounts of excrement when you least expect it." [Gene Spafford]