From owner-freebsd-hackers Thu Jul 27 5:33:27 2000 Delivered-To: freebsd-hackers@freebsd.org Received: from earth.rila.bg (earth.rila.bg [212.39.75.31]) by hub.freebsd.org (Postfix) with ESMTP id D86D637B92B for ; Thu, 27 Jul 2000 05:33:16 -0700 (PDT) (envelope-from mitko@rila.bg) Received: from earth (mitko@localhost [127.0.0.1]) by earth.rila.bg (8.9.3/8.9.3/SuSE Linux 8.9.3-0.1) with SMTP id PAA08505 for ; Thu, 27 Jul 2000 15:31:42 +0300 From: Dimitar Peikov Organization: Rila Solutions To: hackers@FreeBSD.ORG Subject: mmap syncs and file extends Date: Thu, 27 Jul 2000 15:22:01 +0300 X-Mailer: KMail [version 1.0.28] Content-Type: text/plain MIME-Version: 1.0 Message-Id: <00072715314205.05330@earth> Content-Transfer-Encoding: quoted-printable Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Hi, hackers, I've try to use mmap() and resize the mapping. msync() syncronizes only t= he memory that was mmapped with mmap(). How can I extend the main file? Memo= ry is filled correctly, but I must write extended data to file by hand. In my examples 'x.txt' was 11 bytes (some text); Where I'm wrong? ---------- #include #include #include #include #include =20 int main() { char *ptr; int fd, size=3D20; =20 fd =3D open("x.txt", O_RDWR | O_CREAT); ptr =3D mmap(0, 15, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); ptr[0] =3D 'D'; ptr[6] =3D 'D'; ptr =3D mremap(ptr, 10, 20, 1); close(fd); ptr[10] =3D 'Y'; ptr[12] =3D 'X'; printf("1%C\n", ptr[12]); msync(ptr, size, MS_SYNC); munmap(ptr, size); } ---------- --=20 Dimitar Peikov Programmer "We Build e-Business" =20 RILA Solutions =20 27 Building, Acad.G.Bonchev Str. =20 1113 Sofia, Bulgaria =20 home: (+359 2) 595495 phone: (+359 2) 9797320=20 phone: (+359 2) 9797300=20 fax: (+359 2) 9733355 =20 http://www.rila.com=20 To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message