Guess you have to specify O_CREAT flag too in open.

Chaitra

On Sunday, May 25, 2014, Pietro Paolini <P.Paolini@genexis.eu> wrote:
Hello everyone,
in order to try to use mmap() to perform IPC I am writing a test program like this :

int main(char **argv, int argn)
{
        char *addr;
        int fd;

        if ((fd = open(FILENAME, O_RDWR) == -1)) {
                perror("open:");
                exit(1);
        }
        addr = mmap(NULL, SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
        if (addr == MAP_FAILED) {
                printf("mmap() : %p %s", addr, strerror(errno));
                exit(1);
        }
        close(fd);
....


I am running under
Linux crunchbang 3.2.0-4-amd64 #1 SMP Debian 3.2.54-2 x86_64 GNU/Linux

My problem is that everytime I have got an "No such device" error which I don't fully get, could a problem of my platoform
or am I simply doing something wrong ?

Thanks all,
Pietro

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies