Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 5 Jul 1999 19:19:51 -0400
From:      "Kelly Yancey" <kbyanc@alcnet.com>
To:        <freebsd-hackers@freebsd.org>
Subject:   mmap question
Message-ID:  <000101bec73c$e20e3660$291c453f@kbyanc.alcnet.com>

next in thread | raw e-mail | index | archive | help

  I have a quick question about mmap, hopefully someone can smack me and
point
out what I'm missing :)

  the man page says:
    The mmap() function causes the pages starting at addr and continuing for
    at most len bytes to be mapped from the object described by fd, starting
    at byte offset offset. If len is not a multiple of the pagesize, the
    mapped region may extend past the specified range.  Any such extension
    beyond the end of the mapped object will be zero-filled.

  Which is fine and dandy, I'll just stat() the file to get the filesize and
mmap() it. But what happens in someone comes along and replaces the file
with
a larger file? I understand that my view of the file will change to the new
file, but only the length that I mmap()ed originally. Do I have to
periodically stat() the file to determine if I need to re-mmap() it should
the file size change? And if so, doesn't that partly diminish the usefulness
of mmap()? I mean, sure you can edit the file as a file and they are
reflected in the in-memory image, but how many edits don't change the file
size?

  Also, in case it hasn't been notice already (I'm running -stable from May
18th), the mmap(2) manpage has a typo: it has "#include <sys/mman.h>"

  Thanks for your help,

  Kelly
 ~kbyanc@posi.net~
  FreeBSD - The Power To Serve - http://www.freebsd.org/
  Join Team FreeBSD - http://www.posi.net/freebsd/Team-FreeBSD




To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?000101bec73c$e20e3660$291c453f>