From owner-freebsd-questions@FreeBSD.ORG Fri Jul 22 11:21:11 2011 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 152A71065670 for ; Fri, 22 Jul 2011 11:21:11 +0000 (UTC) (envelope-from freebsd@edvax.de) Received: from mx01.qsc.de (mx01.qsc.de [213.148.129.14]) by mx1.freebsd.org (Postfix) with ESMTP id 9596D8FC15 for ; Fri, 22 Jul 2011 11:21:10 +0000 (UTC) Received: from r55.edvax.de (port-92-195-103-124.dynamic.qsc.de [92.195.103.124]) by mx01.qsc.de (Postfix) with ESMTP id 3E31C3CFFD; Fri, 22 Jul 2011 13:21:09 +0200 (CEST) Received: from r55.edvax.de (localhost [127.0.0.1]) by r55.edvax.de (8.14.2/8.14.2) with SMTP id p6MBL8HW002620; Fri, 22 Jul 2011 13:21:08 +0200 (CEST) (envelope-from freebsd@edvax.de) Date: Fri, 22 Jul 2011 13:21:08 +0200 From: Polytropon To: Unga Message-Id: <20110722132108.da198648.freebsd@edvax.de> In-Reply-To: <1311317040.38368.YahooMailClassic@web160115.mail.bf1.yahoo.com> References: <1311317040.38368.YahooMailClassic@web160115.mail.bf1.yahoo.com> Organization: EDVAX X-Mailer: Sylpheed 2.4.7 (GTK+ 2.12.1; i386-portbld-freebsd7.0) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: freebsd-questions@freebsd.org Subject: Re: How to sync a file on FreeBSD? X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Polytropon List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 Jul 2011 11:21:11 -0000 On Thu, 21 Jul 2011 23:44:00 -0700 (PDT), Unga wrote: > How to sync a file on FreeBSD (esp. on 8.1) to disk? > > I used fsync(2), but does not immediately flush to disk. > > I want my writing to a file (a log file) immediately > available to other users to read. Maybe you can use system("/bin/sync"); or sync(); in your program? Check "man 8 sync": "force completion of pending disk writes (flush cache)" as well as "man 2 sync": "The sync() system call forces a write of dirty (modified) buffers in the block buffer cache out to disk." Is this "immediately" enough for your needs? -- Polytropon Magdeburg, Germany Happy FreeBSD user since 4.0 Andra moi ennepe, Mousa, ...