fsck.minix broken

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

 



Today I happened to use mkfs.minix from util-linux-ng-2.16.1
and notice that it is broken.

Funny enough the symptoms are identical to those reported in
http://lists.busybox.net/pipermail/busybox/2000-September/034736.html
when mkfs.minix was broken in busybox.

The problem is that the code for the bitops is no good.
The code from the old days had

#include "bitops.h"

where the bit(), setbit(), clrbit() functions return a truth value (0 or 1).

static inline int bit(char * addr,unsigned int nr)
{
  return (addr[nr >> 3] & (1<<(nr & 7))) != 0;
}

and it is still like this in util-linux-ng-2.14.1.
The mkfs.minix and fsck.minix code actually uses the integer value
of this boolean. For example, there are tests like
	if (zone_in_use(i) == zone_count[i])
with zone_in_use(i) defined as
  #define zone_in_use(x) (bit(zone_map,(x)-FIRSTZONE+1))
and zone_count[i] an integer.

Nowadays, I see in 2.16.1:
  #define zone_in_use(x) (isset(zone_map,(x)-FIRSTZONE+1))
which uses the undocumented isset() function - bad.
On this machine these macros are taken from <sys/param.h> and say
  #define isset(a,i)      ((a)[(i)/NBBY] & (1<<((i)%NBBY)))
in other words are not 0-1.

The easy solution is to revert to earlier code in mkfs.minix
and fsck.minix. It is always a bad idea to edit the code
of little-used utilities. It may take a long time before
someone notices that they are broken now.

Andries


It is this commit:

commit 95356e8b744439336925eeb36f01399f1ee8a5e9
Author: Karel Zak <kzak@xxxxxxxxxx>
Date:   Thu Feb 5 15:44:17 2009 +0000

    mkfs.minix: remove local implementation of {set,clr}bit
    
    We needn't to duplicate stuff from <sys/param.h>.
    
    Signed-off-by: Karel Zak <kzak@xxxxxxxxxx>

--
To unsubscribe from this list: send the line "unsubscribe util-linux-ng" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux