GCC Newspaper
OCTOBER 6, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
cobol

Cobol: Improve diagnostics for directory-based copybooks

Cobol compiler now reports if a copybook is a directory, preventing confusing mmap errors.

The cobol compiler now explicitly checks if a requested copybook is a directory using fstat(2) before attempting to mmap(2) it. This change prevents confusing ‘No such device’ errors and provides a clear diagnostic message indicating that the specified path is a directory, improving usability.

In Details

In cdf-copy.cc, this commit replaces a direct open() call for copybooks with a fstat(2) check prior to mmap(2). This specifically addresses an issue where attempting to mmap a directory would lead to a cryptic map_file: could not map fd error. The new logic emits a user-friendly error stating the copybook is a directory.

For Context
mmap(2)
A system call that maps files or devices into memory. It allows a program to treat file contents as if they were in memory, enabling direct read/write operations.
fstat(2)
A system call that retrieves information about a file, including its type (e.g., regular file, directory, symbolic link). This is used here to detect if the path points to a directory.
Filed Under: coboldiagnosticserror handling