Path: utzoo!utgpu!cunews!bnrgate!brchh104!brchs1!bnr.ca!rice.edu!sun-spots-request From: badri@ecrc.de (Badri Pillai) Newsgroups: comp.sys.sun Subject: mmap question... Keywords: No Digest Subjects in Unmoderated Mode Message-ID: <3638@brchh104.bnr.ca> Date: 5 Jun 91 14:17:00 GMT Sender: news@brchh104.bnr.ca Organization: Sunspots, Pseudo-Unmoderated Lines: 85 Approved: sun-spots@rice.edu X-Original-Date: Wed, 29 May 91 10:45:21 +0200 Can somebody explain me, why mmap fails if the object is created on TMPFS. The following is an example source, test it by creating the object in /tmp(tmpfs) and then try on any other filesystem. Thanks in advance. -------------- #! /bin/sh # This is a shell archive. Remove anything before this line, then unpack # it by saving it into a file and typing "sh file". To overwrite existing # files, type "sh file -c". You can also feed this as standard input via # unshar, or by typing "sh 'xx.c' <<'END_OF_FILE' X#include X#include X#include X#include X#include X Xextern int errno; X Xmain() X{ X char memory_object[128]; X int MEMORY_OBJECT; X X int page_size; X X caddr_t address; X caddr_t addr; X size_t size; X off_t offset; X char* ptr; X X page_size = getpagesize(); X X sprintf(memory_object, "/tmp/%s.%d", "memory_object", getpid()); X MEMORY_OBJECT = open(memory_object, (O_RDWR | O_CREAT), X (S_IRUSR | S_IWUSR)); X if (MEMORY_OBJECT == -1) X perror("open()"); X else X unlink(memory_object); X X size = (size_t) page_size; X offset = (off_t) 0; X addr = (caddr_t) 0; X address = mmap(addr, X size, X (PROT_READ | PROT_WRITE), X MAP_SHARED, X MEMORY_OBJECT, X offset); X if (address == (caddr_t) -1) X perror("mmap()"); X} END_OF_FILE if test 1041 -ne `wc -c <'xx.c'`; then echo shar: \"'xx.c'\" unpacked with wrong size! fi chmod +x 'xx.c' # end of 'xx.c' fi echo shar: End of shell archive. exit 0 badri Badri Pillai European Computer-Industry Research Centre Tel. + (49) 89-92699-119 Arabellastr 17, 8000 Muenchen 81. West Germany. Internet: badri@ecrc.de UUCP: ..unido!ecrc!badri ..pyramid!ecrc!badri