Tcl Source Code

View Ticket
Login
Ticket UUID: 942170
Title: HAVE_ST_BLOCKS missing in configure
Type: Bug Version: obsolete: 8.4.6
Submitter: nobody Created on: 2004-04-26 08:33:43
Subsystem: 53. Configuration and Build Tools Assigned To: dkf
Priority: 5 Medium Severity:
Status: Closed Last Modified: 2009-12-28 20:56:21
Resolution: Fixed Closed By: dkf
    Closed on: 2009-12-28 13:56:21
Description:
Hi, 
 
  in the tcl8.4.6 source-code are lines like 
 
noadmin@win01:.> find . -type f | xargs grep BLOCKS 
./generic/tclTest.c:#   ifdef HAVE_ST_BLOCKS 
./generic/tclTest.c:#   ifdef HAVE_ST_BLOCKS 
./generic/tclIOUtil.c:#ifdef HAVE_ST_BLOCKS 
./generic/tclIOUtil.c:#ifdef HAVE_ST_BLOCKS 
./generic/tclIOUtil.c:#ifdef HAVE_ST_BLOCKS 
./generic/tclCmdAH.c:#ifdef HAVE_ST_BLOCKS 
 
ths "configure" entries are missing 
 
 
mfg 
 
  aotto
User Comments: dkf added on 2009-12-28 20:56:21:

allow_comments - 1

dkf added on 2009-12-28 20:56:20:
Fixed on 8.5. Can't be bothered to backport to 8.4 branch (it's not exactly a disaster if we simply don't use the st_blocks field).

dkf added on 2009-12-28 19:57:15:
Fixed on HEAD.

This was caused by the change from autoconf 2.13 to 2.57+

stwo added on 2009-11-10 01:24:42:

File Added - 350177: tcl-st_blocks.patch

stwo added on 2009-11-10 01:23:10:
With this patch:
HAVE_ST_BLOCKS becomes HAVE_STRUCT_STAT_ST_BLOCKS via the proper autoconf macro and all relevant code is adapted for this change, except for the tests.

Note that this will break cmdAH-28.3 if your system has an st_blocks field in struct stat.
Note that the casts retrieving the values from struct stat in function StoreStatData() are different from those used in the TIP 316 implementation.

I put this patch here as a next step.
I think that StoreStatData() (and others?) should use the TIP 316 functions, but the differences in casting should be worked out. Which ones are the correct ones?

It's not important to me whether or not to include the blocks field - you can fight amongst yourselves for that ;)

matzek added on 2009-11-06 15:57:28:
So what will Tcl_GetBlocksFromStat() return , if st_blocks is not available? And how does Tcl support me to find out, of which size 1 block in st_blocks is? Don't answer "look at Tcl_GetBlockSizefromStat()"! That's returning st_blksize, and this may or may not the actual block size...

Linux "man 2 stat":

----

       The st_blocks field indicates the number of blocks allocated to the file, 512-byte units.  (This may be smaller than st_size/512 when the file has holes.)

       The st_blksize field gives the "preferred" blocksize for efficient file system I/O.  (Writing to a file in smaller chunks may cause an inefficient read-modify-rewrite.)

----

AIX "man stat.h":

----

st_blksize  Size, in bytes of each block of the file.

st_blocks Number of blocks actually used by the file (measured in the units specified by the DEV_BSIZE constant).

----

HP-UX "man 5 stat":

----

longst_blksizea filesystem-specific preferred I/O block size for this object. In some filesystem types, this may vary from file to file

blkcnt_tst_blocksnumber of blocks of a filesystem-specific size allocated for this object

----

Solaris "man 2 stat":

----

st_blksize    A hint as to the “best” unit size for I/O operations. This field is not defined for block special or character special files.

st_blocks    The total number of physical blocks of size 512 bytes actually allocated on disk. This field is not defined for block special or character special files.

----

-- Matthias Kraft

stwo added on 2009-11-06 03:02:22:
USE_OBSOLETE_FS_HOOKS enables old code which also uses  HAVE_ST_BLOCKS.
If HAVE_ST_BLOCKS is enabled then the C function Tcl_Stat and the Tcl command [file stat] will return a 'blocks' field.
This has been around since 8.4.0 and seeing as no one seems to be missing it, I'd agree that it should be purged.
But! The implementation of TIP 316 has now added: Tcl_GetBlocksFromStat - Returns the st_blocks field as an unsigned wide integer.
If HAVE_ST_BLOCKS isn't defined then a guess is made.
So perhaps HAVE_ST_BLOCKS should be properly configured and used.
The function StoreStatData in generic/tclICmdAH.c could be modified to use the TIP 316 functions.
Have all the 'stat' functions/commands return the same fields.
As it is now, if HAVE_ST_BLOCKS were to be enabled then the result of [file stat] would contain an 'extra' field. This causes a test failure since the test suite doesn't account for the 'blocks' field either.

dgp added on 2009-11-05 22:57:38:
Support for the obsolete FS hooks is already
purged from the HEAD, so if HAVE_ST_BLOCKS
is only for their sake, they ought to be purged too.

matzek added on 2009-11-05 15:35:06:
Oh ... and the code came in with the implementation of TIP 72.

matzek added on 2009-11-05 15:33:23:
Summing up some conversation on the chat about this topic, today:

* To enable this code one apparently has to provide the defines HAVE_ST_BLOCKS and USE_OBSOLETE_FS_HOOKS. Neither one is provided via the autoconf stuff.

* If I read the commentary in tclIOUtil.c correctly, this was never released and is only in there for backward compatibility for TclPro.

* st_blocks itself is relatively useless (IMHO), one have to KNOW the block size of the file system. It is not a part of POSIX, but is an X/Open System Interface. Besides this POSIX documents for sys/stat.h:

"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.

Traditionally, some implementations defined the multiplier for st_blocks in <sys/param.h> as the symbol DEV_BSIZE."

-- Matthias Kraft

Attachments: