On Mon, Nov 21, 2022 at 9:21 PM <tlaro...@polynum.com> wrote:

> diff --git a/EmulatorPkg/Unix/Host/BlockIo.c
> b/EmulatorPkg/Unix/Host/BlockIo.c
> index cf2d6b4cda..c0c694be55 100644
> --- a/EmulatorPkg/Unix/Host/BlockIo.c
> +++ b/EmulatorPkg/Unix/Host/BlockIo.c
> @@ -133,6 +133,20 @@ EmuBlockIoOpenDevice (
>
>        ioctl (Private->fd, DKIOCGETMAXBLOCKCOUNTWRITE,
> &Private->Media->OptimalTransferLengthGranularity);
>      }
> + #elif _NETBSD_SOURCE
> +    {
> +      u_int  BlockSize;
>
Hi,

Again, thanks for the patches. Please send them in the way I kind of
described in my other reply.

s/u_int/UINT/

+      off_t  DiskSize;
>
I think this off_t is fine, per the other off_t usages, I don't know if the
maintainers agree.

> +
> +      if (ioctl (Private->fd,  DIOCGSECTORSIZE, &BlockSize) == 0) {
> +        Private->Media->BlockSize = BlockSize;
> +      }
> +
> +      if (ioctl (Private->fd, DIOCGMEDIASIZE, &DiskSize) == 0) {
> +        Private->NumberOfBlocks   = DivU64x32 (DiskSize,
> (UINT32)BlockSize);
> +        Private->Media->LastBlock = Private->NumberOfBlocks - 1;
> +      }
> +    }
>   #else
>      {
>        size_t  BlockSize;
>


> diff --git a/EmulatorPkg/Unix/Host/Host.c b/EmulatorPkg/Unix/Host/Host.c
> index 38c01c84af..c505300129 100644
> --- a/EmulatorPkg/Unix/Host/Host.c
> +++ b/EmulatorPkg/Unix/Host/Host.c
> @@ -12,6 +12,12 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
>  #define MAP_ANONYMOUS  MAP_ANON
>  #endif
>
> +#ifdef _NETBSD_SOURCE
> +#define MAP_ANON_FD_ (-1)
> +#else
> +#define MAP_ANON_FD_ (0)
> +#endif
>
Would there be a harm if we just passed -1 everywhere? It's a bit odd
NetBSD explicitly requires this, but AFAIK implementations
either EINVAL on fd != -1 or take whatever since it's anon. The main
implementations (Linux, FreeBSD, NetBSD, OpenBSD, macOS) seem to
agree that passing -1 should be safe everywhere (in fact, it's pretty funny
that all BSD-derived implementations agree with the fd = -1 thing, but I
digress).

The rest of the patch looks mostly ok to me, but then again, I'm not a
maintainer for this.

Thanks,
Pedro


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#96524): https://edk2.groups.io/g/devel/message/96524
Mute This Topic: https://groups.io/mt/95182515/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-


Reply via email to