Return to BSD News archive
Path: sserve!newshost.anu.edu.au!munnari.oz.au!constellation!osuunx.ucc.okstate.edu!moe.ksu.ksu.edu!ux1.cso.uiuc.edu!uwm.edu!cs.utexas.edu!math.ohio-state.edu!sol.ctr.columbia.edu!news.kei.com!ub!rutgers!njitgw.njit.edu!hertz.njit.edu!kxn3796 From: kxn3796@hertz.njit.edu (Ken Nakata) Newsgroups: comp.os.386bsd.development Subject: Re: MMAP() doesn't work for me ? Keywords: mmap, 386bsd Message-ID: <1993Jun2.152352.25963@njitgw.njit.edu> Date: 2 Jun 93 15:23:52 GMT References: <C7xM5G.3sE@unix.portal.com> Sender: news@njit.edu Organization: New Jersey Institute of Technology, Newark, N.J. Lines: 66 Nntp-Posting-Host: hertz.njit.edu In article <C7xM5G.3sE@unix.portal.com> chris@shell.portal.com (Chris - Ding) writes: > >The configuration is 386bsd 0.1 + 0.2.3. > >The command sequence is: > >#su >#ls -l /dev/mem >crw-r----- 1 root 2, 0 May 31 11:58 /dev/mem >#a.out >test ( mmap ) : Invalid argument > > >Can anyone tell me what's wrong with the code ? Or there is a bug in the kernal ? >Thanks. >C. Ding >chris@shell.portal.com > >------ Source code for a.out -------- >#include <sys/file.h> >#include <unistd.h> >#include <stdio.h> >#include <ctype.h> >#include <sys/mman.h> > >main() >{ > caddr_t addr; > int prot = PROT_WRITE; > static int fd; > > int i; > > if ( ( fd = open ( "/dev/mem", O_RDWR ) ) == -1 ) > { > perror ( "test" ); > exit( 1 ); > } > addr = mmap ( (caddr_t) 0, len, prot, MAP_FILE, fd, (off_t)0x0 ); > if ( addr == ( caddr_t ) -1 ) > { > perror ( "test (mmap) " ); > exit ( 1 ); > } > > : > : > : > : >} > >-- >Chris Ding >chris@portal.shell.com This is because /dev/mem doesn't have support for mmap function. Could any guru/wizard tell us why it doesn't? Thanks in advance. Ken Nakata -- * I apologize if there are misuses of and/or impolite words or phrases in this mail or post. They are not intended; I don't fully understand certain words or each nuance of a phrase. Any corrections for either English compositions or contents are greatly appreciated. Thank you. Ken Nakata, CIS student, NJIT *