mmap doesn't implemented in glibc? - Linux

This is a discussion on mmap doesn't implemented in glibc? - Linux ; #include #include #include #include #include #include #include #include #include int main() { int fd; if((fd=open("a.txt",O_WRONLY|O_CREAT)) perror("open error"); } void *pmm=mmap(0,10,PROT_WRITE,MAP_SHARED,fd,0); if(pmm==MAP_FAILED){ perror(strerror(errno)); } printf("%p\n",pmm); return 0; } The program will say ``Function not implemented" When mmap is called. I think ...

+ Reply to Thread
Results 1 to 4 of 4

Thread: mmap doesn't implemented in glibc?

  1. mmap doesn't implemented in glibc?

    #include
    #include
    #include
    #include
    #include
    #include
    #include
    #include
    #include

    int main()
    {
    int fd;
    if((fd=open("a.txt",O_WRONLY|O_CREAT))<0){
    perror("open error");
    }
    void *pmm=mmap(0,10,PROT_WRITE,MAP_SHARED,fd,0);
    if(pmm==MAP_FAILED){
    perror(strerror(errno));
    }
    printf("%p\n",pmm);
    return 0;
    }
    The program will say ``Function not implemented" When mmap is called.
    I think it should be implemented.



  2. Re: mmap doesn't implemented in glibc?

    Ronald wrote:
    > #include
    > #include
    > #include
    > #include
    > #include
    > #include
    > #include
    > #include
    > #include


    > int main()
    > {
    > int fd;
    > if((fd=open("a.txt",O_WRONLY|O_CREAT))<0){
    > perror("open error");
    > }
    > void *pmm=mmap(0,10,PROT_WRITE,MAP_SHARED,fd,0);
    > if(pmm==MAP_FAILED){
    > perror(strerror(errno));
    > }
    > printf("%p\n",pmm);
    > return 0;
    > }
    > The program will say ``Function not implemented" When mmap is called.
    > I think it should be implemented.


    That's astonishing - I would expect mmap() to be available on all
    Linux systems. Are you sure about the "Function not implemented"?
    On my system I get EACCES because you request MAP_SHARED for a
    file that's only opened for writting, but for MAP_SHARED you need
    to open it in read/write mode.
    Regards, Jens
    --
    \ Jens Thoms Toerring ___ jt@toerring.de
    \__________________________ http://toerring.de

  3. Really strange, it's ok now.

    I don't know why.
    When I start my computer this morning, compile and run it. It reports
    ``Permission denied". Use O_RDWR, all goes well.

  4. Re: mmap doesn't implemented in glibc?

    "Ronald" writes:

    > #include
    > #include
    > #include
    > #include
    > #include
    > #include
    > #include
    > #include
    > #include
    >
    > int main()
    > {
    > int fd;
    > if((fd=open("a.txt",O_WRONLY|O_CREAT))<0){
    > perror("open error");
    > }
    > void *pmm=mmap(0,10,PROT_WRITE,MAP_SHARED,fd,0);
    > if(pmm==MAP_FAILED){
    > perror(strerror(errno));
    > }
    > printf("%p\n",pmm);
    > return 0;
    > }
    > The program will say ``Function not implemented" When mmap is called.
    > I think it should be implemented.


    That's an odd error to get, but MAP_SHARED does require the file to be
    opened with mode O_RDWR. It's all in the man page.

    --
    Måns Rullgård
    mru@inprovide.com

+ Reply to Thread