[gdal-dev] test failures on pkgsrc build of 3.3.2rc3

Greg Troxel gdt at lexort.com
Wed Sep 1 12:22:30 PDT 2021

>> Looking into the avc failure, I find
>> $ ogrinfo ogr/data/avc/testavc/testavc/
>> INFO: Open of `ogr/data/avc/testavc/testavc/'
>>        using driver `AVCBin' successful.
>> 1: ARC (Line String)
>> 2: LAB (Point)
>> But if I leave off the trailing / I get a failure to find a driver.  A
>> trailing slash on a directrory name seems odd to me, and usually the
>> result of completion.
> Hum, I suspect you might hit a similar issue as the one for FreeBSD in
> https://github.com/OSGeo/gdal/blob/a95e796f65b26379b0e5c699bacef29f7684f79f/gdal/gcore/gdalopeninfo.cpp#L216
> where fopen("/some/dir", "rb") succeeds.
> Can you test changing that with whatever define is appropriate to test
> for your OS and submit the resulting patch ?

The comment about FreeBSD being odd seems strange to me, as POSIX has no
notion that fopen must fail when opening a directory for reading.


As I read the spec, it is a violation to return NULL when the first
argument is a directory and the second is r or rb.  A test program
succeeds in calling fopen on . with rb, on both NetBSD and macOS 10.13.

Perhaps I am misreading the POSIX spec.

I applied a patch to always do the directory check, and now ogrinfo
works with or without the trailing /.   Patch looks more complicated
than it is....

--- gcore/gdalopeninfo.cpp.orig	2021-09-01 09:48:45.000000000 +0000
+++ gcore/gdalopeninfo.cpp
@@ -213,12 +213,8 @@ retry:  // TODO(schwehr): Stop using got
 #endif  // HAVE_READLINK
-#ifdef __FreeBSD__
-    /* FreeBSD 8 oddity: fopen(a_directory, "rb") returns non NULL */
+    /* fopen(dir, "r") is required to succeed, per POSIX */
     bool bPotentialDirectory = (eAccess == GA_ReadOnly);
-    bool bPotentialDirectory = false;
-#endif  // __FreeBDS__
     /* Check if the filename might be a directory of a special virtual file system */
     if( STARTS_WITH(pszFilename, "/vsizip/") ||

A test run with this fix and GDAL_DATA unset got to only 20 failures.

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: test_fopen.c
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20210901/0ddc7e95/attachment.c>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 194 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20210901/0ddc7e95/attachment.sig>

More information about the gdal-dev mailing list