This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Improve stat_result.st_blocks and st_blksize documentation
Type: Stage: resolved
Components: Documentation Versions: Python 3.2, Python 3.3, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: docs@python Nosy List: docs@python, liw, martin.panter, python-dev, r.david.murray
Priority: normal Keywords: patch

Created on 2011-06-16 20:28 by liw, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
stat_result.patch liw, 2011-06-16 20:28 Patch for stat_result documentation review
Messages (10)
msg138467 - (view) Author: Lars Wirzenius (liw) Date: 2011-06-16 20:28
Attached patch adds a few words to the os.stat documentation for the st_blocks and st_blksize fields to clarify them.
msg138468 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2011-06-16 20:42
Looks good for linux.  Do you have a posix reference that confirms this interpretation?
msg138471 - (view) Author: Lars Wirzenius (liw) Date: 2011-06-16 21:05
http://pubs.opengroup.org/onlinepubs/009695399/basedefs/sys/stat.h.html says "A file system-specific preferred I/O block size for this object. In some file system types, this may vary from file to file.", which says essentially the same as the Linux stat(2) manpage from which I copied the extra words.

The same page claims that st_blocks may use other units than 512 byte blocks, but that seems to be quite rare. GNU coreutils sources claim HP-UX and AIX PS/2 have non-512 blocks. Perhaps it would be better to indicate how to find out the block size? (Since st_blksize is not it, but that's an easy assumption to make.)
msg138474 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2011-06-16 21:38
Ah, bingo.  That was what was tickling at my memory but I couldn't remember what the exact issue was I was recalling.  I forget what I was doing where that mattered, but as I vaguely remember it there is no portable way to find out what blocksize st_blocks is in.  Or at least not one that is currently exposed from Python.  I could be remembering wrong, though.
msg138475 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2011-06-16 21:44
Ah, found it: Issue 10016.
msg138542 - (view) Author: Lars Wirzenius (liw) Date: 2011-06-17 18:42
Right. So I guess at least the following should be changed (I'll make an actual patch once there's consensus):

* st_blocks should say that the size of block is often 512 bytes, but that's not guaranteed, and there's no way to know for sure

* st_blksize should say it is size of efficient I/O, and is unrelated to st_blocks

Should there be something more? Ideally, there should be a way to find out the size of blocks for st_blocks, but I don't know how to figure that out (though probably code from GNU's du could be borrowed).
msg138545 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2011-06-17 18:49
I think that wording is as good as we can do for now.  Providing a way to determine the size of st_blocks blocks should be a separate issue (a feature request).  That enhancement can include an update to these docs, but since it is an enhancement it will only go into the development version.  But your wording fix should go into all maintained versions.

I think your suggested rewording is reasonable.
msg199067 - (view) Author: Martin Panter (martin.panter) * (Python committer) Date: 2013-10-06 11:03
What happened to this patch? The current documentation is very misleading because the descriptions of the two block fields appear to complement each other.
msg199087 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2013-10-06 16:11
New changeset ef5aa8d7e932 by Georg Brandl in branch '3.3':
Closes #12350: clarify blocks/block size members of stat result.
http://hg.python.org/cpython/rev/ef5aa8d7e932
msg199088 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2013-10-06 16:11
New changeset c32657e278f6 by Georg Brandl in branch '2.7':
Closes #12350: clarify blocks/block size members of stat result.
http://hg.python.org/cpython/rev/c32657e278f6
History
Date User Action Args
2022-04-11 14:57:18adminsetgithub: 56559
2013-10-06 16:11:39python-devsetmessages: + msg199088
2013-10-06 16:11:32python-devsetstatus: open -> closed

nosy: + python-dev
messages: + msg199087

resolution: fixed
stage: resolved
2013-10-06 11:03:16martin.pantersetnosy: + martin.panter
messages: + msg199067
2011-06-17 18:49:32r.david.murraysetmessages: + msg138545
2011-06-17 18:42:09liwsetmessages: + msg138542
2011-06-16 21:44:32r.david.murraysetversions: + Python 3.2, Python 3.3
2011-06-16 21:44:03r.david.murraysetmessages: + msg138475
2011-06-16 21:38:43r.david.murraysetmessages: + msg138474
2011-06-16 21:05:55liwsetmessages: + msg138471
2011-06-16 20:42:32r.david.murraysetnosy: + r.david.murray
messages: + msg138468
2011-06-16 20:28:46liwcreate