Ticket #2261 (closed enhancement: fixed)

Opened 22 months ago

Last modified 18 months ago

Member named `st_blocks' is missing from struct stat in sys/stat.h

Reported by: kaoutsis Owned by: axeld
Priority: normal Milestone: R1
Component: System/libroot.so Version: R1/pre-alpha1
Keywords: Cc:
Blocked By: Platform: All
Blocking:

Change History

  Changed 22 months ago by kaoutsis

Required by wine:

/Haiku1/packages/wine-1.0-rc1/dlls/ntdll> make
gcc -c -I. -I. -I../../include -I../../include  -D__WINESRC__ -D_NTSYSTEM_ -D_REENTRANT -fPIC -Wall -pipe -fno-strict-aliasing -Wwrite-strings -Wpointer-arith  -g -O2  -o directory.o directory.c
/Haiku1/packages/wine-1.0-rc1/dlls/ntdll/directory.c: In function `append_entry':
/Haiku1/packages/wine-1.0-rc1/dlls/ntdll/directory.c:947: structure has no member named `st_blocks'
make: *** [directory.o] Error 1

directory.c at line 947 +-1:

        info->EndOfFile.QuadPart = st.st_size;
        info->AllocationSize.QuadPart = (ULONGLONG)st.st_blocks * 512;
        info->FileAttributes |= FILE_ATTRIBUTE_ARCHIVE;

  Changed 22 months ago by andreasf

This has been a common issue for ports, see some examples and workarounds at HaikuPorts (formerly BePorts). BeOS did not have it either.

follow-up: ↓ 5   Changed 22 months ago by nielx

Git also assumes this st_blocks to exist.

  Changed 22 months ago by bonefish

  • type changed from bug to enhancement
  • component changed from - General to System

stat::st_blocks is actually part of the XSI extension.

in reply to: ↑ 3   Changed 18 months ago by scottmc

Replying to nielx:

Git also assumes this st_blocks to exist.

So does CVS 1-12-13...

  Changed 18 months ago by axeld

  • status changed from new to closed
  • resolution set to fixed
  • component changed from System to System/libroot.so

Fixed in r27791. What unit is used for st_blocks in the software that it uses besides WINE which assumes a block size of 512? Currently, BFS uses its native block size for the computation of the value, but if it's always expressed in 512 blocks, then we should probably change this.

Also note that this is just another value that cannot be retrieved via BStatable::GetStat() due to binary compatibility.

  Changed 18 months ago by anevilyak

The POSIX spec seems to indicate that it's allowed to vary:

The unit for the st_blocks member of the stat structure is not defined within IEEE Std 1003.1-2001. In some implementations it is 512 bytes. It may differ on a file system basis. There is no correlation between values of the st_blocks and st_blksize, and the f_bsize (from <sys/statvfs.h>) structure members.

Source:  http://www.opengroup.org/onlinepubs/000095399/basedefs/sys/stat.h.html

  Changed 18 months ago by axeld

The POSIX spec is pretty stupid in this regard, as it makes the st_blocks field essentially useless. So if other platforms are using a consistent value, we should use that, too.

  Changed 18 months ago by anevilyak

Right, I was wondering about that as well, since I don't see from the spec how you would actually determine the block size on a particular platform.

Note: See TracTickets for help on using tickets.