This bug has been introduced by commit
95356e8b744439336925eeb36f01399f1ee8a5e9.
The fsck.minix code assumes that isset() macro returns boolean,
unfortunately the generic implementation from libc returns integer.
This patch also add a fallback for the bitmap macros to include/bitops.h.
Reported-by: "Andries E. Brouwer" <Andries.Brouwer@cwi.nl>
Signed-off-by: Karel Zak <kzak@redhat.com>
#include <termios.h>
#include <mntent.h>
#include <sys/stat.h>
-#include <sys/param.h>
#include <signal.h>
#include "minix.h"
#include "nls.h"
#include "pathnames.h"
+#include "bitops.h"
#define ROOT_INO 1
static void recursive_check(unsigned int ino);
static void recursive_check2(unsigned int ino);
-#define inode_in_use(x) (isset(inode_map,(x)))
-#define zone_in_use(x) (isset(zone_map,(x)-FIRSTZONE+1))
+#define inode_in_use(x) (isset(inode_map,(x)) != 0)
+#define zone_in_use(x) (isset(zone_map,(x)-FIRSTZONE+1) != 0)
#define mark_inode(x) (setbit(inode_map,(x)),changed=1)
#define unmark_inode(x) (clrbit(inode_map,(x)),changed=1)
#include <stdlib.h>
#include <termios.h>
#include <sys/stat.h>
-#include <sys/param.h>
#include <mntent.h>
#include <getopt.h>
#include "minix.h"
#include "nls.h"
#include "pathnames.h"
+#include "bitops.h"
#define MINIX_ROOT_INO 1
#define MINIX_BAD_INO 2
static int used_good_blocks = 0;
static unsigned long req_nr_inodes = 0;
-#define inode_in_use(x) (isset(inode_map,(x)))
-#define zone_in_use(x) (isset(zone_map,(x)-FIRSTZONE+1))
+#define zone_in_use(x) (isset(zone_map,(x)-FIRSTZONE+1) != 0)
#define mark_inode(x) (setbit(inode_map,(x)))
#define unmark_inode(x) (clrbit(inode_map,(x)))
#include <stdint.h>
#include <endian.h>
+/*
+ * Bit map related macros. Usually provided by libc.
+ */
+#include <sys/param.h>
+
+#ifndef NBBY
+# define NBBY CHAR_BIT
+#endif
+
+#ifndef setbit
+# define setbit(a,i) ((a)[(i)/NBBY] |= 1<<((i)%NBBY))
+# define clrbit(a,i) ((a)[(i)/NBBY] &= ~(1<<((i)%NBBY)))
+# define isset(a,i) ((a)[(i)/NBBY] & (1<<((i)%NBBY)))
+# define isclr(a,i) (((a)[(i)/NBBY] & (1<<((i)%NBBY))) == 0)
+#endif
+
#if !defined __BYTE_ORDER || !(__BYTE_ORDER == __LITTLE_ENDIAN) && !(__BYTE_ORDER == __BIG_ENDIAN)
#error missing __BYTE_ORDER
#endif