Re: [PATCH] full device



One more patch fixing two issues:

stat.st_blocks may be 64-bit, but Midnight commander truncates it to long

If the file has too many blocks, display overflows the right end of the panel (because there is no size_trunc_len when printing block count).

Mikulas

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-29 02:59:50.000000000 +0200
+++ src/info.c	2006-12-29 03:02:01.000000000 +0200
@@ -165,8 +165,9 @@
 	    size_trunc_len(buffer, 9, st.st_size, 0);
 	    printw (const_cast(char *, _("Size:      %s")), buffer);
 #ifdef HAVE_STRUCT_STAT_ST_BLOCKS
+	    size_trunc_len(buffer, 6, st.st_blocks, 0);
 	    printw (const_cast(char *, (st.st_blocks==1) ?
-		_(" (%ld block)") : _(" (%ld blocks)")), (long) st.st_blocks);
+		_(" (%s block)") : _(" (%s blocks)")), buffer);
 #endif
 	}
 	


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