From owner-freebsd-hackers Fri Jun 16 12:49:26 2000 Delivered-To: freebsd-hackers@freebsd.org Received: from apollo.backplane.com (apollo.backplane.com [216.240.41.2]) by hub.freebsd.org (Postfix) with ESMTP id 2A89C37BA3E for ; Fri, 16 Jun 2000 12:49:24 -0700 (PDT) (envelope-from dillon@apollo.backplane.com) Received: (from dillon@localhost) by apollo.backplane.com (8.9.3/8.9.1) id MAA60866; Fri, 16 Jun 2000 12:49:17 -0700 (PDT) (envelope-from dillon) Date: Fri, 16 Jun 2000 12:49:17 -0700 (PDT) From: Matthew Dillon Message-Id: <200006161949.MAA60866@apollo.backplane.com> To: Joy Ganguly Cc: freebsd-hackers Subject: Re: mmap and file writes...??? References: <394A3727.1FEC441E@falcon.niksun.com> Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG :hi all, : :i have a question regarding mmap and file write. a file is mmap'ed and :data is written into the mapped region. now the same region is written. :(as shown below) : :buf = mmap(NULL, len, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); :. :. /* some data put in buf */ :. : :write(fd, buf, len); : : :now does this lead to unnecessary copies?? more specifically what :happens if two virtual addresses point to the same physical address and :data is copied from one to the other. : :thanx in advance : :joy You can copy data from one part of a file to another using this method, but only if the two areas do not overlap. If the areas overlap, the result will be possible corruption of the file. -Matt Matthew Dillon To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message