I can, but not without some fixups to the posted program -- see the
filemap_nopage() thread for details, there seems to be a problem with that
function in the later 2.3 kernels.
I've not got access to a *nix box at the moment, so the following from
memory
(I can't remember the exact constant names off the top of my head):
>> #include <unistd.h>
>> #include <sys/mman.h>
Various other include files needed here..
>> main()
>> {
>> int fd;
>> char *mem;
>> int i = 0;
>> char c = 0;
>>
>> fd = open("file", 0666);
fd = open("file", xxCREAT|xxRDWR, 0666);
>> lseek(fd, 1000000, 0);
>> mem = mmap(0, 1000000, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd,
0);
>> if (mem <= 0)
> ^^^^^^^^^^
>Erm? Do you really mean that?
if (mem == (caddr_t)-1)
>I consistently get:
>$ ./foo
>0xffffffff
>Segmentation fault (core dumped)
Yup, the open() fails and thus the mmap() does too (invalid fd passed);
pointers are unsigned so you can't use the <=0 check on the result
(successfully).
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/