All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hareesh Nagarajan <hareesh.nagarajan@gmail.com>
To: linux-c-programming@vger.kernel.org
Subject: Forcing fsync() using an ouput stream in C++
Date: Thu, 3 Mar 2005 00:38:10 -0600	[thread overview]
Message-ID: <7728232c05030222384c65f341@mail.gmail.com> (raw)

Hi,

I am aware this is a C-programming mailing list. I just thought I
might get some useful inputs from this ML.

My problem is that I haven't figured out how I must fsync an output
stream (in C++) even after reading the contents of this link:
http://gcc.gnu.org/ml/gcc-help/2004-02/msg00285.html

How must I modify this method (this method doesn't work; it prints the
error message and exits!) ?

void logRecovery::syncToDisk(fstream& f)
{
    unix_filebuf_t* buf;
    buf = dynamic_cast<unix_filebuf_t*>(f.rdbuf());
    if (buf == NULL) {
	cerr << "Fatal: Don't know fd of stream" << endl;
	exit(-1);
    }

    fsync(buf->fd());
}

I am using GCC 3.3.4.

Thanks,

Hareesh

             reply	other threads:[~2005-03-03  6:38 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-03-03  6:38 Hareesh Nagarajan [this message]
2005-03-03  8:15 ` Forcing fsync() using an ouput stream in C++ Steve Graegert

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7728232c05030222384c65f341@mail.gmail.com \
    --to=hareesh.nagarajan@gmail.com \
    --cc=linux-c-programming@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.