[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] hurd: Implement device memory mapping
From: |
Samuel Thibault |
Subject: |
Re: [PATCH] hurd: Implement device memory mapping |
Date: |
Sun, 12 Dec 2021 16:19:23 +0100 |
User-agent: |
NeoMutt/20170609 (1.8.3) |
Hello,
Joan Lledó, le dim. 12 déc. 2021 13:52:14 +0100, a ecrit:
> + err = io_map (file, &robj, &wobj);
> + mach_port_deallocate (mach_task_self(), file);
> + if (err)
> + return err;
> +
> + switch (prot & (VM_PROT_READ|VM_PROT_WRITE)) {
> + case VM_PROT_READ:
> + pager = robj;
> + if (wobj != MACH_PORT_NULL)
> + mach_port_deallocate (mach_task_self(), wobj);
> + break;
> + case VM_PROT_READ|VM_PROT_WRITE:
> + if (robj == wobj) {
> + pager = wobj;
> + /* Remove extra reference. */
> + mach_port_deallocate (mach_task_self (), pager);
> + }
> + else if (wobj == MACH_PORT_NULL) {
> + /* We asked for write permissions but they weren't granted. */
> + mach_port_deallocate (mach_task_self (), robj);
> + return EPERM;
> + }
Don't we need
else { pager = wobj; } ?
Otherwise pager would be undefined.
Note: better *not* initialize the robj/wobj/pager variables by default,
so that the compiler does catch such mistakes and emit a warning.
> @@ -523,18 +630,18 @@ pci_system_hurd_create(void)
>
> pci_sys->num_devices = 0;
>
> - if ((err = get_privileged_ports (NULL, &device_master)) ||
> (device_master == MACH_PORT_NULL)) {
> - pci_system_cleanup();
> - return err;
> - }
> -
> - err = device_open (device_master, D_READ|D_WRITE, "pci", &pci_port);
> - if (!err) {
> - root = file_name_lookup_under (pci_port, ".", O_DIRECTORY | O_RDWR |
> O_EXEC, 0);
> - }
> -
> - if (!root) {
> - root = file_name_lookup (_SERVERS_BUS_PCI, O_RDWR, 0);
> + if ((err = get_privileged_ports (NULL, &device_master))
> + || (device_master == MACH_PORT_NULL)) {
> + root = file_name_lookup (_SERVERS_BUS_PCI, O_RDONLY, 0);
> + } else {
> + err = device_open (device_master, D_READ, "pci", &pci_port);
> + mach_port_deallocate (mach_task_self (), device_master);
> + if (!err) {
> + root = file_name_lookup_under (pci_port, ".",
> + O_DIRECTORY | O_RDONLY | O_EXEC,
> 0);
> + }
> + device_close (pci_port);
> + mach_port_deallocate (mach_task_self (), pci_port);
These two should be inside if (!err)
> }
>
> if (!root) {
- Re: About consuming/releaseing ports in libpciaccess, Joan Lledó, 2021/12/12
- [PATCH] hurd: Implement device memory mapping, Joan Lledó, 2021/12/12
- Re: [PATCH] hurd: Implement device memory mapping,
Samuel Thibault <=
- Re: [PATCH] hurd: Implement device memory mapping, Joan Lledó, 2021/12/19
- Re: [PATCH] hurd: Implement device memory mapping, Samuel Thibault, 2021/12/19
- Re: [PATCH] hurd: Implement device memory mapping, Joan Lledó, 2021/12/28
- Re: [PATCH] hurd: Implement device memory mapping, Samuel Thibault, 2021/12/28
- Re: [PATCH] hurd: Implement device memory mapping, Joan Lledó, 2021/12/28
- Re: [PATCH] hurd: Implement device memory mapping, Samuel Thibault, 2021/12/28
- Re: [PATCH] hurd: Implement device memory mapping, Joan Lledó, 2021/12/30
- [PATCH] hurd: Implement device memory mapping, Joan Lledó, 2021/12/30