From: Daniel Barkalow Date: Mon, 10 Oct 2005 20:27:46 GMT Subject: Re: First cut at git port to Cygwin Message-ID: In-Reply-To: On Mon, 10 Oct 2005, Johannes Schindelin wrote: > Hi, > > On Mon, 10 Oct 2005, H. Peter Anvin wrote: > > > Junio C Hamano wrote: > > > > > > PROT_WRITE is true, but we do MAP_PRIVATE, and if I recall > > > correctly we do not write file via mmap -- at least we do not > > > intend to. > > > > > > > Then PROT_READ probably makes more sense? > > Not necessarily. Sometimes you need to annotate the data from the index, > and this does not need to be written back to the index file. In fact, it is intentional that we open the file O_RDONLY, and mmap it PROT_READ | PROT_WRITE, MAP_PRIVATE. We prepare the next index in the memory where we mapped the old index, but we don't want to change what's on the disk using the mapping; we write that later to a different file using write(). > > > Yes. It might have been overkill that you supported writing > > > changes back, though. > > > > Not just overkill; if we do MAP_PRIVATE it's actively WRONG. > > See above. > > BTW, is there a mechanism to make sure that the index file is locked > between reading and writing? There's definitely locking; the new file is written to "(filename).lock", which is openned O_CREAT | O_EXCL, and is moved to the destination when it's complete. I believe everything that intends to write a new index gets the lock before reading the old index, although I haven't actually checked. -Daniel *This .sig left intentionally blank*