View Issue Details

IDProjectCategoryView StatusLast Update
0037530FPCDocumentationpublic2020-09-03 01:08
ReporterTrevor Roydhouse Assigned ToMichael Van Canneyt  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
PlatformAppleOSmacOS 
Fixed in Version3.3.1 
Summary0037530: tstatfs example program errors for macOS
DescriptionExample 30 at https://www.freepascal.org/docs-html/rtl/unix/tstatfs.html

{$if defined(Linux) or defined(sunos)}
      // SysV like.
      writeln ('fstype : ',info.fstype);
{$else}
      // BSD like, incl Mac OS X. <<<<<< Suggests example works on macOS
      writeln ('fstype : ',info.ftype);
{$endif}

[...]
writeln ('ffree : ',info.ffree);
{$ifdef FreeBSD}
      writeln ('fsid : ',info.fsid[0]);
 {$else}
      writeln ('fsid : ',info.fsid[0]); <<<<<<<
      writeln ('Namelen : ',info.namelen); <<<<<<<
{$endif}

macOS does not have the fsid and namelen fields (or equivalents) in its record structure for statfs, statfs64, fstatfs or fstatfs64. See man 2 statfs.

Suggest:

{$ifdef Darwin}
      writeln ('ffree : ',info.ffree);
{$elseif FreeBSD}
      writeln ('ffree : ',info.ffree);
      writeln ('fsid : ',info.fsid[0]);
{$else}
      writeln ('ffree : ',info.ffree);
      writeln ('fsid : ',info.fsid[0]);
      writeln ('Namelen : ',info.namelen);
{$endif}
Tagsdocumentation
Fixed in Revision1740
FPCOldBugId
FPCTarget3.2.2
Attached Files

Activities

Trevor Roydhouse

2020-08-10 16:01

reporter   ~0124736

Should have tested that suggestion on FreeBSD as well as macOS. Fixed version of $ifdefs:

  {$if defined (Darwin)}
      writeln ('ffree : ',info.ffree);
  {$elseif defined (FREEBSD)}
      writeln ('ffree : ',info.ffree);
      writeln ('fsid : ',info.fsid[0]);
  {$else}
      writeln ('ffree : ',info.ffree);
      writeln ('fsid : ',info.fsid[0]);
      writeln ('Namelen : ',info.namelen);
  {$endif}

Michael Van Canneyt

2020-09-03 00:40

administrator   ~0125327

Fixed, thanks for reporting this !

Trevor Roydhouse

2020-09-03 01:04

reporter   ~0125331

Thanks for fixing!

Issue History

Date Modified Username Field Change
2020-08-10 07:50 Trevor Roydhouse New Issue
2020-08-10 07:50 Trevor Roydhouse Status new => assigned
2020-08-10 07:50 Trevor Roydhouse Assigned To => Michael Van Canneyt
2020-08-10 07:52 Trevor Roydhouse Tag Attached: documentation
2020-08-10 16:01 Trevor Roydhouse Note Added: 0124736
2020-09-03 00:40 Michael Van Canneyt Status assigned => resolved
2020-09-03 00:40 Michael Van Canneyt Resolution open => fixed
2020-09-03 00:40 Michael Van Canneyt Fixed in Version => 3.3.1
2020-09-03 00:40 Michael Van Canneyt Fixed in Revision => 1740
2020-09-03 00:40 Michael Van Canneyt FPCTarget => 3.2.2
2020-09-03 00:40 Michael Van Canneyt Note Added: 0125327
2020-09-03 01:04 Trevor Roydhouse Status resolved => closed
2020-09-03 01:04 Trevor Roydhouse Note Added: 0125331