[PATCH] full device



Another patch:

When the device is out of free inodes or blocks, MC will display "No node information" or "No space information" --- actualy when the filesystem declines to report node or space information, it sets total number of blocks/nodes to 0. When it sets number of free inodes/blocks 0, it means that it is full.

Mikulas

Hi

I've found on three machines (I wonder that no one noticed it so far) that mc displays incorrect information on inode count, for example:

|  Filesystem: /                       |
|  Device:    /dev/md0                 |
|  Type:      ext2                     |
|  Free space: 161G (0%) of 552G       |
|  Free nodes: 32864471 (-27%) of 364380

|  Filesystem: /home                   |
|  Device:    /dev/md0                 |
|  Type:      xfs                      |
|  Free space: 15G (13%) of 117G       |
|  Free nodes: 64702776 (-31%) of 669767

|  Filesystem: COMMON:/                |
|  Device:    DISK1-P2:/               |
|  Type:      SPADFS                   |
|  Free space: 36G (40%) of 88G        |
|  Free nodes: 74794575 (-5%) of 1850848

--- the bug is obviously caused by integer overflow when multiplying by 100. When I further investigated the code, I found that it stores free space and free inode count only in "int" variable --- it will cause problems with devices with more than 2^31 blocks (they already exists, but I don't have such). --- so I fixed both block and inode display to use double instead --- after aplying the patch, the output looks sane:

|  Filesystem: HOME:/                  |
|  Device:    DISK1-P2:/               |
|  Type:      SPADFS                   |
|  Free space: 36G (40%) of 88G        |
|  Free nodes: 71M (40%) of 177M       |

--- maybe you could change double to "long long" but I'm not sure if it exists on all machines --- a configure test would probably be needed.

Mikulas
--- /tmp/info.c	2006-12-28 05:31:59.000000000 +0200
+++ src/info.c	2006-12-28 05:32:59.000000000 +0200
@@ -99,7 +99,7 @@
 
     case 16:
 	widget_move (&info->widget, 16, 3);
-	if (myfs_stats.nfree >0 && myfs_stats.nodes > 0){
+	if (myfs_stats.nodes > 0){
 	    char buffer1 [6], buffer2[6];
 	    size_trunc_len (buffer1, 5, myfs_stats.nfree, 0);
 	    size_trunc_len (buffer2, 5, myfs_stats.nodes, 0);
@@ -112,7 +112,7 @@
 	
     case 15:
 	widget_move (&info->widget, 15, 3);
-	if (myfs_stats.avail > 0 && myfs_stats.total > 0){
+	if (myfs_stats.total > 0){
 	    char buffer1 [6], buffer2[6];
 	    size_trunc_len (buffer1, 5, myfs_stats.avail, 1);
 	    size_trunc_len (buffer2, 5, myfs_stats.total, 1);


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