Opened 17 years ago

Closed 16 years ago

Last modified 16 years ago

#2261 closed enhancement (fixed)

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: Blocking:
Platform: All

Description

Change History (9)

comment:1 by kaoutsis, 17 years ago

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;

comment:2 by andreasf, 17 years ago

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

comment:3 by nielx, 17 years ago

Git also assumes this st_blocks to exist.

comment:4 by bonefish, 17 years ago

Component: - GeneralSystem
Type: bugenhancement

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

in reply to:  3 comment:5 by scottmc, 16 years ago

Replying to nielx:

Git also assumes this st_blocks to exist.

So does CVS 1-12-13...

comment:6 by axeld, 16 years ago

Component: SystemSystem/libroot.so
Resolution: fixed
Status: newclosed

Fixed in hrev27791. 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.

comment:7 by anevilyak, 16 years ago

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

comment:8 by axeld, 16 years ago

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.

comment:9 by anevilyak, 16 years ago

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.