guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

03/05: daemon: Don't reply on 'st_blocks'.


From: guix-commits
Subject: 03/05: daemon: Don't reply on 'st_blocks'.
Date: Thu, 29 Aug 2019 19:34:14 -0400 (EDT)

civodul pushed a commit to branch master
in repository guix.

commit 546a709f202024c8a5173ad372a87ddc1c284c63
Author: Eelco Dolstra <address@hidden>
Date:   Thu Aug 29 15:04:49 2019 +0200

    daemon: Don't reply on 'st_blocks'.
    
    Ported by Ludovic Courtès <address@hidden>
    from 
<https://github.com/NixOS/nix/commit/a2c4fcd5e9782dc8d2998773380c7171ee53b813>.
    
    * nix/libstore/gc.cc (LocalStore::removeUnusedLinks): Use 'st.st_size'
    instead of 'st.st_blocks * 512'.
    * nix/libutil/util.cc (_deletePath): Likewise.
---
 nix/libstore/gc.cc  | 9 ++++-----
 nix/libutil/util.cc | 2 +-
 2 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/nix/libstore/gc.cc b/nix/libstore/gc.cc
index 310b879..46171e1 100644
--- a/nix/libstore/gc.cc
+++ b/nix/libstore/gc.cc
@@ -569,9 +569,8 @@ void LocalStore::removeUnusedLinks(const GCState & state)
             throw SysError(format("statting `%1%'") % path);
 
         if (st.st_nlink != 1) {
-            unsigned long long size = st.st_blocks * 512ULL;
-            actualSize += size;
-            unsharedSize += (st.st_nlink - 1) * size;
+            actualSize += st.st_size;
+            unsharedSize += (st.st_nlink - 1) * st.st_size;
             continue;
         }
 
@@ -580,13 +579,13 @@ void LocalStore::removeUnusedLinks(const GCState & state)
         if (unlink(path.c_str()) == -1)
             throw SysError(format("deleting `%1%'") % path);
 
-        state.results.bytesFreed += st.st_blocks * 512;
+        state.results.bytesFreed += st.st_size;
     }
 
     struct stat st;
     if (stat(linksDir.c_str(), &st) == -1)
         throw SysError(format("statting `%1%'") % linksDir);
-    long long overhead = st.st_blocks * 512ULL;
+    long long overhead = st.st_size;
 
     printMsg(lvlInfo, format("note: currently hard linking saves %.2f MiB")
         % ((unsharedSize - actualSize - overhead) / (1024.0 * 1024.0)));
diff --git a/nix/libutil/util.cc b/nix/libutil/util.cc
index 768e12b..9a83876 100644
--- a/nix/libutil/util.cc
+++ b/nix/libutil/util.cc
@@ -309,7 +309,7 @@ static void _deletePath(const Path & path, unsigned long 
long & bytesFreed)
     struct stat st = lstat(path);
 
     if (!S_ISDIR(st.st_mode) && st.st_nlink == 1)
-        bytesFreed += st.st_blocks * 512;
+       bytesFreed += st.st_size;
 
     if (S_ISDIR(st.st_mode)) {
         /* Make the directory writable. */



reply via email to

[Prev in Thread] Current Thread [Next in Thread]