This is the mail archive of the cygwin@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

RE: problem with mmap and cygwin 1.1.8


>And at this point you're trying to mmap a file with size 0 by
>giving a filesize > 0.

Thanks for taking the time to point out my mistake.  I'm not very familiar
with mmap and didn't catch the problem since it worked (or at least appeared
to) under 1.1.7.  I fixed the code in question and it now works fine with
Cygwin 1.1.8.  

>But your example shows that the error code returned by mmap is
>not correct. It should be EOVERFLOW.

At least the bug in my program wasn't a complete waste of time! ;-)

Thanks again,

Rhet


>  -----Original Message-----
[Turnbull Wallace Capt AFRL/VSBXR]  Re: problem with mmap and cygwin 1.1.8
*	To: cygwin <cygwin at cygwin dot com> 
*	Subject: Re: problem with mmap and cygwin 1.1.8 
*	From: Corinna Vinschen <cygwin at cygwin dot com> 
*	Date: Tue, 3 Apr 2001 19:21:33 +0200 
*	References:
<D5C80F97BFC2D311A6AB0060977DA05AD96818@hamsxafrl1.plh.af.mil
<msg00168.html>> 

On Tue, Apr 03, 2001 at 10:02:09AM -0400, Turnbull Wallace Capt AFRL/VSBXR
wrote:
> Hello all.  I've recently updated my system to cygwin 1.1.8 and gcc
> 2.95-3.2. I had been running cygwin 1.1.7 and gcc 2.95.2-6.  The following
> code (which calls mmap) worked fine under 1.1.7 but now mmap fails with
> errno = 13, "Permission denied."  (Actually, the strace shows:
> "geterrno_from_win_error: unknown windows error 1006, setting errno to
13") 
> 
> I rolled back to the previous setup just to double check and the call to
> mmap worked fine.  Attached is the broken code, some cygcheck output, and
> strace output.  I'm running Windows 2000 Pro, SP1.  I did a diff on the
> cygwin sources and noticed significant changes to mmap.cc between 1.1.7
and
> 1.1.8 but didn't I didn't delve very deep.  Any ideas?  

Your source isn't correct.

> int create_files()
> {
>    int i;
>    int fd;
>    char *p;
>    char fname[1024];
>    long size;
>    int perms;
>   
>    size = get_file_size();

At this point you get a size, probably > 0.

>    perms = 0666;
>    
>    for (i=0;i<NUMALTBINS;i++)
>    {
>       memset(fname,'\0',1024);
>       sprintf(fname,"%s/csealt%02d.map",FILEPATH,i);
>       printf("creating file %s with perms %03o\n",fname,perms);
>       
>       //create and open the file
>       if ((fd = open(fname, O_RDWR | O_CREAT | O_TRUNC, perms)) < 0)

Now you create(!) an empty(!) file.

>       {
>          fprintf(stderr,"error creating file\n");     
> 
>          return -1;      
>       }
>               
>       if ((p = mmap(0,(size_t) size, 
>               PROT_READ | PROT_WRITE, MAP_FILE | MAP_SHARED, fd, 0)) ==
> (caddr_t) -1)

And at this point you're trying to mmap a file with size 0 by
giving a filesize > 0.

But your example shows that the error code returned by mmap is
not correct. It should be EOVERFLOW. I will change that for the
next version.

Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Developer                                <mailto:cygwin@cygwin.com>
Red Hat, Inc.

--
Want to unsubscribe from this list?
Check out: http://cygwin.com/ml/#unsubscribe-simple <http://cygwin.com/ml/>
>  

--
Want to unsubscribe from this list?
Check out: http://cygwin.com/ml/#unsubscribe-simple


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]