From owner-freebsd-hackers@FreeBSD.ORG Fri Jun 23 17:05:11 2006 Return-Path: X-Original-To: freebsd-hackers@freebsd.org Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 6B42C16A47C for ; Fri, 23 Jun 2006 17:05:11 +0000 (UTC) (envelope-from dmitry@atlantis.dp.ua) Received: from postman.atlantis.dp.ua (postman.atlantis.dp.ua [193.108.47.1]) by mx1.FreeBSD.org (Postfix) with ESMTP id 994D543D6B for ; Fri, 23 Jun 2006 17:05:06 +0000 (GMT) (envelope-from dmitry@atlantis.dp.ua) Received: from smtp.atlantis.dp.ua (smtp.atlantis.dp.ua [193.108.46.231]) by postman.atlantis.dp.ua (8.13.1/8.13.1) with ESMTP id k5NH515c061220; Fri, 23 Jun 2006 20:05:01 +0300 (EEST) (envelope-from dmitry@atlantis.dp.ua) Date: Fri, 23 Jun 2006 20:05:01 +0300 (EEST) From: Dmitry Pryanishnikov To: Konstantin Belousov In-Reply-To: <20060623150227.GK5115@deviant.kiev.zoral.com.ua> Message-ID: <20060623195551.A43353@atlantis.atlantis.dp.ua> References: <20060623173723.H39481@atlantis.atlantis.dp.ua> <20060623150227.GK5115@deviant.kiev.zoral.com.ua> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: freebsd-hackers@freebsd.org Subject: Re: Simple question about mmap() system call X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 23 Jun 2006 17:05:11 -0000 Hello! On Fri, 23 Jun 2006, Konstantin Belousov wrote: >> if ((diskp=mmap(NULL, 512, >> PROT_READ | PROT_WRITE, 0, fd, 0)) == MAP_FAILED) >> err(EX_IOERR, "Can't mmap() file"); >> >> shows actual first byte of my file. But modification doesn't get written >> back to the disk, file contents are unchanged after execution of my code. >> I'm sure I'm overlooking something very basic and stupid, but can't find >> what exactly. > You forgot MAP_SHARED. Thank you! Yes, that's it. I would say that it's description MAP_SHARED Modifications are shared. is rather terse and doesn't explicitly says that w/o it data will not be stored back to the mmapped object. One can only deduce this behaviour, and deduction sometimes fails at the end of working day ;) Sincerely, Dmitry -- Atlantis ISP, System Administrator e-mail: dmitry@atlantis.dp.ua nic-hdl: LYNX-RIPE