[Mono-dev] Syscall.mmap problem

Mauricio Henriquez mhenriquezs at terra.cl
Wed Oct 24 21:07:48 EDT 2007


Hi to all:

I trying to help to Tim Taubert in they implementation of 
Video4Linux.Net and now I have problems with the Syscall.mmap function, 
so I traslate a C mmap working example  code and allways crash, here is 
my code:

    int fdin;
            IntPtr start;
            Mono.Unix.Native.Stat statbuf;
            long len;
            if((fdin = Syscall.open("/pr.txt",  OpenFlags.O_RDONLY)) < 0)
                Console.WriteLine("open crash");
            else
                Console.WriteLine("open fine");
           
            if((Syscall.fstat(fdin, out statbuf)) < 0)
                Console.WriteLine("fstat crash");
            else
                Console.WriteLine("fstat ok");
           
            len = statbuf.st_size;
            //file lenght is 6, I test this with a mmap C code
            Console.WriteLine("length = {0}", len); //OK
           
            start = Syscall.mmap
                (IntPtr.Zero,
                 (ulong)len,
                 MmapProts.PROT_READ,
                 MmapFlags.MAP_PRIVATE,
                 fdin,
                 0);
            Console.WriteLine(start.ToString());
            if (start == Syscall.MAP_FAILED)
                throw new Exception("mmap crash.");

do you see some mistake?, I use Fedora 5 with mono-1.2.5.1, may be you 
can send me a workin Mono.Posix or Mono.Unix dll, becouse I prefer don't 
compile all mono stuff only for this dll, becouse all other stuff work 
perfectly.

In advance, thank you very much.

Mauricio Henriquez




More information about the Mono-devel-list mailing list