* fhandler.h (fhandler_dev_mem): Add methods mmap, munmap and msync.

Add `unit' member.
        * fhandler_mem.cc (fhandler_dev_mem): Initialize `unit' as well.
        (init): Care for differences between /dev/mem, /dev/kmem (not
        implemented yet) and /dev/port.
        (open): Change debug message to reflect the device.
        (mmap): New function.
        (munmap): Ditto.
        (msync): Ditto.
        (fstat): Use unit when setting st_dev in stat structure.
        * mmap.cc (mmap): Handle MAP_ANONYMOUS flag.
        Change error handling slightly.
        * path.cc (get_device_number): Handle /dev/port.
This commit is contained in:
Corinna Vinschen
2000-10-07 17:35:36 +00:00
parent 7aadaf0f7e
commit 4ea34a6850
5 changed files with 185 additions and 30 deletions

View File

@@ -203,7 +203,7 @@ mmap (caddr_t addr, size_t len, int prot, int flags, int fd, off_t off)
caddr_t base = addr;
HANDLE h;
if (fd == -1)
if ((flags & MAP_ANONYMOUS) || fd == -1)
{
fh_paging_file.set_io_handle (INVALID_HANDLE_VALUE);
fh = &fh_paging_file;
@@ -463,8 +463,16 @@ fhandler_disk_file::mmap (caddr_t *addr, size_t len, DWORD access,
if (!base || ((flags & MAP_FIXED) && base != addr))
{
__seterrno ();
syscall_printf ("-1 = mmap(): MapViewOfFileEx failed with %E");
if (!base)
{
__seterrno ();
syscall_printf ("-1 = mmap(): MapViewOfFileEx failed with %E");
}
else
{
set_errno (EINVAL);
syscall_printf ("-1 = mmap(): address shift with MAP_FIXED given");
}
CloseHandle (h);
return INVALID_HANDLE_VALUE;
}