] unsigned long do_mmap(struct file * file, unsigned long addr, unsigned long len,
] unsigned long prot, unsigned long flags, unsigned long off)
] {
] struct mm_struct * mm = current->mm;
] struct vm_area_struct * vma;
] int error;
]
] if ((len = PAGE_ALIGN(len)) == 0)
] return addr;
And "here" is where this happens.
Wouldn't it be better to just do "return NULL"?
There you have a perfectly valid pointer to access the 0 bytes that
you asked for.
Just like "malloc (0)" returns NULL on some systems: You're toast when
you dare dereference the pointer (beyond what you asked for). (and feel
free not to free/munmap it afterwards.)
The "files" in /proc should in my opinion not pretend to be files:
they should be "pipes". Many programs stat their input file, and if
they get "normal file", they have all sorts of assumptions on tricks
they can do.
For example, "wc -c" will just return the st_size of the file, instead
of doing all the work that is normally involved in counting the file.
Roger.
-- ** R.E.Wolff@BitWizard.nl ** http://www.BitWizard.nl/ ** +31-15-2137555 ** *-- BitWizard writes Linux device drivers for any device you may have! --* ------ Microsoft SELLS you Windows, Linux GIVES you the whole house ------
- 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/