[Bug 260708] Opening /dev/urandom fails with errno=31 (EMLINK)

From: <bugzilla-noreply_at_freebsd.org>
Date: Sun, 26 Dec 2021 20:23:41 UTC

            Bug ID: 260708
           Summary: Opening /dev/urandom fails with errno=31 (EMLINK)
           Product: Base System
           Version: 12.2-STABLE
          Hardware: amd64
                OS: Any
            Status: New
          Severity: Affects Only Me
          Priority: ---
         Component: kern
          Assignee: bugs@FreeBSD.org
          Reporter: noloader@gmail.com

Hi Everyone,

I seem to be getting a nonsensical error when opening /dev/urandom.

The code is:

    # ifdef O_NOFOLLOW
        const int flags = O_RDONLY|O_NOFOLLOW;
    # else
        const int flags = O_RDONLY;
    # endif

        m_fd = open("/dev/urandom", flags);
        if (m_fd == -1)
            throw OS_RNG_Err("open /dev/urandom");

Under GDB, I am seeing an error of EMLINK:

    (gdb) p m_fd
    $2 = -1
    (gdb) p flags
    $3 = 256
    (gdb) p (int)errno
    $4 = 31

    (gdb) set output-radix 10
    Output radix now set to decimal 10, hex a, octal 12.
    (gdb) p (int)errno
    $5 = 31

When I lookup the error at
it says:

    Maximum allowable hard links to a single file
    has been exceeded (limit of 32767 hard links per file).

Something sounds a bit off. I am not creating a link, and I doubt there are 32K
links to the file.

You are receiving this mail because:
You are the assignee for the bug.