Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(77162)

#12442: shutil.disk_usage()

Can't Edit
Can't Publish+Mail
Start Review
Created:
8 years, 1 month ago by g.rodola
Modified:
8 years, 1 month ago
Reviewers:
ezio.melotti, neologix, merwok
CC:
rhettinger, AntoinePitrou, giampaolo.rodola, ezio.melotti, eric.araujo, brian.curtin, devnull_psf.upfronthosting.co.za, rhettinger, brian.curtin, devnull_psf.upfronthosting.co.za
Visibility:
Public.

Patch Set 1 #

Total comments: 7

Patch Set 2 #

Total comments: 2

Patch Set 3 #

Unified diffs Side-by-side diffs Delta from patch set Stats Patch
Doc/library/shutil.rst View 1 chunk +8 lines, -0 lines 0 comments Download
Lib/shutil.py View 1 2 2 chunks +19 lines, -0 lines 0 comments Download
Lib/test/test_shutil.py View 1 2 1 chunk +10 lines, -0 lines 0 comments Download
Modules/posixmodule.c View 1 2 2 chunks +27 lines, -0 lines 0 comments Download

Messages

Total messages: 7
ezio.melotti
http://bugs.python.org/review/12442/diff/2949/7656 File Doc/library/shutil.rst (right): http://bugs.python.org/review/12442/diff/2949/7656#newcode170 Doc/library/shutil.rst:170: total, used and free space expressed in bytes plus ...
8 years, 1 month ago #1
neologix_free.fr
http://bugs.python.org/review/12442/diff/2949/7657 File Lib/shutil.py (right): http://bugs.python.org/review/12442/diff/2949/7657#newcode771 Lib/shutil.py:771: used = (st.f_blocks - st.f_bfree) * st.f_frsize I'm not ...
8 years, 1 month ago #2
giampaolo.rodola
On 2011/06/30 10:54:59, Charles-François Natali wrote: > I'm not sure the computations are correct. On ...
8 years, 1 month ago #3
giampaolo.rodola
On 2011/06/29 19:58:31, ezio.melotti wrote: > An example would be nice. Are these ints? floats? ...
8 years, 1 month ago #4
eric.araujo
http://bugs.python.org/review/12442/diff/2951/7664 File Lib/shutil.py (right): http://bugs.python.org/review/12442/diff/2951/7664#newcode776 Lib/shutil.py:776: # NB: on UNIX the percentage might different than ...
8 years, 1 month ago #5
giampaolo.rodola
On 2011/06/30 10:54:59, Charles-François Natali wrote: > I'm not sure the computations are correct. > ...
8 years, 1 month ago #6
giampaolo.rodola
8 years, 1 month ago #7
2011/7/1 Charles-François Natali <neologix@free.fr>:
>>> I'm not sure the computations are correct.
>>> free should be (st.f_bavail * st.f_bsize)
>>> used should be (st.f_blocks * st.f_frsize - st.f_bfree * st.f_bsize).
>>> Filesystems fragments are obsolete and not used on EXT(2|3|4) and
>> BTRFS
>>> filesystems, but the current computations might break on a system
>> where f_frsize
>>> < f_bsize.
>>
>> They don't match df on my linux box (ext3 fs).
>>
>
> They match on both RHEL4 and RHEL6 boxes with EXT3 and NFS filesystems.
> Here's what I use:
> free = st.f_bavail * st.f_bsize
> total = st.f_blocks * st.f_frsize
> used = (total - st.f_bfree * st.f_bsize)
>
> The only reason this could possibly differ from the current code is if
> f_bsize != f_frsize...
> Maybe a typo in your test code?
>

They match on my linux box but doesn't on FreeBSD on which f_bsize != f_frsize
(16384 vs 2048).
The original versions I was using:

   free = (st.f_bavail * st.f_frsize)
   total = (st.f_blocks * st.f_frsize)
   used = (st.f_blocks - st.f_bfree) * st.f_frsize

...matches on both Linux and FreeBSD.
Sign in to reply to this message.

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+