Re: Using INN with shared writable memory in Linux 1.3.3

Michael Riepe (
Sun, 25 Jun 1995 04:31:36 +0200

From: (Brian Blackmore)

> Linus did say a while back that he would like somebody brave to try
> out using INN with shared writable memory mappings and since I run INN
> for my own purposes and my own purposes only I thought I'd give it a
> try. I present the following observations which may or may not be of
> interest to Linus and anyone else reading here..
> 1. With shared memory creating new groups doesn't seem to work properly,
> all you get in the active file is the approprate number of NUL's at the
> end. I remember Linus saying he wasn't quite sure what to do when you
> ran off the end of the mapping, well INN seems to want to extend it,
> Linux at present doesn't.

You can't change the size of a file by means of writing outside the
region of a shared writable mapping - at least that's what the slowaris
man pages say. The problem here's a little different, though. Consider
the following program:

#include <sys/fcntl.h>
#include <sys/types.h>
#include <sys/mman.h>

main(int argc, char **argv) {
char *p;
int fd;
int err;

fd = open("testfile", O_RDWR|O_CREAT|O_TRUNC, 0644);
ftruncate(fd, 10240);
p = (char*)mmap(0, 10240, PROT_READ|PROT_WRITE,
p[0] = 'A';
p[10239] = 'Z';
munmap((caddr_t)p, 10240);
return 0;

This *should* create a file filled with all 0's and 'A' and 'Z' at the
beginning and the end, respectively - but it doesn't (the file is
created but contains all 0's). If you copy 10K from /dev/zero and open
the file with just O_RDWR, it works correctly.


 Michael Riepe               <>
 Universit"at Hannover
 Institut f"ur Fertigungstechnik und Spanende Werkzeugmaschinen
 Schlosswender Str. 5                  30159 Hannover (Germany)
 ... beware the storm that gathers here ("The Prophet's Song")