Many files:
  block.c (ext2fs_block_iterate2): Use retval which is a errcode_t type.
  bitmaps.c (make_bitmap): Use size_t instead of int where appropriate.
  bb_inode.c (set_bad_block_proc): Add #pragma argsused for Turbo C.
  alloc.c (ext2fs_new_inode): Use ino_t instead of int for the group number.
  get_pathname.c: Use ino_t instead of int where appropriate.
  ext2fs.h: Make the magic structure element be errcode_t instead of int.
  alloc.c alloc_tables.c badblocks.c bb_compat.c bb_inode.c
  	bitmaps.c block.c bmove.c brel_ma.c check_desc.c closefs.c
  	cmp_bitmaps.c dblist.c dblist_dir.c dir_iterate.c dirblock.c
  	dupfs.c expanddir.c freefs.c get_pathname.c icount.c
  	initialize.c inline.c inode.c irel_ma.c link.c llseek.c
  	lookup.c mkdir.c namei.c newdir.c read_bb.c read_bb_file.c
  	rs_bitmap.c rw_bitmaps.c swapfs.c test_io.c tst_badblocks.c
  	tst_iscan.c unix_io.c unlink.c valid_blk.c version.c: Add an
  	#ifdef for HAVE_UNISTD_H

diff --git a/lib/ext2fs/ChangeLog b/lib/ext2fs/ChangeLog
index 5733631..8d463da 100644
--- a/lib/ext2fs/ChangeLog
+++ b/lib/ext2fs/ChangeLog
@@ -1,3 +1,31 @@
+Sun Aug 10 10:05:22 1997  Theodore Ts'o  <tytso@rsts-11.mit.edu>
+
+	* block.c (ext2fs_block_iterate2): Use retval which is a errcode_t
+		type.
+
+	* bitmaps.c (make_bitmap): Use size_t instead of int where
+		appropriate.
+
+	* bb_inode.c (set_bad_block_proc): Add #pragma argsused for Turbo C.
+
+	* alloc.c (ext2fs_new_inode): Use ino_t instead of int for the
+		group number.
+
+	* get_pathname.c: Use ino_t instead of int where appropriate.
+
+	* ext2fs.h: Make the magic structure element be errcode_t instead
+		of int.
+
+	* alloc.c alloc_tables.c badblocks.c bb_compat.c bb_inode.c
+ 	 	bitmaps.c block.c bmove.c brel_ma.c check_desc.c closefs.c
+ 	 	cmp_bitmaps.c dblist.c dblist_dir.c dir_iterate.c
+ 	 	dirblock.c dupfs.c expanddir.c freefs.c get_pathname.c
+ 	 	icount.c initialize.c inline.c inode.c irel_ma.c link.c
+ 	 	llseek.c lookup.c mkdir.c namei.c newdir.c read_bb.c
+ 	 	read_bb_file.c rs_bitmap.c rw_bitmaps.c swapfs.c 
+ 	 	test_io.c tst_badblocks.c tst_iscan.c unix_io.c unlink.c
+ 	 	valid_blk.c version.c: Add an #ifdef for HAVE_UNISTD_H
+
 Tue Jun 17 01:33:20 1997  Theodore Ts'o  <tytso@rsts-11.mit.edu>
 
 	* unix_io.c (unix_read_blk): If ext2fs_llseek() fails, but errno
diff --git a/lib/ext2fs/alloc.c b/lib/ext2fs/alloc.c
index 50cee77..308e353 100644
--- a/lib/ext2fs/alloc.c
+++ b/lib/ext2fs/alloc.c
@@ -11,7 +11,9 @@
  */
 
 #include <stdio.h>
+#if HAVE_UNISTD_H
 #include <unistd.h>
+#endif
 #include <stdlib.h>
 #include <time.h>
 #include <sys/stat.h>
@@ -33,7 +35,7 @@
 errcode_t ext2fs_new_inode(ext2_filsys fs, ino_t dir, int mode,
 			   ext2fs_inode_bitmap map, ino_t *ret)
 {
-	int	dir_group = 0;
+	ino_t	dir_group = 0;
 	ino_t	i;
 	ino_t	start_inode;
 
diff --git a/lib/ext2fs/alloc_tables.c b/lib/ext2fs/alloc_tables.c
index 1c88557..a557db1 100644
--- a/lib/ext2fs/alloc_tables.c
+++ b/lib/ext2fs/alloc_tables.c
@@ -12,7 +12,9 @@
 
 #include <stdio.h>
 #include <string.h>
+#if HAVE_UNISTD_H
 #include <unistd.h>
+#endif
 #include <stdlib.h>
 #include <fcntl.h>
 #include <time.h>
diff --git a/lib/ext2fs/badblocks.c b/lib/ext2fs/badblocks.c
index 25444f0..75f6df0 100644
--- a/lib/ext2fs/badblocks.c
+++ b/lib/ext2fs/badblocks.c
@@ -11,7 +11,9 @@
 
 #include <stdio.h>
 #include <string.h>
+#if HAVE_UNISTD_H
 #include <unistd.h>
+#endif
 #include <stdlib.h>
 #include <fcntl.h>
 #include <time.h>
diff --git a/lib/ext2fs/bb_compat.c b/lib/ext2fs/bb_compat.c
index 38aeb8a..2a2c1ec 100644
--- a/lib/ext2fs/bb_compat.c
+++ b/lib/ext2fs/bb_compat.c
@@ -11,7 +11,9 @@
 
 #include <stdio.h>
 #include <string.h>
+#if HAVE_UNISTD_H
 #include <unistd.h>
+#endif
 #include <stdlib.h>
 #include <fcntl.h>
 #include <time.h>
diff --git a/lib/ext2fs/bb_inode.c b/lib/ext2fs/bb_inode.c
index a5dd3a9..7a9609c 100644
--- a/lib/ext2fs/bb_inode.c
+++ b/lib/ext2fs/bb_inode.c
@@ -15,7 +15,9 @@
 
 #include <stdio.h>
 #include <string.h>
+#if HAVE_UNISTD_H
 #include <unistd.h>
+#endif
 #include <stdlib.h>
 #include <fcntl.h>
 #include <time.h>
@@ -154,6 +156,9 @@
  * Clear the bad blocks in the bad block inode, while saving the
  * indirect blocks.
  */
+#ifdef __TURBOC__
+#pragma argsused
+#endif
 static int clear_bad_block_proc(ext2_filsys fs, blk_t *block_nr, int blockcnt,
 				blk_t ref_block, int ref_offset, void *private)
 {
@@ -207,6 +212,9 @@
  *
  * Set the block list in the bad block inode, using the supplied bitmap.
  */
+#ifdef __TURBOC__
+#pragma argsused
+#endif
 static int set_bad_block_proc(ext2_filsys fs, blk_t *block_nr,
 			      int blockcnt, blk_t ref_block, 
 			      int ref_offset, void *private)
diff --git a/lib/ext2fs/bitmaps.c b/lib/ext2fs/bitmaps.c
index defa0cd..46b4ee6 100644
--- a/lib/ext2fs/bitmaps.c
+++ b/lib/ext2fs/bitmaps.c
@@ -12,7 +12,9 @@
 
 #include <stdio.h>
 #include <string.h>
+#if HAVE_UNISTD_H
 #include <unistd.h>
+#endif
 #include <stdlib.h>
 #include <fcntl.h>
 #include <time.h>
@@ -31,7 +33,7 @@
 			     ext2fs_generic_bitmap *ret)
 {
 	ext2fs_generic_bitmap bitmap;
-	int	size;
+	size_t	size;
 
 	bitmap = malloc(sizeof(struct ext2fs_struct_generic_bitmap));
 	if (!bitmap)
@@ -53,7 +55,7 @@
 	} else
 		bitmap->description = 0;
 
-	size = ((bitmap->real_end - bitmap->start) / 8) + 1;
+	size = (size_t) (((bitmap->real_end - bitmap->start) / 8) + 1);
 	bitmap->bitmap = malloc(size);
 	if (!bitmap->bitmap) {
 		free(bitmap->description);
@@ -187,7 +189,7 @@
 		return;
 
 	memset(bitmap->bitmap, 0,
-	       ((bitmap->real_end - bitmap->start) / 8) + 1);
+	       (size_t) (((bitmap->real_end - bitmap->start) / 8) + 1));
 }
 
 void ext2fs_clear_block_bitmap(ext2fs_block_bitmap bitmap)
@@ -196,5 +198,5 @@
 		return;
 
 	memset(bitmap->bitmap, 0,
-	       ((bitmap->real_end - bitmap->start) / 8) + 1);
+	       (size_t) (((bitmap->real_end - bitmap->start) / 8) + 1));
 }
diff --git a/lib/ext2fs/block.c b/lib/ext2fs/block.c
index 03bf5f3..c1709d9 100644
--- a/lib/ext2fs/block.c
+++ b/lib/ext2fs/block.c
@@ -11,7 +11,9 @@
 
 #include <stdio.h>
 #include <string.h>
+#if HAVE_UNISTD_H
 #include <unistd.h>
+#endif
 #include <stdlib.h>
 #if HAVE_ERRNO_H
 #include <errno.h>
@@ -321,9 +323,9 @@
 
 	EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS);
 
-	ret = ext2fs_get_blocks(fs, ino, blocks);
-	if (ret)
-		return ret;
+	retval = ext2fs_get_blocks(fs, ino, blocks);
+	if (retval)
+		return retval;
 
 	ctx.fs = fs;
 	ctx.func = func;
diff --git a/lib/ext2fs/bmove.c b/lib/ext2fs/bmove.c
index c355453..6bcd74d 100644
--- a/lib/ext2fs/bmove.c
+++ b/lib/ext2fs/bmove.c
@@ -8,7 +8,9 @@
 
 #include <stdio.h>
 #include <string.h>
+#if HAVE_UNISTD_H
 #include <unistd.h>
+#endif
 #include <stdlib.h>
 #include <sys/types.h>
 #include <sys/time.h>
diff --git a/lib/ext2fs/brel_ma.c b/lib/ext2fs/brel_ma.c
index a4258a7..aadd4f4 100644
--- a/lib/ext2fs/brel_ma.c
+++ b/lib/ext2fs/brel_ma.c
@@ -13,8 +13,12 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#if HAVE_UNISTD_H
 #include <unistd.h>
+#endif
+#if HAVE_ERRNO_H
 #include <errno.h>
+#endif
 
 #include <linux/ext2_fs.h>
 
diff --git a/lib/ext2fs/check_desc.c b/lib/ext2fs/check_desc.c
index 74b3e2d..fca0bb4 100644
--- a/lib/ext2fs/check_desc.c
+++ b/lib/ext2fs/check_desc.c
@@ -11,7 +11,9 @@
 
 #include <stdio.h>
 #include <string.h>
+#if HAVE_UNISTD_H
 #include <unistd.h>
+#endif
 #include <stdlib.h>
 #include <fcntl.h>
 #include <time.h>
diff --git a/lib/ext2fs/closefs.c b/lib/ext2fs/closefs.c
index 4678d9e..3883055 100644
--- a/lib/ext2fs/closefs.c
+++ b/lib/ext2fs/closefs.c
@@ -10,7 +10,9 @@
  */
 
 #include <stdio.h>
+#if HAVE_UNISTD_H
 #include <unistd.h>
+#endif
 #include <stdlib.h>
 #include <time.h>
 #include <string.h>
diff --git a/lib/ext2fs/cmp_bitmaps.c b/lib/ext2fs/cmp_bitmaps.c
index 3d04a97..21fe42a 100644
--- a/lib/ext2fs/cmp_bitmaps.c
+++ b/lib/ext2fs/cmp_bitmaps.c
@@ -11,7 +11,9 @@
 
 #include <stdio.h>
 #include <string.h>
+#if HAVE_UNISTD_H
 #include <unistd.h>
+#endif
 #include <stdlib.h>
 #include <fcntl.h>
 #include <time.h>
diff --git a/lib/ext2fs/dblist.c b/lib/ext2fs/dblist.c
index 88763fc..6273935 100644
--- a/lib/ext2fs/dblist.c
+++ b/lib/ext2fs/dblist.c
@@ -11,7 +11,9 @@
  */
 
 #include <stdio.h>
+#if HAVE_UNISTD_H
 #include <unistd.h>
+#endif
 #include <stdlib.h>
 #include <string.h>
 #include <time.h>
diff --git a/lib/ext2fs/dblist_dir.c b/lib/ext2fs/dblist_dir.c
index 10c7b58..ebbf17a 100644
--- a/lib/ext2fs/dblist_dir.c
+++ b/lib/ext2fs/dblist_dir.c
@@ -11,7 +11,9 @@
  */
 
 #include <stdio.h>
+#if HAVE_UNISTD_H
 #include <unistd.h>
+#endif
 #include <stdlib.h>
 #include <string.h>
 #include <time.h>
diff --git a/lib/ext2fs/dir_iterate.c b/lib/ext2fs/dir_iterate.c
index 91f8ca6..40c289b 100644
--- a/lib/ext2fs/dir_iterate.c
+++ b/lib/ext2fs/dir_iterate.c
@@ -11,7 +11,9 @@
 
 #include <stdio.h>
 #include <string.h>
+#if HAVE_UNISTD_H
 #include <unistd.h>
+#endif
 #include <stdlib.h>
 #if HAVE_ERRNO_H
 #include <errno.h>
diff --git a/lib/ext2fs/dirblock.c b/lib/ext2fs/dirblock.c
index 4db5b18..4f8b94b 100644
--- a/lib/ext2fs/dirblock.c
+++ b/lib/ext2fs/dirblock.c
@@ -10,7 +10,9 @@
  */
 
 #include <stdio.h>
+#if HAVE_UNISTD_H
 #include <unistd.h>
+#endif
 #include <stdlib.h>
 #include <string.h>
 #include <time.h>
diff --git a/lib/ext2fs/dupfs.c b/lib/ext2fs/dupfs.c
index b2eee0b..f7edd83 100644
--- a/lib/ext2fs/dupfs.c
+++ b/lib/ext2fs/dupfs.c
@@ -10,7 +10,9 @@
  */
 
 #include <stdio.h>
+#if HAVE_UNISTD_H
 #include <unistd.h>
+#endif
 #include <stdlib.h>
 #include <time.h>
 #include <string.h>
diff --git a/lib/ext2fs/expanddir.c b/lib/ext2fs/expanddir.c
index 852b40f..39852c2 100644
--- a/lib/ext2fs/expanddir.c
+++ b/lib/ext2fs/expanddir.c
@@ -11,7 +11,9 @@
 
 #include <stdio.h>
 #include <string.h>
+#if HAVE_UNISTD_H
 #include <unistd.h>
+#endif
 #include <stdlib.h>
 #if HAVE_ERRNO_H
 #include <errno.h>
diff --git a/lib/ext2fs/ext2fs.h b/lib/ext2fs/ext2fs.h
index 57dfacd..8409e61 100644
--- a/lib/ext2fs/ext2fs.h
+++ b/lib/ext2fs/ext2fs.h
@@ -45,7 +45,7 @@
 typedef struct struct_ext2_filsys *ext2_filsys;
 
 struct ext2fs_struct_generic_bitmap {
-	int		magic;
+	errcode_t	magic;
 	ext2_filsys 	fs;
 	__u32		start, end;
 	__u32		real_end;
@@ -119,7 +119,7 @@
 #define EXT2_NEW_INODE_FL	0x80000000
 
 struct struct_ext2_filsys {
-	int				magic;
+	errcode_t			magic;
 	io_channel			io;
 	int				flags;
 	char *				device_name;
diff --git a/lib/ext2fs/freefs.c b/lib/ext2fs/freefs.c
index 43331ab..8d1da19 100644
--- a/lib/ext2fs/freefs.c
+++ b/lib/ext2fs/freefs.c
@@ -10,7 +10,9 @@
  */
 
 #include <stdio.h>
+#if HAVE_UNISTD_H
 #include <unistd.h>
+#endif
 #include <stdlib.h>
 
 #include <linux/ext2_fs.h>
diff --git a/lib/ext2fs/get_pathname.c b/lib/ext2fs/get_pathname.c
index 8c94e93..adce200 100644
--- a/lib/ext2fs/get_pathname.c
+++ b/lib/ext2fs/get_pathname.c
@@ -20,7 +20,9 @@
 
 #include <stdio.h>
 #include <string.h>
+#if HAVE_UNISTD_H
 #include <unistd.h>
+#endif
 #include <stdlib.h>
 #if HAVE_ERRNO_H
 #include <errno.h>
@@ -31,12 +33,15 @@
 #include "ext2fs.h"
 
 struct get_pathname_struct {
-	int		search_ino;
-	int		parent;
+	ino_t		search_ino;
+	ino_t		parent;
 	char		*name;
 	errcode_t	errcode;
 };
 
+#ifdef __TURBOC__
+#pragma argsused
+#endif
 static int get_pathname_proc(struct ext2_dir_entry *dirent,
 			     int	offset,
 			     int	blocksize,
diff --git a/lib/ext2fs/icount.c b/lib/ext2fs/icount.c
index 7c68680..5bffc18 100644
--- a/lib/ext2fs/icount.c
+++ b/lib/ext2fs/icount.c
@@ -10,7 +10,9 @@
  */
 
 #include <et/com_err.h>
+#if HAVE_UNISTD_H
 #include <unistd.h>
+#endif
 #include <stdlib.h>
 #include <string.h>
 #include <stdio.h>
diff --git a/lib/ext2fs/initialize.c b/lib/ext2fs/initialize.c
index f9e744b..c1f3608 100644
--- a/lib/ext2fs/initialize.c
+++ b/lib/ext2fs/initialize.c
@@ -12,7 +12,9 @@
 
 #include <stdio.h>
 #include <string.h>
+#if HAVE_UNISTD_H
 #include <unistd.h>
+#endif
 #include <stdlib.h>
 #include <fcntl.h>
 #include <time.h>
diff --git a/lib/ext2fs/inline.c b/lib/ext2fs/inline.c
index 3451c35..d5ee683 100644
--- a/lib/ext2fs/inline.c
+++ b/lib/ext2fs/inline.c
@@ -14,7 +14,9 @@
 
 #include <stdio.h>
 #include <string.h>
+#if HAVE_UNISTD_H
 #include <unistd.h>
+#endif
 #include <stdlib.h>
 #include <fcntl.h>
 #include <time.h>
diff --git a/lib/ext2fs/inode.c b/lib/ext2fs/inode.c
index 3806ac6..ddca41c 100644
--- a/lib/ext2fs/inode.c
+++ b/lib/ext2fs/inode.c
@@ -11,7 +11,9 @@
 
 #include <stdio.h>
 #include <string.h>
+#if HAVE_UNISTD_H
 #include <unistd.h>
+#endif
 #include <stdlib.h>
 #include <sys/stat.h>
 #include <sys/types.h>
diff --git a/lib/ext2fs/irel_ma.c b/lib/ext2fs/irel_ma.c
index 1bb3af6..3a8538c 100644
--- a/lib/ext2fs/irel_ma.c
+++ b/lib/ext2fs/irel_ma.c
@@ -13,8 +13,12 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#if HAVE_UNISTD_H
 #include <unistd.h>
+#endif
+#if HAVE_ERRNO_H
 #include <errno.h>
+#endif
 
 #include <linux/ext2_fs.h>
 
diff --git a/lib/ext2fs/link.c b/lib/ext2fs/link.c
index 933dfa8..63b11b4 100644
--- a/lib/ext2fs/link.c
+++ b/lib/ext2fs/link.c
@@ -11,7 +11,9 @@
 
 #include <stdio.h>
 #include <string.h>
+#if HAVE_UNISTD_H
 #include <unistd.h>
+#endif
 #include <stdlib.h>
 
 #include <linux/ext2_fs.h>
diff --git a/lib/ext2fs/llseek.c b/lib/ext2fs/llseek.c
index 71a9d91..986bf0b 100644
--- a/lib/ext2fs/llseek.c
+++ b/lib/ext2fs/llseek.c
@@ -12,14 +12,18 @@
 #include <sys/types.h>
 
 #include <errno.h>
+#if HAVE_UNISTD_H
 #include <unistd.h>
+#endif
 #include "et/com_err.h"
 #include "ext2fs/io.h"
 
 #ifdef __linux__
 
 #ifdef HAVE_LLSEEK
+#if HAVE_UNISTD_H
 #include <unistd.h>
+#endif
 #include <syscall.h>
 
 #else	/* HAVE_LLSEEK */
diff --git a/lib/ext2fs/lookup.c b/lib/ext2fs/lookup.c
index 5cded5f..575806e 100644
--- a/lib/ext2fs/lookup.c
+++ b/lib/ext2fs/lookup.c
@@ -11,7 +11,9 @@
 
 #include <stdio.h>
 #include <string.h>
+#if HAVE_UNISTD_H
 #include <unistd.h>
+#endif
 #include <stdlib.h>
 #if HAVE_ERRNO_H
 #include <errno.h>
diff --git a/lib/ext2fs/mkdir.c b/lib/ext2fs/mkdir.c
index 67a2046..649f05a 100644
--- a/lib/ext2fs/mkdir.c
+++ b/lib/ext2fs/mkdir.c
@@ -11,7 +11,9 @@
 
 #include <stdio.h>
 #include <string.h>
+#if HAVE_UNISTD_H
 #include <unistd.h>
+#endif
 #include <stdlib.h>
 #include <fcntl.h>
 #include <time.h>
diff --git a/lib/ext2fs/namei.c b/lib/ext2fs/namei.c
index ae39eec..9824977 100644
--- a/lib/ext2fs/namei.c
+++ b/lib/ext2fs/namei.c
@@ -11,7 +11,9 @@
 
 #include <stdio.h>
 #include <string.h>
+#if HAVE_UNISTD_H
 #include <unistd.h>
+#endif
 #include <stdlib.h>
 #if HAVE_ERRNO_H
 #include <errno.h>
diff --git a/lib/ext2fs/newdir.c b/lib/ext2fs/newdir.c
index 863960f..074a722 100644
--- a/lib/ext2fs/newdir.c
+++ b/lib/ext2fs/newdir.c
@@ -11,7 +11,9 @@
 
 #include <stdio.h>
 #include <string.h>
+#if HAVE_UNISTD_H
 #include <unistd.h>
+#endif
 #include <stdlib.h>
 #if HAVE_ERRNO_H
 #include <errno.h>
diff --git a/lib/ext2fs/read_bb.c b/lib/ext2fs/read_bb.c
index 3fabddd..6934ab9 100644
--- a/lib/ext2fs/read_bb.c
+++ b/lib/ext2fs/read_bb.c
@@ -11,7 +11,9 @@
 
 #include <stdio.h>
 #include <string.h>
+#if HAVE_UNISTD_H
 #include <unistd.h>
+#endif
 #include <stdlib.h>
 #include <fcntl.h>
 #include <time.h>
diff --git a/lib/ext2fs/read_bb_file.c b/lib/ext2fs/read_bb_file.c
index 16c2e0b..32a8083 100644
--- a/lib/ext2fs/read_bb_file.c
+++ b/lib/ext2fs/read_bb_file.c
@@ -11,7 +11,9 @@
 
 #include <stdio.h>
 #include <string.h>
+#if HAVE_UNISTD_H
 #include <unistd.h>
+#endif
 #include <stdlib.h>
 #include <fcntl.h>
 #include <time.h>
diff --git a/lib/ext2fs/rs_bitmap.c b/lib/ext2fs/rs_bitmap.c
index c41b5e6..02e3dd1 100644
--- a/lib/ext2fs/rs_bitmap.c
+++ b/lib/ext2fs/rs_bitmap.c
@@ -11,7 +11,9 @@
 
 #include <stdio.h>
 #include <string.h>
+#if HAVE_UNISTD_H
 #include <unistd.h>
+#endif
 #include <stdlib.h>
 #include <fcntl.h>
 #include <time.h>
diff --git a/lib/ext2fs/rw_bitmaps.c b/lib/ext2fs/rw_bitmaps.c
index e9bb58c..bbde132 100644
--- a/lib/ext2fs/rw_bitmaps.c
+++ b/lib/ext2fs/rw_bitmaps.c
@@ -11,7 +11,9 @@
 
 #include <stdio.h>
 #include <string.h>
+#if HAVE_UNISTD_H
 #include <unistd.h>
+#endif
 #include <stdlib.h>
 #include <fcntl.h>
 #include <time.h>
diff --git a/lib/ext2fs/swapfs.c b/lib/ext2fs/swapfs.c
index de347ac..b4330d6 100644
--- a/lib/ext2fs/swapfs.c
+++ b/lib/ext2fs/swapfs.c
@@ -10,7 +10,9 @@
  */
 
 #include <stdio.h>
+#if HAVE_UNISTD_H
 #include <unistd.h>
+#endif
 #include <stdlib.h>
 #include <time.h>
 
diff --git a/lib/ext2fs/test_io.c b/lib/ext2fs/test_io.c
index a82f094..65c4d10 100644
--- a/lib/ext2fs/test_io.c
+++ b/lib/ext2fs/test_io.c
@@ -11,7 +11,9 @@
 
 #include <stdio.h>
 #include <string.h>
+#if HAVE_UNISTD_H
 #include <unistd.h>
+#endif
 #include <stdlib.h>
 #include <fcntl.h>
 #include <time.h>
diff --git a/lib/ext2fs/tst_badblocks.c b/lib/ext2fs/tst_badblocks.c
index d071406..2063420 100644
--- a/lib/ext2fs/tst_badblocks.c
+++ b/lib/ext2fs/tst_badblocks.c
@@ -11,7 +11,9 @@
 
 #include <stdio.h>
 #include <string.h>
+#if HAVE_UNISTD_H
 #include <unistd.h>
+#endif
 #include <stdlib.h>
 #include <fcntl.h>
 #include <time.h>
diff --git a/lib/ext2fs/tst_iscan.c b/lib/ext2fs/tst_iscan.c
index dbf0813..2febe62 100644
--- a/lib/ext2fs/tst_iscan.c
+++ b/lib/ext2fs/tst_iscan.c
@@ -11,7 +11,9 @@
 
 #include <stdio.h>
 #include <string.h>
+#if HAVE_UNISTD_H
 #include <unistd.h>
+#endif
 #include <stdlib.h>
 #include <fcntl.h>
 #include <time.h>
diff --git a/lib/ext2fs/unix_io.c b/lib/ext2fs/unix_io.c
index 2be3e70..0baae38 100644
--- a/lib/ext2fs/unix_io.c
+++ b/lib/ext2fs/unix_io.c
@@ -13,7 +13,9 @@
 
 #include <stdio.h>
 #include <string.h>
+#if HAVE_UNISTD_H
 #include <unistd.h>
+#endif
 #include <stdlib.h>
 #include <fcntl.h>
 #include <time.h>
diff --git a/lib/ext2fs/unlink.c b/lib/ext2fs/unlink.c
index e0309aa..9c55423 100644
--- a/lib/ext2fs/unlink.c
+++ b/lib/ext2fs/unlink.c
@@ -11,7 +11,9 @@
 
 #include <stdio.h>
 #include <string.h>
+#if HAVE_UNISTD_H
 #include <unistd.h>
+#endif
 #include <stdlib.h>
 
 #include <linux/ext2_fs.h>
diff --git a/lib/ext2fs/valid_blk.c b/lib/ext2fs/valid_blk.c
index 3a0cb3e..ff49f80 100644
--- a/lib/ext2fs/valid_blk.c
+++ b/lib/ext2fs/valid_blk.c
@@ -11,7 +11,9 @@
  */
 
 #include <stdio.h>
+#if HAVE_UNISTD_H
 #include <unistd.h>
+#endif
 #include <stdlib.h>
 #include <string.h>
 #include <time.h>
diff --git a/lib/ext2fs/version.c b/lib/ext2fs/version.c
index 38accf6..9e489ec 100644
--- a/lib/ext2fs/version.c
+++ b/lib/ext2fs/version.c
@@ -10,7 +10,9 @@
  */
 
 #include <et/com_err.h>
+#if HAVE_UNISTD_H
 #include <unistd.h>
+#endif
 #include <stdlib.h>
 #include <string.h>
 #include <stdio.h>