Article View: comp.sys.sun
Article #8397mmap question...
From: Badri Pillai
Date: Wed, 05 Jun 1991 14:17
Date: Wed, 05 Jun 1991 14:17
83 lines
2941 bytes
2941 bytes
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 <file", e.g.. If this archive is complete, you
# will see the following message at the end:
# "End of shell archive."
# Contents: xx.c
# Wrapped by badri@acrab7 on Wed May 29 10:19:37 1991
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'xx.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'xx.c'\"
else
echo shar: Extracting \"'xx.c'\" \(1041 characters\)
sed "s/^X//" >'xx.c' <<'END_OF_FILE'
X#include <sys/types.h>
X#include <sys/mman.h>
X#include <fcntl.h>
X#include <stdio.h>
X#include <errno.h>
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
Technical Details
Message-ID:
<3638@brchh104.bnr.ca>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!cunews!bnrgate!brchh104!brchs1!bnr.ca!rice.edu!sun-spots-requestShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!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