gdesklets - calculation of disksize
Franz Klammer
klammer at webonaut.com
Wed Mar 31 00:14:01 PST 2004
Joe Marcus Clarke wrote:
>On Tue, 2004-03-30 at 17:11, Franz Klammer wrote:
>
>>question to the knowing people:
>>
>>gdesklets didn't calculate the correct disk size returned from glibtop.
>>i had to change the following lines (excerpt from a diff):
>>
>>- free = float(bfree * 512)
>>- total = float(blocks * 512)
>>+ free = float(bfree * 2048)
>>+ total = float(blocks * 2048)
>>
>>my questions:
>>- is this only necessary on -CURRENT?
>>- if yes: from which version upwards i should check?
>>
>
>On -CURRENT, we have statvfs, but there are parts of the GNOME code that
>don't use it right. This is why you were seeing weird values in
>nautilus previously. Places where statvfs is used need to be modified
>to use the f_frsize member for block size, and f_bavail for available
>blocks.
>
>In this case, you also need to make sure that the value given to you
>from libgtop2 is using f_blocks and f_bfree. Then, multiply those
>values by whatever you get for f_frsize.
>
>
ok! i hope i this is it ...
attached patch gdesklets_current.diff for testting.
the only thing which i'm not sure now is the free-disk value.
seems that this values includes also the amount fbsd reserves for
failover, e..g.:
df -h returns:
30G 19G 8.9G 68% /usr
sysinfo desklets are showing this values:
29.79 18.51 11.28
only the free/avail values is not really correct.
@pav - guess you are using -CURRENT can you please test it?
franz.
ps: patch is also fetchable from
http://webonaut.com/temp/gdesklets_current.diff.
>Joe
>
>
>>franz
>>
-------------- next part --------------
diff -Nur gdesklets.orig/Makefile gdesklets/Makefile
--- gdesklets.orig/Makefile Wed Mar 24 10:43:04 2004
+++ gdesklets/Makefile Wed Mar 31 09:56:22 2004
@@ -32,6 +32,9 @@
MAN1= gdesklets.1
+post-patch:
+ @${TOUCH} ${WRKSRC}/libdesklets/glibtop*
+
post-install:
@${MKDIR} ${PREFIX}/share/gnome/gdesklets/Displays
@${PYTHON_CMD} ${PYTHON_LIBDIR}/compileall.py ${PREFIX}/share/gnome/gdesklets/config
diff -Nur gdesklets.orig/files/patch-libdesklets::Disk.py gdesklets/files/patch-libdesklets::Disk.py
--- gdesklets.orig/files/patch-libdesklets::Disk.py Wed Feb 25 14:13:32 2004
+++ gdesklets/files/patch-libdesklets::Disk.py Wed Mar 31 10:00:02 2004
@@ -1,5 +1,5 @@
---- libdesklets/Disk.py.orig Mon Feb 23 10:52:50 2004
-+++ libdesklets/Disk.py Mon Feb 23 10:54:31 2004
+--- libdesklets/Disk.py.orig Fri Feb 20 14:29:07 2004
++++ libdesklets/Disk.py Wed Mar 31 09:34:54 2004
@@ -1,6 +1,6 @@
import glibtop
import polling
@@ -35,3 +35,17 @@
return partitions
+@@ -44,9 +49,10 @@
+ #
+ def __poll_size(self, partition):
+
+- blocks, bfree, bavail, files, ffree = glibtop.get_fsusage(partition)
+- free = float(bfree * 512)
+- total = float(blocks * 512)
++ blocks, bfree, bavail, files, ffree, block_size = glibtop.get_fsusage(partition)
++
++ free = float(bfree * block_size)
++ total = float(blocks * block_size)
+ used = total - free
+
+ return (total, used)#, free)
diff -Nur gdesklets.orig/files/patch-libdesklets::glibtop.c gdesklets/files/patch-libdesklets::glibtop.c
--- gdesklets.orig/files/patch-libdesklets::glibtop.c Thu Jan 1 01:00:00 1970
+++ gdesklets/files/patch-libdesklets::glibtop.c Wed Mar 31 09:53:41 2004
@@ -0,0 +1,19 @@
+--- libdesklets/glibtop.c.orig Wed Mar 31 09:50:48 2004
++++ libdesklets/glibtop.c Wed Mar 31 09:47:29 2004
+@@ -519,7 +519,7 @@
+
+ PyObject* get_fsusage(const char *mount_dir)
+ {
+- PyObject * const t = PyTuple_New(5);
++ PyObject * const t = PyTuple_New(6);
+
+ glibtop_fsusage buf;
+ glibtop_get_fsusage(&buf, mount_dir);
+@@ -529,6 +529,7 @@
+ PyTuple_SetItem(t, 2, PyL_ULL(buf.bavail));
+ PyTuple_SetItem(t, 3, PyL_ULL(buf.files));
+ PyTuple_SetItem(t, 4, PyL_ULL(buf.ffree));
++ PyTuple_SetItem(t, 5, PyL_ULL(buf.block_size));
+
+ return t;
+ }
More information about the freebsd-gnome
mailing list