Index: aclocal.m4
===================================================================
RCS file: /cvsroot/hurd/hurd/aclocal.m4,v
retrieving revision 1.5
diff -u -r1.5 aclocal.m4
--- aclocal.m4	15 Feb 2003 23:57:50 -0000	1.5
+++ aclocal.m4	9 Aug 2003 12:03:53 -0000
@@ -26,6 +26,14 @@
   AC_DEFINE(HAVE_MIG_RETCODE)
 fi])
 
+AC_DEFUN([hurd_TYPE_CHECK], [dnl
+AC_CACHE_CHECK(for $1 in mach/mach_types.h, hurd_cv_mach_$1,
+AC_TRY_COMPILE([#include <mach/mach_types.h>], [extern $1 foo;],
+hurd_cv_mach_$1=$1, hurd_cv_mach_$1=$2))
+if test [$]hurd_cv_mach_$1 != $1; then
+  CPPFLAGS="$CPPFLAGS -D$1=$2"
+fi])
+
 dnl The following check is based on a similar check in GNU inetutils 1.4.0.
 dnl
 dnl hurd_LIB_NCURSESW -- check for, and configure, ncursesw
@@ -79,4 +87,3 @@
   fi
   AC_SUBST(NCURSESW_INCLUDE)
   AC_SUBST(LIBNCURSESW)])dnl
-
Index: configure
===================================================================
RCS file: /cvsroot/hurd/hurd/configure,v
retrieving revision 1.1
diff -u -r1.1 configure
--- configure	15 Feb 2003 23:58:22 -0000	1.1
+++ configure	9 Aug 2003 12:03:55 -0000
@@ -2889,6 +2889,100 @@
 _ACEOF
 
 fi
+echo "$as_me:$LINENO: checking for task_t in mach/mach_types.h" >&5
+echo $ECHO_N "checking for task_t in mach/mach_types.h... $ECHO_C" >&6
+if test "${hurd_cv_mach_task_t+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <mach/mach_types.h>
+int
+main ()
+{
+extern task_t foo;
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  hurd_cv_mach_task_t=task_t
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+hurd_cv_mach_task_t=task_port_t
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $hurd_cv_mach_task_t" >&5
+echo "${ECHO_T}$hurd_cv_mach_task_t" >&6
+if test $hurd_cv_mach_task_t != task_t; then
+  CPPFLAGS="$CPPFLAGS -Dtask_t=task_port_t"
+fi
+echo "$as_me:$LINENO: checking for thread_t in mach/mach_types.h" >&5
+echo $ECHO_N "checking for thread_t in mach/mach_types.h... $ECHO_C" >&6
+if test "${hurd_cv_mach_thread_t+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <mach/mach_types.h>
+int
+main ()
+{
+extern thread_t foo;
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  hurd_cv_mach_thread_t=thread_t
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+hurd_cv_mach_thread_t=thread_port_t
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $hurd_cv_mach_thread_t" >&5
+echo "${ECHO_T}$hurd_cv_mach_thread_t" >&6
+if test $hurd_cv_mach_thread_t != thread_t; then
+  CPPFLAGS="$CPPFLAGS -Dthread_t=thread_port_t"
+fi
 
 # See if --version-script is available.
 echo "$as_me:$LINENO: checking for ld --version-script" >&5
Index: configure.in
===================================================================
RCS file: /cvsroot/hurd/hurd/configure.in,v
retrieving revision 1.35
diff -u -r1.35 configure.in
--- configure.in	15 Feb 2003 23:57:50 -0000	1.35
+++ configure.in	9 Aug 2003 12:03:55 -0000
@@ -96,6 +96,8 @@
 AC_SUBST(LIBCRYPT)
 
 hurd_MIG_RETCODE
+hurd_TYPE_CHECK(task_t, task_port_t)
+hurd_TYPE_CHECK(thread_t, thread_port_t)
 
 # See if --version-script is available.
 AC_CACHE_CHECK(for ld --version-script, hurd_cv_ld_version_script_option, [dnl
Index: ext2fs/balloc.c
===================================================================
RCS file: /cvsroot/hurd/hurd/ext2fs/balloc.c,v
retrieving revision 1.28
diff -u -r1.28 balloc.c
--- ext2fs/balloc.c	10 Mar 2000 04:54:55 -0000	1.28
+++ ext2fs/balloc.c	9 Aug 2003 12:03:59 -0000
@@ -65,8 +65,8 @@
 
   spin_lock (&global_lock);
 
-  if (block < sblock->s_first_data_block ||
-      (block + count) > sblock->s_blocks_count)
+  if (block < le32_to_cpu (sblock->s_first_data_block) ||
+      (block + count) > le32_to_cpu (sblock->s_blocks_count))
     {
       ext2_error ("freeing blocks not in datazone - "
 		  "block = %u, count = %lu", block, count);
@@ -80,24 +80,26 @@
     {
       unsigned long int gcount = count;
 
-      block_group = ((block - sblock->s_first_data_block)
-		     / sblock->s_blocks_per_group);
-      bit = (block - sblock->s_first_data_block) % sblock->s_blocks_per_group;
-      if (bit + count > sblock->s_blocks_per_group)
+      block_group = ((block - le32_to_cpu (sblock->s_first_data_block))
+		     / le32_to_cpu (sblock->s_blocks_per_group));
+      bit = (block - le32_to_cpu (sblock->s_first_data_block))
+	% le32_to_cpu (sblock->s_blocks_per_group);
+      if (bit + count > le32_to_cpu (sblock->s_blocks_per_group))
 	{
-	  unsigned long overflow = bit + count - sblock->s_blocks_per_group;
+	  unsigned long overflow = bit + count - le32_to_cpu (sblock->s_blocks_per_group);
 	  gcount -= overflow;
 	  ext2_debug ("freeing blocks across group boundary - "
 		      "block = %u, count = %lu",
 		      block, count);
 	}
       gdp = group_desc (block_group);
-      bh = bptr (gdp->bg_block_bitmap);
+      bh = bptr (le32_to_cpu (gdp->bg_block_bitmap));
 
-      if (in_range (gdp->bg_block_bitmap, block, gcount) ||
-	  in_range (gdp->bg_inode_bitmap, block, gcount) ||
-	  in_range (block, gdp->bg_inode_table, itb_per_group) ||
-	  in_range (block + gcount - 1, gdp->bg_inode_table, itb_per_group))
+      if (in_range (le32_to_cpu (gdp->bg_block_bitmap), block, gcount) ||
+	  in_range (le32_to_cpu (gdp->bg_inode_bitmap), block, gcount) ||
+	  in_range (block, le32_to_cpu (gdp->bg_inode_table), itb_per_group) ||
+	  in_range (block + gcount - 1, le32_to_cpu (gdp->bg_inode_table),
+		    itb_per_group))
 	ext2_panic ("freeing blocks in system zones - "
 		    "block = %u, count = %lu",
 		    block, count);
@@ -108,8 +110,10 @@
 	    ext2_warning ("bit already cleared for block %lu", block + i);
 	  else
 	    {
-	      gdp->bg_free_blocks_count++;
-	      sblock->s_free_blocks_count++;
+	      gdp->bg_free_blocks_count = cpu_to_le16
+		(le16_to_cpu (gdp->bg_free_blocks_count) + 1);
+	      sblock->s_free_blocks_count = cpu_to_le32
+		(le32_to_cpu (sblock->s_free_blocks_count) + 1);
 	    }
 	}
 
@@ -152,7 +156,8 @@
   spin_lock (&global_lock);
 
 #ifdef XXX /* Auth check to use reserved blocks  */
-  if (sblock->s_free_blocks_count <= sblock->s_r_blocks_count &&
+  if (le32_to_cpu (sblock->s_free_blocks_count)
+      <= le32_to_cpu (sblock->s_r_blocks_count) &&
       (!fsuser () && (sb->u.ext2_sb.s_resuid != current->fsuid) &&
        (sb->u.ext2_sb.s_resgid == 0 ||
 	!in_group_p (sb->u.ext2_sb.s_resgid))))
@@ -168,18 +173,21 @@
   /*
      * First, test whether the goal block is free.
    */
-  if (goal < sblock->s_first_data_block || goal >= sblock->s_blocks_count)
-    goal = sblock->s_first_data_block;
-  i = (goal - sblock->s_first_data_block) / sblock->s_blocks_per_group;
+  if (goal < le32_to_cpu (sblock->s_first_data_block)
+      || goal >= le32_to_cpu (sblock->s_blocks_count))
+    goal = le32_to_cpu (sblock->s_first_data_block);
+  i = (goal - le32_to_cpu (sblock->s_first_data_block))
+    / le32_to_cpu (sblock->s_blocks_per_group);
   gdp = group_desc (i);
-  if (gdp->bg_free_blocks_count > 0)
+  if (le16_to_cpu (gdp->bg_free_blocks_count) > 0)
     {
-      j = ((goal - sblock->s_first_data_block) % sblock->s_blocks_per_group);
+      j = ((goal - le32_to_cpu (sblock->s_first_data_block))
+	   % le32_to_cpu (sblock->s_blocks_per_group));
 #ifdef EXT2FS_DEBUG
       if (j)
 	goal_attempts++;
 #endif
-      bh = bptr (gdp->bg_block_bitmap);
+      bh = bptr (le32_to_cpu (gdp->bg_block_bitmap));
 
       ext2_debug ("goal is at %d:%d", i, j);
 
@@ -197,17 +205,17 @@
 	     * The goal was occupied; search forward for a free
 	     * block within the next 32 blocks
 	   */
-	  lmap = ((((unsigned long *) bh)[j >> 5]) >>
+	  lmap = (le32_to_cpu (((unsigned long *) bh)[j >> 5]) >>
 		  ((j & 31) + 1));
-	  if (j < sblock->s_blocks_per_group - 32)
-	    lmap |= (((unsigned long *) bh)[(j >> 5) + 1]) <<
-	      (31 - (j & 31));
+	  if (j < le32_to_cpu (sblock->s_blocks_per_group) - 32)
+	    lmap |= (le32_to_cpu (((unsigned long *) bh)[(j >> 5) + 1]) <<
+	      (31 - (j & 31)));
 	  else
 	    lmap |= 0xffffffff << (31 - (j & 31));
 	  if (lmap != 0xffffffffl)
 	    {
 	      k = ffz (lmap) + 1;
-	      if ((j + k) < sblock->s_blocks_per_group)
+	      if ((j + k) < le32_to_cpu (sblock->s_blocks_per_group))
 		{
 		  j += k;
 		  goto got_block;
@@ -227,17 +235,17 @@
        * cyclicly search through the rest of the groups.
        */
       p = ((char *) bh) + (j >> 3);
-      r = memscan (p, 0, (sblock->s_blocks_per_group - j + 7) >> 3);
+      r = memscan (p, 0, (le32_to_cpu (sblock->s_blocks_per_group) - j + 7) >> 3);
       k = (r - ((char *) bh)) << 3;
-      if (k < sblock->s_blocks_per_group)
+      if (k < le32_to_cpu (sblock->s_blocks_per_group))
 	{
 	  j = k;
 	  goto search_back;
 	}
       k = find_next_zero_bit ((unsigned long *) bh,
-			      sblock->s_blocks_per_group,
+			      le32_to_cpu (sblock->s_blocks_per_group),
 			      j);
-      if (k < sblock->s_blocks_per_group)
+      if (k < le32_to_cpu (sblock->s_blocks_per_group))
 	{
 	  j = k;
 	  goto got_block;
@@ -256,7 +264,7 @@
       if (i >= groups_count)
 	i = 0;
       gdp = group_desc (i);
-      if (gdp->bg_free_blocks_count > 0)
+      if (le16_to_cpu (gdp->bg_free_blocks_count) > 0)
 	break;
     }
   if (k >= groups_count)
@@ -264,15 +272,15 @@
       spin_unlock (&global_lock);
       return 0;
     }
-  bh = bptr (gdp->bg_block_bitmap);
-  r = memscan (bh, 0, sblock->s_blocks_per_group >> 3);
+  bh = bptr (le32_to_cpu (gdp->bg_block_bitmap));
+  r = memscan (bh, 0, le32_to_cpu (sblock->s_blocks_per_group) >> 3);
   j = (r - bh) << 3;
-  if (j < sblock->s_blocks_per_group)
+  if (j < le32_to_cpu (sblock->s_blocks_per_group))
     goto search_back;
   else
     j = find_first_zero_bit ((unsigned long *) bh,
-			     sblock->s_blocks_per_group);
-  if (j >= sblock->s_blocks_per_group)
+			     le32_to_cpu (sblock->s_blocks_per_group));
+  if (j >= le32_to_cpu (sblock->s_blocks_per_group))
     {
       ext2_error ("free blocks count corrupted for block group %d", i);
       spin_unlock (&global_lock);
@@ -289,13 +297,14 @@
 
 got_block:
 
-  ext2_debug ("using block group %d (%d)", i, gdp->bg_free_blocks_count);
+  ext2_debug ("using block group %d (%d)", i, le16_to_cpu (gdp->bg_free_blocks_count));
 
-  tmp = j + i * sblock->s_blocks_per_group + sblock->s_first_data_block;
+  tmp = j + i * le32_to_cpu (sblock->s_blocks_per_group)
+    + le32_to_cpu (sblock->s_first_data_block);
 
-  if (tmp == gdp->bg_block_bitmap ||
-      tmp == gdp->bg_inode_bitmap ||
-      in_range (tmp, gdp->bg_inode_table, itb_per_group))
+  if (tmp == le32_to_cpu (gdp->bg_block_bitmap) ||
+      tmp == le32_to_cpu (gdp->bg_inode_bitmap) ||
+      in_range (tmp, le32_to_cpu (gdp->bg_inode_table), itb_per_group))
     ext2_panic ("allocating block in system zone; block = %u", tmp);
 
   if (set_bit (j, bh))
@@ -325,7 +334,8 @@
       *prealloc_count = 0;
       *prealloc_block = tmp + 1;
       for (k = 1;
-	   k < prealloc_goal && (j + k) < sblock->s_blocks_per_group; k++)
+	   k < prealloc_goal && (j + k) < le32_to_cpu (sblock->s_blocks_per_group);
+	   k++)
 	{
 	  if (set_bit (j + k, bh))
 	    break;
@@ -339,8 +349,10 @@
 	      spin_unlock (&modified_global_blocks_lock);
 	    }
 	}
-      gdp->bg_free_blocks_count -= *prealloc_count;
-      sblock->s_free_blocks_count -= *prealloc_count;
+      gdp->bg_free_blocks_count = cpu_to_le16
+	(le16_to_cpu (gdp->bg_free_blocks_count) - *prealloc_count);
+      sblock->s_free_blocks_count = cpu_to_le32
+	(le32_to_cpu (sblock->s_free_blocks_count) - *prealloc_count);
       ext2_debug ("preallocated a further %u bits", *prealloc_count);
     }
 #endif
@@ -349,7 +361,7 @@
 
   record_global_poke (bh);
 
-  if (j >= sblock->s_blocks_count)
+  if (j >= le32_to_cpu (sblock->s_blocks_count))
     {
       ext2_error ("block >= blocks count - block_group = %d, block=%d", i, j);
       j = 0;
@@ -359,10 +371,12 @@
   ext2_debug ("allocating block %d; goal hits %d of %d",
 	      j, goal_hits, goal_attempts);
 
-  gdp->bg_free_blocks_count--;
+  gdp->bg_free_blocks_count = cpu_to_le16
+    (le16_to_cpu (gdp->bg_free_blocks_count) - 1);
   record_global_poke (gdp);
 
-  sblock->s_free_blocks_count--;
+  sblock->s_free_blocks_count = cpu_to_le32
+    (le32_to_cpu (sblock->s_free_blocks_count) - 1);
   sblock_dirty = 1;
 
  sync_out:
@@ -388,26 +402,26 @@
   for (i = 0; i < groups_count; i++)
     {
       gdp = group_desc (i);
-      desc_count += gdp->bg_free_blocks_count;
-      x = count_free (bptr (gdp->bg_block_bitmap), block_size);
+      desc_count += le16_to_cpu (gdp->bg_free_blocks_count);
+      x = count_free (bptr (le32_to_cpu (gdp->bg_block_bitmap)), block_size);
       printf ("group %d: stored = %d, counted = %lu",
 	      i, gdp->bg_free_blocks_count, x);
       bitmap_count += x;
     }
   printf ("ext2_count_free_blocks: stored = %u, computed = %lu, %lu",
-	  sblock->s_free_blocks_count, desc_count, bitmap_count);
+	  le32_to_cpu (sblock->s_free_blocks_count), desc_count, bitmap_count);
   spin_unlock (&global_lock);
   return bitmap_count;
 #else
-  return sblock->s_free_blocks_count;
+  return le32_to_cpu (sblock->s_free_blocks_count);
 #endif
 }
 
 static inline int
 block_in_use (block_t block, unsigned char *map)
 {
-  return test_bit ((block - sblock->s_first_data_block) %
-		   sblock->s_blocks_per_group, map);
+  return test_bit ((block - le32_to_cpu (sblock->s_first_data_block)) %
+		   le32_to_cpu (sblock->s_blocks_per_group), map);
 }
 
 void
@@ -449,8 +463,8 @@
 	}
 
       gdp = group_desc (i);
-      desc_count += gdp->bg_free_blocks_count;
-      bh = bptr (gdp->bg_block_bitmap);
+      desc_count += le16_to_cpu (gdp->bg_free_blocks_count);
+      bh = bptr (le32_to_cpu (gdp->bg_block_bitmap));
 
       if (!EXT2_HAS_RO_COMPAT_FEATURE (sblock,
 				       EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER)
@@ -465,26 +479,27 @@
 			  j, i);
 	}
 
-      if (!block_in_use (gdp->bg_block_bitmap, bh))
+      if (!block_in_use (le32_to_cpu (gdp->bg_block_bitmap), bh))
 	ext2_error ("block bitmap for group %d is marked free", i);
 
-      if (!block_in_use (gdp->bg_inode_bitmap, bh))
+      if (!block_in_use (le32_to_cpu (gdp->bg_inode_bitmap), bh))
 	ext2_error ("inode bitmap for group %d is marked free", i);
 
       for (j = 0; j < itb_per_group; j++)
-	if (!block_in_use (gdp->bg_inode_table + j, bh))
+	if (!block_in_use (le32_to_cpu (gdp->bg_inode_table) + j, bh))
 	  ext2_error ("block #%d of the inode table in group %d is marked free", j, i);
 
       x = count_free (bh, block_size);
-      if (gdp->bg_free_blocks_count != x)
+      if (le16_to_cpu (gdp->bg_free_blocks_count) != x)
 	ext2_error ("wrong free blocks count for group %d,"
 		    " stored = %d, counted = %lu",
-		    i, gdp->bg_free_blocks_count, x);
+		    i, le16_to_cpu (gdp->bg_free_blocks_count), x);
       bitmap_count += x;
     }
-  if (sblock->s_free_blocks_count != bitmap_count)
+  if (le32_to_cpu (sblock->s_free_blocks_count) != bitmap_count)
     ext2_error ("wrong free blocks count in super block,"
 		" stored = %lu, counted = %lu",
-		(unsigned long) sblock->s_free_blocks_count, bitmap_count);
+		(unsigned long) le32_to_cpu (sblock->s_free_blocks_count),
+		bitmap_count);
   spin_unlock (&global_lock);
 }
Index: ext2fs/bitmap.c
===================================================================
RCS file: /cvsroot/hurd/hurd/ext2fs/bitmap.c,v
retrieving revision 1.14
diff -u -r1.14 bitmap.c
--- ext2fs/bitmap.c	3 Oct 1999 10:23:29 -0000	1.14
+++ ext2fs/bitmap.c	9 Aug 2003 12:03:59 -0000
@@ -70,7 +70,7 @@
   if (offset)
     {
       tmp = *(p++);
-      tmp |= ~0UL >> (32-offset);
+      tmp |= cpu_to_le32 (~0UL >> (32-offset));
       if (size < 32)
 	goto found_first;
       if (~tmp)
@@ -90,9 +90,9 @@
   tmp = *p;
 
 found_first:
-  tmp |= ~0UL << size;
+  return result + ffz (le32_to_cpu (tmp) | (~0UL << size));
 found_middle:
-  return result + ffz(tmp);
+  return result + ffz (le32_to_cpu (tmp));
 }
 
 /* Linus sez that gcc can optimize the following correctly, we'll see if this
Index: ext2fs/dir.c
===================================================================
RCS file: /cvsroot/hurd/hurd/ext2fs/dir.c,v
retrieving revision 1.44
diff -u -r1.44 dir.c
--- ext2fs/dir.c	1 Aug 2002 00:59:34 -0000	1.44
+++ ext2fs/dir.c	9 Aug 2003 12:03:59 -0000
@@ -400,15 +400,15 @@
 
   for (currentoff = blockaddr, prevoff = 0;
        currentoff < blockaddr + DIRBLKSIZ;
-       prevoff = currentoff, currentoff += entry->rec_len)
+       prevoff = currentoff, currentoff += le16_to_cpu (entry->rec_len))
     {
       entry = (struct ext2_dir_entry_2 *)currentoff;
 
       if (!entry->rec_len
-	  || entry->rec_len % EXT2_DIR_PAD
+	  || le16_to_cpu (entry->rec_len) % EXT2_DIR_PAD
 	  || entry->name_len > EXT2_NAME_LEN
-	  || currentoff + entry->rec_len > blockaddr + DIRBLKSIZ
-	  || EXT2_DIR_REC_LEN (entry->name_len) > entry->rec_len
+	  || currentoff + le16_to_cpu (entry->rec_len) > blockaddr + DIRBLKSIZ
+	  || EXT2_DIR_REC_LEN (entry->name_len) > le16_to_cpu (entry->rec_len)
 	  || memchr (entry->name, '\0', entry->name_len))
 	{
 	  ext2_warning ("bad directory entry: inode: %Ld offset: %zd",
@@ -423,9 +423,9 @@
 
 	  /* Count how much free space this entry has in it. */
 	  if (entry->inode == 0)
-	    thisfree = entry->rec_len;
+	    thisfree = le16_to_cpu (entry->rec_len);
 	  else
-	    thisfree = entry->rec_len - EXT2_DIR_REC_LEN (entry->name_len);
+	    thisfree = le16_to_cpu (entry->rec_len) - EXT2_DIR_REC_LEN (entry->name_len);
 
 	  /* If this isn't at the front of the block, then it will
 	     have to be copied if we do a compression; count the
@@ -510,7 +510,7 @@
       ds->preventry = (struct ext2_dir_entry_2 *) prevoff;
     }
 
-  *inum = entry->inode;
+  *inum = le32_to_cpu (entry->inode);
   return 0;
 }
 
@@ -539,6 +539,11 @@
 
   dp->dn_set_mtime = 1;
 
+#if 1
+  ext2_debug ("diskfs_direnter_hard: entering `%s' into inode %Lu",
+	      name, dp->cache_id);
+#endif
+
   /* Select a location for the new directory entry.  Each branch of this
      switch is responsible for setting NEW to point to the on-disk
      directory entry being written, and setting NEW->rec_len appropriately.  */
@@ -547,7 +552,7 @@
     {
     case TAKE:
       /* We are supposed to consume this slot. */
-      assert (ds->entry->inode == 0 && ds->entry->rec_len >= needed);
+      assert (ds->entry->inode == 0 && le16_to_cpu (ds->entry->rec_len) >= needed);
 
       new = ds->entry;
       break;
@@ -556,12 +561,12 @@
       /* We are supposed to take the extra space at the end
 	 of this slot. */
       oldneeded = EXT2_DIR_REC_LEN (ds->entry->name_len);
-      assert (ds->entry->rec_len - oldneeded >= needed);
+      assert (le16_to_cpu (ds->entry->rec_len) - oldneeded >= needed);
 
       new = (struct ext2_dir_entry_2 *) ((vm_address_t) ds->entry + oldneeded);
 
-      new->rec_len = ds->entry->rec_len - oldneeded;
-      ds->entry->rec_len = oldneeded;
+      new->rec_len = cpu_to_le16 (le16_to_cpu (ds->entry->rec_len) - oldneeded);
+      ds->entry->rec_len = cpu_to_le16 (oldneeded);
       break;
 
     case COMPRESS:
@@ -575,16 +580,16 @@
 	{
 	  struct ext2_dir_entry_2 *from = (struct ext2_dir_entry_2 *)fromoff;
 	  struct ext2_dir_entry_2 *to = (struct ext2_dir_entry_2 *) tooff;
-	  int fromreclen = from->rec_len;
+	  int fromreclen = le16_to_cpu (from->rec_len);
 
 	  if (from->inode != 0)
 	    {
 	      assert (fromoff >= tooff);
 
 	      memmove (to, from, fromreclen);
-	      to->rec_len = EXT2_DIR_REC_LEN (to->name_len);
+	      to->rec_len = cpu_to_le16 (EXT2_DIR_REC_LEN (to->name_len));
 
-	      tooff += to->rec_len;
+	      tooff += le16_to_cpu (to->rec_len);
 	    }
 	  fromoff += fromreclen;
 	}
@@ -593,7 +598,7 @@
       assert (totfreed >= needed);
 
       new = (struct ext2_dir_entry_2 *) tooff;
-      new->rec_len = totfreed;
+      new->rec_len = cpu_to_le16 (totfreed);
       break;
 
     case EXTEND:
@@ -622,7 +627,7 @@
       dp->dn_stat.st_size = oldsize + DIRBLKSIZ;
       dp->dn_set_ctime = 1;
 
-      new->rec_len = DIRBLKSIZ;
+      new->rec_len = cpu_to_le16 (DIRBLKSIZ);
       break;
 
     default:
@@ -633,7 +638,7 @@
   /* NEW points to the directory entry being written, and its
      rec_len field is already filled in.  Now fill in the rest.  */
 
-  new->inode = np->cache_id;
+  new->inode = cpu_to_le32 (np->cache_id);
 #if 0
   /* XXX We cannot enable this code because file types can change
      (and conceivably quite often) with translator settings.
@@ -713,8 +718,9 @@
   else
     {
       assert ((vm_address_t) ds->entry - (vm_address_t) ds->preventry
-	      == ds->preventry->rec_len);
-      ds->preventry->rec_len += ds->entry->rec_len;
+	      == le16_to_cpu (ds->preventry->rec_len));
+      ds->preventry->rec_len = cpu_to_le16
+	(le16_to_cpu (ds->preventry->rec_len) + le16_to_cpu (ds->entry->rec_len));
     }
 
   dp->dn_set_mtime = 1;
@@ -747,7 +753,7 @@
 
   assert (!diskfs_readonly);
 
-  ds->entry->inode = np->cache_id;
+  ds->entry->inode = cpu_to_le32 (np->cache_id);
   dp->dn_set_mtime = 1;
   dp->dn->info.i_flags &= ~EXT2_BTREE_FL;
 
@@ -783,7 +789,7 @@
 
   for (curoff = buf;
        !hit && curoff < buf + dp->dn_stat.st_size;
-       curoff += entry->rec_len)
+       curoff += le16_to_cpu (entry->rec_len))
     {
       entry = (struct ext2_dir_entry_2 *) curoff;
 
@@ -841,7 +847,7 @@
 
   for (offinblk = buf;
        offinblk < buf + DIRBLKSIZ;
-       offinblk += entry->rec_len)
+       offinblk += le16_to_cpu (entry->rec_len))
     {
       entry = (struct ext2_dir_entry_2 *) offinblk;
       if (entry->inode)
@@ -969,7 +975,7 @@
 	}
       for (i = 0, bufp = buf;
 	   i < entry - curentry && bufp - buf < DIRBLKSIZ;
-	   bufp += ((struct ext2_dir_entry_2 *)bufp)->rec_len, i++)
+	   bufp += le16_to_cpu (((struct ext2_dir_entry_2 *)bufp)->rec_len), i++)
 	;
       /* Make sure we didn't run off the end. */
       assert (bufp - buf < DIRBLKSIZ);
@@ -1020,7 +1026,7 @@
 	    if (datap + rec_len > *data + allocsize)
 	      break;
 
-	  userp->d_fileno = entryp->inode;
+	  userp->d_fileno = le32_to_cpu (entryp->inode);
 	  userp->d_reclen = rec_len;
 	  userp->d_namlen = name_len;
 
@@ -1061,7 +1067,7 @@
 	  return EIO;
 	}
 
-      bufp += entryp->rec_len;
+      bufp += le16_to_cpu (entryp->rec_len);
       if (bufp - buf == DIRBLKSIZ)
 	{
 	  blkno++;
@@ -1071,7 +1077,7 @@
 	{
 	  ext2_warning ("directory entry too long: inode: %Ld offset: %zd",
 			dp->cache_id,
-			blkno * DIRBLKSIZ + bufp - buf - entryp->rec_len);
+			blkno * DIRBLKSIZ + bufp - buf - le16_to_cpu (entryp->rec_len));
 	  return EIO;
 	}
     }
Index: ext2fs/ext2_fs.h
===================================================================
RCS file: /cvsroot/hurd/hurd/ext2fs/ext2_fs.h,v
retrieving revision 1.23
diff -u -r1.23 ext2_fs.h
--- ext2fs/ext2_fs.h	5 Feb 2000 11:59:54 -0000	1.23
+++ ext2fs/ext2_fs.h	9 Aug 2003 12:04:00 -0000
@@ -25,7 +25,7 @@
 /*
  * Define EXT2FS_DEBUG to produce debug messages
  */
-#undef EXT2FS_DEBUG
+#define EXT2FS_DEBUG
 
 /*
  * Define EXT2_PREALLOCATE to preallocate data blocks for expanding files
@@ -75,6 +75,16 @@
  */
 #define EXT2_LINK_MAX		32000
 
+/* #define SB_LITTLE_ENDIAN 0 if the superblock is
+   in the machine's native format.  */
+#if !defined (SB_LITTLE_ENDIAN) || SB_LITTLE_ENDIAN
+#define sb16_to_cpu(x) le16_to_cpu(x)
+#define sb32_to_cpu(x) le32_to_cpu(x)
+#else
+#define sb16_to_cpu(x) (x)
+#define sb32_to_cpu(x) (x)
+#endif
+
 /*
  * Macro-instructions used to manage several block sizes
  */
@@ -84,26 +94,26 @@
 #ifdef __KERNEL__
 # define EXT2_BLOCK_SIZE(s)		((s)->s_blocksize)
 #else
-# define EXT2_BLOCK_SIZE(s)		(EXT2_MIN_BLOCK_SIZE << (s)->s_log_block_size)
+# define EXT2_BLOCK_SIZE(s)		(EXT2_MIN_BLOCK_SIZE << sb32_to_cpu ((s)->s_log_block_size))
 #endif
 #define EXT2_ACLE_PER_BLOCK(s)		(EXT2_BLOCK_SIZE(s) / sizeof (struct ext2_acl_entry))
 #define	EXT2_ADDR_PER_BLOCK(s)		(EXT2_BLOCK_SIZE(s) / sizeof (__u32))
 #ifdef __KERNEL__
 # define EXT2_BLOCK_SIZE_BITS(s)	((s)->s_blocksize_bits)
 #else
-# define EXT2_BLOCK_SIZE_BITS(s)	((s)->s_log_block_size + 10)
+# define EXT2_BLOCK_SIZE_BITS(s)	(sb32_to_cpu ((s)->s_log_block_size) + 10)
 #endif
 #ifdef __KERNEL__
 #define	EXT2_ADDR_PER_BLOCK_BITS(s)	((s)->u.ext2_sb.s_addr_per_block_bits)
 #define EXT2_INODE_SIZE(s)		((s)->u.ext2_sb.s_inode_size)
 #define EXT2_FIRST_INO(s)		((s)->u.ext2_sb.s_first_ino)
 #else
-#define EXT2_INODE_SIZE(s)	(((s)->s_rev_level == EXT2_GOOD_OLD_REV) ? \
+#define EXT2_INODE_SIZE(s)	((sb32_to_cpu ((s)->s_rev_level) == EXT2_GOOD_OLD_REV) ? \
 				 EXT2_GOOD_OLD_INODE_SIZE : \
-				 (s)->s_inode_size)
-#define EXT2_FIRST_INO(s)	(((s)->s_rev_level == EXT2_GOOD_OLD_REV) ? \
+				 sb16_to_cpu ((s)->s_inode_size))
+#define EXT2_FIRST_INO(s)	((sb32_to_cpu ((s)->s_rev_level) == EXT2_GOOD_OLD_REV) ? \
 				 EXT2_GOOD_OLD_FIRST_INO : \
-				 (s)->s_first_ino)
+				 sb16_to_cpu ((s)->s_first_ino))
 #endif
 
 /*
@@ -116,7 +126,8 @@
 # define EXT2_FRAG_SIZE(s)		((s)->u.ext2_sb.s_frag_size)
 # define EXT2_FRAGS_PER_BLOCK(s)	((s)->u.ext2_sb.s_frags_per_block)
 #else
-# define EXT2_FRAG_SIZE(s)		(EXT2_MIN_FRAG_SIZE << (s)->s_log_frag_size)
+# define EXT2_FRAG_SIZE(s)		(EXT2_MIN_FRAG_SIZE << (__s32) sb32_to_cpu \
+					 ((__u32)(s)->s_log_frag_size))
 # define EXT2_FRAGS_PER_BLOCK(s)	(EXT2_BLOCK_SIZE(s) / EXT2_FRAG_SIZE(s))
 #endif
 
@@ -166,9 +177,9 @@
 # define EXT2_INODES_PER_GROUP(s)	((s)->u.ext2_sb.s_inodes_per_group)
 # define EXT2_DESC_PER_BLOCK_BITS(s)	((s)->u.ext2_sb.s_desc_per_block_bits)
 #else
-# define EXT2_BLOCKS_PER_GROUP(s)	((s)->s_blocks_per_group)
+# define EXT2_BLOCKS_PER_GROUP(s)	(sb32_to_cpu ((s)->s_blocks_per_group))
 # define EXT2_DESC_PER_BLOCK(s)		(EXT2_BLOCK_SIZE(s) / sizeof (struct ext2_group_desc))
-# define EXT2_INODES_PER_GROUP(s)	((s)->s_inodes_per_group)
+# define EXT2_INODES_PER_GROUP(s)	(sb32_to_cpu ((s)->s_inodes_per_group))
 #endif
 
 /*
@@ -283,8 +294,8 @@
 
 #ifdef	__hurd__
 #define i_translator	osd1.hurd1.h_i_translator
-#define i_frag		osd2.hurd2.h_i_frag;
-#define i_fsize		osd2.hurd2.h_i_fsize;
+#define i_frag		osd2.hurd2.h_i_frag
+#define i_fsize		osd2.hurd2.h_i_fsize
 #define i_uid_high	osd2.hurd2.h_i_uid_high
 #define i_gid_high	osd2.hurd2.h_i_gid_high
 #define i_author	osd2.hurd2.h_i_author
@@ -432,11 +443,11 @@
  */
 
 #define EXT2_HAS_COMPAT_FEATURE(sb,mask)			\
-	( EXT2_SB(sb)->s_feature_compat & (mask) )
+	( sb32_to_cpu (EXT2_SB(sb)->s_feature_compat) & (mask) )
 #define EXT2_HAS_RO_COMPAT_FEATURE(sb,mask)			\
-	( EXT2_SB(sb)->s_feature_ro_compat & (mask) )
+	( sb32_to_cpu (EXT2_SB(sb)->s_feature_ro_compat) & (mask) )
 #define EXT2_HAS_INCOMPAT_FEATURE(sb,mask)			\
-	( EXT2_SB(sb)->s_feature_incompat & (mask) )
+	( sb32_to_cpu (EXT2_SB(sb)->s_feature_incompat) & (mask) )
 
 #define EXT2_FEATURE_COMPAT_DIR_PREALLOC	0x0001
 
Index: ext2fs/ext2fs.c
===================================================================
RCS file: /cvsroot/hurd/hurd/ext2fs/ext2fs.c,v
retrieving revision 1.55
diff -u -r1.55 ext2fs.c
--- ext2fs/ext2fs.c	2 Jun 2002 21:40:56 -0000	1.55
+++ ext2fs/ext2fs.c	9 Aug 2003 12:04:00 -0000
@@ -171,6 +171,7 @@
      This starts the first diskfs thread for us.  */
   store = diskfs_init_main (&startup_argp, argc, argv,
 			    &store_parsed, &bootstrap);
+  setvbuf (stdout, NULL, _IONBF, 0);
 
   if (store->size < SBLOCK_OFFS + SBLOCK_SIZE)
     ext2_panic ("device too small for superblock (%Ld bytes)", store->size);
Index: ext2fs/ext2fs.h
===================================================================
RCS file: /cvsroot/hurd/hurd/ext2fs/ext2fs.h,v
retrieving revision 1.70
diff -u -r1.70 ext2fs.h
--- ext2fs/ext2fs.h	8 Oct 2002 23:10:09 -0000	1.70
+++ ext2fs/ext2fs.h	9 Aug 2003 12:04:01 -0000
@@ -28,6 +28,7 @@
 #include <assert.h>
 #include <rwlock.h>
 #include <sys/mman.h>
+#include <endian.h>
 
 #define __hurd__		/* Enable some hurd-specific fields.  */
 
@@ -106,6 +107,38 @@
 #define EXT2FS_EI extern inline
 #endif
 
+#if __BYTE_ORDER == __BIG_ENDIAN
+/* From <linux>/include/asm-ppc/byteorder.h.
+   On the PowerPC, we could someday use the special little-endian
+   instructions.  */
+
+EXT2FS_EI __u32 le32_to_cpu (__u32 x) __attribute__ ((const));
+EXT2FS_EI __u16 le16_to_cpu (__u16 x) __attribute__ ((const));
+
+EXT2FS_EI __u32
+le32_to_cpu (__u32 x)
+{
+  return ((((x) & 0x000000ffU) << 24) |
+	  (((x) & 0x0000ff00U) <<  8) |
+	  (((x) & 0x00ff0000U) >>  8) |
+	  (((x) & 0xff000000U) >> 24));
+}
+#define cpu_to_le32(x) le32_to_cpu(x)
+
+EXT2FS_EI __u16
+le16_to_cpu (__u16 x)
+{
+  return ((((x) & 0x00ff) << 8) |
+	  (((x) & 0xff00) >> 8));
+}
+#define cpu_to_le16(x) le16_to_cpu(x)
+#else  /* __BYTE_ORDER */
+#define le32_to_cpu(x) (x)
+#define cpu_to_le32(x) (x)
+#define le16_to_cpu(x) (x)
+#define cpu_to_le16(x) (x)
+#endif  /* __BYTE_ORDER */
+
 /* ---------------------------------------------------------------- */
 /* Bitmap routines.  */
 
@@ -116,7 +149,7 @@
 test_bit (unsigned num, char *bitmap)
 {
   const uint32_t *const bw = (uint32_t *) bitmap + (num >> 5);
-  const uint_fast32_t mask = 1 << (num & 31);
+  const uint_fast32_t mask = cpu_to_le32 (1 << (num & 31));
   return *bw & mask;
 }
 
@@ -126,7 +159,7 @@
 set_bit (unsigned num, char *bitmap)
 {
   uint32_t *const bw = (uint32_t *) bitmap + (num >> 5);
-  const uint_fast32_t mask = 1 << (num & 31);
+  const uint_fast32_t mask = cpu_to_le32 (1 << (num & 31));
   return (*bw & mask) ?: (*bw |= mask, 0);
 }
 
@@ -136,7 +169,7 @@
 clear_bit (unsigned num, char *bitmap)
 {
   uint32_t *const bw = (uint32_t *) bitmap + (num >> 5);
-  const uint_fast32_t mask = 1 << (num & 31);
+  const uint_fast32_t mask = cpu_to_le32 (1 << (num & 31));
   return (*bw & mask) ? (*bw &= ~mask, mask) : 0;
 }
 
@@ -230,7 +263,7 @@
 unsigned int log2_block_size;
 
 /* The number of bits to scale min-blocks to get filesystem blocks.  */
-#define BLOCKSIZE_SCALE	(sblock->s_log_block_size)
+#define BLOCKSIZE_SCALE	(le32_to_cpu (sblock->s_log_block_size))
 
 /* log2 of the number of device blocks in a filesystem block.  */
 unsigned log2_dev_blocks_per_fs_block;
@@ -293,17 +326,17 @@
 #define group_desc(num)	(&group_desc_image[num])
 struct ext2_group_desc *group_desc_image;
 
-#define inode_group_num(inum) (((inum) - 1) / sblock->s_inodes_per_group)
+#define inode_group_num(inum) (((inum) - 1) / le32_to_cpu (sblock->s_inodes_per_group))
 
 /* Convert an inode number to the dinode on disk. */
 EXT2FS_EI struct ext2_inode *
 dino (ino_t inum)
 {
-  unsigned long inodes_per_group = sblock->s_inodes_per_group;
+  unsigned long inodes_per_group = le32_to_cpu (sblock->s_inodes_per_group);
   unsigned long bg_num = (inum - 1) / inodes_per_group;
   unsigned long group_inum = (inum - 1) % inodes_per_group;
   struct ext2_group_desc *bg = group_desc(bg_num);
-  block_t block = bg->bg_inode_table + (group_inum / inodes_per_block);
+  block_t block = le32_to_cpu (bg->bg_inode_table) + (group_inum / inodes_per_block);
   return ((struct ext2_inode *)bptr(block)) + group_inum % inodes_per_block;
 }
 
Index: ext2fs/getblk.c
===================================================================
RCS file: /cvsroot/hurd/hurd/ext2fs/getblk.c,v
retrieving revision 1.24
diff -u -r1.24 getblk.c
--- ext2fs/getblk.c	10 Mar 2000 04:54:55 -0000	1.24
+++ ext2fs/getblk.c	9 Aug 2003 12:04:01 -0000
@@ -122,7 +122,7 @@
   block_t hint;
 #endif
 
-  *result = node->dn->info.i_data[nr];
+  *result = le32_to_cpu (node->dn->info.i_data[nr]);
   if (*result)
     return 0;
 
@@ -142,14 +142,14 @@
 	{
 	  if (node->dn->info.i_data[i])
 	    {
-	      goal = node->dn->info.i_data[i];
+	      goal = le32_to_cpu (node->dn->info.i_data[i]);
 	      break;
 	    }
 	}
       if (!goal)
 	goal =
 	  (node->dn->info.i_block_group * EXT2_BLOCKS_PER_GROUP (sblock))
-	  + sblock->s_first_data_block;
+	  + le32_to_cpu (sblock->s_first_data_block);
     }
 
   *result = ext2_alloc_block (node, goal, zero);
@@ -160,7 +160,7 @@
   if (!*result)
     return ENOSPC;
 
-  node->dn->info.i_data[nr] = *result;
+  node->dn->info.i_data[nr] = cpu_to_le32 (*result);
 
   node->dn->info.i_next_alloc_block = new_block;
   node->dn->info.i_next_alloc_goal = *result;
@@ -182,7 +182,7 @@
   block_t goal = 0;
   block_t *bh = (block_t *)bptr (block);
 
-  *result = bh[nr];
+  *result = le32_to_cpu (bh[nr]);
   if (*result)
     return 0;
 
@@ -197,7 +197,7 @@
 	{
 	  if (bh[i])
 	    {
-	      goal = bh[i];
+	      goal = le32_to_cpu (bh[i]);
 	      break;
 	    }
 	}
@@ -209,7 +209,7 @@
   if (!*result)
     return ENOSPC;
 
-  bh[nr] = *result;
+  bh[nr] = cpu_to_le32 (*result);
 
   if (diskfs_synchronous || node->dn->info.i_osync)
     sync_global_ptr (bh, 1);
@@ -248,9 +248,9 @@
      * allocations use the same goal zone
    */
 
-  ext2_debug ("block = %u, next = %u, goal = %u", block,
+  /* ext2_debug ("block = %u, next = %u, goal = %u", block,
 	      node->dn->info.i_next_alloc_block,
-	      node->dn->info.i_next_alloc_goal);
+	      node->dn->info.i_next_alloc_goal); */
 
   if (block == node->dn->info.i_next_alloc_block + 1)
     {
Index: ext2fs/hyper.c
===================================================================
RCS file: /cvsroot/hurd/hurd/ext2fs/hyper.c,v
retrieving revision 1.32
diff -u -r1.32 hyper.c
--- ext2fs/hyper.c	2 Jun 2002 21:40:59 -0000	1.32
+++ ext2fs/hyper.c	9 Aug 2003 12:04:01 -0000
@@ -42,7 +42,7 @@
        global blocks are actually modified so the pager can write only them. */
     {
       /* One bit per filesystem block.  */
-      mod_map_size = sblock->s_blocks_count >> 3;
+      mod_map_size = le32_to_cpu (sblock->s_blocks_count) >> 3;
       modified_global_blocks = mmap (0, mod_map_size, PROT_READ|PROT_WRITE,
 				     MAP_ANON, 0, 0);
       assert (modified_global_blocks != (void *) -1);
@@ -64,15 +64,15 @@
 
   sblock = (struct ext2_super_block *) boffs_ptr (SBLOCK_OFFS);
 
-  if (sblock->s_magic != EXT2_SUPER_MAGIC
+  if (sblock->s_magic != cpu_to_le16 (EXT2_SUPER_MAGIC)
 #ifdef EXT2FS_PRE_02B_COMPAT
-      && sblock->s_magic != EXT2_PRE_02B_MAGIC
+      && sblock->s_magic != cpu_to_le16 (EXT2_PRE_02B_MAGIC)
 #endif
       )
     ext2_panic ("bad magic number %#x (should be %#x)",
-		sblock->s_magic, EXT2_SUPER_MAGIC);
+		le16_to_cpu (sblock->s_magic), EXT2_SUPER_MAGIC);
 
-  log2_block_size = EXT2_MIN_BLOCK_LOG_SIZE + sblock->s_log_block_size;
+  log2_block_size = EXT2_MIN_BLOCK_LOG_SIZE + le32_to_cpu (sblock->s_log_block_size);
   block_size = 1 << log2_block_size;
 
   if (block_size > EXT2_MAX_BLOCK_SIZE)
@@ -92,10 +92,10 @@
     ext2_panic ("block size %d isn't a power-of-two multiple of 512!",
 		block_size);
 
-  if ((store->size >> log2_block_size) < sblock->s_blocks_count)
+  if ((store->size >> log2_block_size) < le32_to_cpu (sblock->s_blocks_count))
     ext2_panic ("disk size (%qd bytes) too small; superblock says we need %qd",
 		(long long int) store->size,
-		(long long int) sblock->s_blocks_count << log2_block_size);
+		(long long int) le32_to_cpu (sblock->s_blocks_count) << log2_block_size);
   if (log2_dev_blocks_per_fs_block != 0
       && (store->size & ((1 << log2_dev_blocks_per_fs_block) - 1)) != 0)
     ext2_warning ("%Ld (%zd byte) device blocks "
@@ -106,40 +106,42 @@
   /* Set these handy variables.  */
   inodes_per_block = block_size / EXT2_INODE_SIZE (sblock);
 
-  frag_size = EXT2_MIN_FRAG_SIZE << sblock->s_log_frag_size;
+  frag_size = EXT2_MIN_FRAG_SIZE << (__s32) le32_to_cpu ((__u32) sblock->s_log_frag_size);
   if (frag_size)
     frags_per_block = block_size / frag_size;
   else
     ext2_panic ("frag size is zero!");
 
-  if (sblock->s_rev_level > EXT2_GOOD_OLD_REV)
+  if (le32_to_cpu (sblock->s_rev_level) > EXT2_GOOD_OLD_REV)
     {
-      if (sblock->s_feature_incompat & ~EXT2_FEATURE_INCOMPAT_SUPP)
+      if (le32_to_cpu (sblock->s_feature_incompat) & ~EXT2_FEATURE_INCOMPAT_SUPP)
 	ext2_panic ("could not mount because of unsupported optional features"
 		    " (0x%x)",
-		    sblock->s_feature_incompat & ~EXT2_FEATURE_INCOMPAT_SUPP);
-      if (sblock->s_feature_ro_compat & ~EXT2_FEATURE_RO_COMPAT_SUPP)
+		    le32_to_cpu (sblock->s_feature_incompat)
+		    & ~EXT2_FEATURE_INCOMPAT_SUPP);
+      if (le32_to_cpu (sblock->s_feature_ro_compat) & ~EXT2_FEATURE_RO_COMPAT_SUPP)
 	{
 	  ext2_warning ("mounted readonly because of"
 			" unsupported optional features (0x%x)",
-			sblock->s_feature_ro_compat & ~EXT2_FEATURE_RO_COMPAT_SUPP);
+			le32_to_cpu (sblock->s_feature_ro_compat)
+			& ~EXT2_FEATURE_RO_COMPAT_SUPP);
 	  diskfs_readonly = 1;
 	}
-      if (sblock->s_inode_size != EXT2_GOOD_OLD_INODE_SIZE)
-	ext2_panic ("inode size %d isn't supported", sblock->s_inode_size);
+      if (sblock->s_inode_size != cpu_to_le16 (EXT2_GOOD_OLD_INODE_SIZE))
+	ext2_panic ("inode size %d isn't supported", le16_to_cpu (sblock->s_inode_size));
     }
 
   groups_count =
-    ((sblock->s_blocks_count - sblock->s_first_data_block +
-      sblock->s_blocks_per_group - 1)
-     / sblock->s_blocks_per_group);
+    ((le32_to_cpu (sblock->s_blocks_count) - le32_to_cpu (sblock->s_first_data_block) +
+      le32_to_cpu (sblock->s_blocks_per_group) - 1)
+     / le32_to_cpu (sblock->s_blocks_per_group));
 
-  itb_per_group = sblock->s_inodes_per_group / inodes_per_block;
+  itb_per_group = le32_to_cpu (sblock->s_inodes_per_group) / inodes_per_block;
   desc_per_block = block_size / sizeof (struct ext2_group_desc);
   addr_per_block = block_size / sizeof (block_t);
   db_per_group = (groups_count + desc_per_block - 1) / desc_per_block;
 
-  ext2fs_clean = sblock->s_state & EXT2_VALID_FS;
+  ext2fs_clean = sblock->s_state & cpu_to_le16 (EXT2_VALID_FS);
   if (! ext2fs_clean)
     {
       ext2_warning ("FILESYSTEM NOT UNMOUNTED CLEANLY; PLEASE fsck");
@@ -166,16 +168,16 @@
 error_t
 diskfs_set_hypermetadata (int wait, int clean)
 {
-  if (clean && ext2fs_clean && !(sblock->s_state & EXT2_VALID_FS))
+  if (clean && ext2fs_clean && !(sblock->s_state & cpu_to_le16 (EXT2_VALID_FS)))
     /* The filesystem is clean, so we need to set the clean flag.  */
     {
-      sblock->s_state |= EXT2_VALID_FS;
+      sblock->s_state |= cpu_to_le16 (EXT2_VALID_FS);
       sblock_dirty = 1;
     }
-  else if (!clean && (sblock->s_state & EXT2_VALID_FS))
+  else if (!clean && (sblock->s_state & cpu_to_le16 (EXT2_VALID_FS)))
     /* The filesystem just became dirty, so clear the clean flag.  */
     {
-      sblock->s_state &= ~EXT2_VALID_FS;
+      sblock->s_state &= cpu_to_le16 (~EXT2_VALID_FS);
       sblock_dirty = 1;
       wait = 1;
     }
@@ -186,7 +188,7 @@
      record_global_poke (sblock);
    }
 
-  sync_global (wait);
+ sync_global (wait);
 
   /* Should check writability here and return EROFS if necessary. XXX */
   return 0;
@@ -201,6 +203,6 @@
 
   mprotect (disk_image, store->size, PROT_READ | (readonly ? 0 : PROT_WRITE));
 
-  if (!readonly && !(sblock->s_state & EXT2_VALID_FS))
+  if (!readonly && !(sblock->s_state & cpu_to_le16 (EXT2_VALID_FS)))
     ext2_warning ("UNCLEANED FILESYSTEM NOW WRITABLE");
 }
Index: ext2fs/ialloc.c
===================================================================
RCS file: /cvsroot/hurd/hurd/ext2fs/ialloc.c,v
retrieving revision 1.38
diff -u -r1.38 ialloc.c
--- ext2fs/ialloc.c	8 Oct 2002 23:10:09 -0000	1.38
+++ ext2fs/ialloc.c	9 Aug 2003 12:04:01 -0000
@@ -64,18 +64,18 @@
 
   spin_lock (&global_lock);
 
-  if (inum < EXT2_FIRST_INO (sblock) || inum > sblock->s_inodes_count)
+  if (inum < EXT2_FIRST_INO (sblock) || inum > le32_to_cpu (sblock->s_inodes_count))
     {
       ext2_error ("reserved inode or nonexistent inode: %Ld", inum);
       spin_unlock (&global_lock);
       return;
     }
 
-  block_group = (inum - 1) / sblock->s_inodes_per_group;
-  bit = (inum - 1) % sblock->s_inodes_per_group;
+  block_group = (inum - 1) / le32_to_cpu (sblock->s_inodes_per_group);
+  bit = (inum - 1) % le32_to_cpu (sblock->s_inodes_per_group);
 
   gdp = group_desc (block_group);
-  bh = bptr (gdp->bg_inode_bitmap);
+  bh = bptr (le32_to_cpu (gdp->bg_inode_bitmap));
 
   if (!clear_bit (bit, bh))
     ext2_warning ("bit already cleared for inode %Ld", inum);
@@ -83,12 +83,15 @@
     {
       record_global_poke (bh);
 
-      gdp->bg_free_inodes_count++;
+      gdp->bg_free_inodes_count = cpu_to_le16
+	(le16_to_cpu (gdp->bg_free_inodes_count) + 1);
       if (S_ISDIR (old_mode))
-	gdp->bg_used_dirs_count--;
+	gdp->bg_used_dirs_count = cpu_to_le16
+	  (le16_to_cpu (gdp->bg_used_dirs_count) - 1);
       record_global_poke (gdp);
 
-      sblock->s_free_inodes_count++;
+      sblock->s_free_inodes_count = cpu_to_le32
+	(le32_to_cpu (sblock->s_free_inodes_count) + 1);
     }
 
   sblock_dirty = 1;
@@ -124,14 +127,15 @@
 
   if (S_ISDIR (mode))
     {
-      avefreei = sblock->s_free_inodes_count / groups_count;
+      avefreei = le32_to_cpu (sblock->s_free_inodes_count) / groups_count;
 
 /* I am not yet convinced that this next bit is necessary.
       i = inode_group_num(dir_inum);
       for (j = 0; j < groups_count; j++)
 	{
 	  tmp = group_desc (i);
-	  if ((tmp->bg_used_dirs_count << 8) < tmp->bg_free_inodes_count)
+	  if ((le16_to_cpu (tmp->bg_used_dirs_count) << 8)
+	      < le16_to_cpu (tmp->bg_free_inodes_count))
 	    {
 	      gdp = tmp;
 	      break;
@@ -147,10 +151,11 @@
 	    {
 	      tmp = group_desc (j);
 	      if (tmp->bg_free_inodes_count
-		  && tmp->bg_free_inodes_count >= avefreei)
+		  && le16_to_cpu (tmp->bg_free_inodes_count) >= avefreei)
 		{
 		  if (!gdp ||
-		      (tmp->bg_free_blocks_count > gdp->bg_free_blocks_count))
+		      (le16_to_cpu (tmp->bg_free_blocks_count)
+		       > le16_to_cpu (gdp->bg_free_blocks_count)))
 		    {
 		      i = j;
 		      gdp = tmp;
@@ -213,10 +218,11 @@
       return 0;
     }
 
-  bh = bptr (gdp->bg_inode_bitmap);
+  bh = bptr (le32_to_cpu (gdp->bg_inode_bitmap));
   if ((inum =
-       find_first_zero_bit ((unsigned long *) bh, sblock->s_inodes_per_group))
-      < sblock->s_inodes_per_group)
+       find_first_zero_bit ((unsigned long *) bh,
+			    le32_to_cpu (sblock->s_inodes_per_group)))
+      < le32_to_cpu (sblock->s_inodes_per_group))
     {
       if (set_bit (inum, bh))
 	{
@@ -236,8 +242,8 @@
       goto repeat;
     }
 
-  inum += i * sblock->s_inodes_per_group + 1;
-  if (inum < EXT2_FIRST_INO (sblock) || inum > sblock->s_inodes_count)
+  inum += i * le32_to_cpu (sblock->s_inodes_per_group) + 1;
+  if (inum < EXT2_FIRST_INO (sblock) || inum > le32_to_cpu (sblock->s_inodes_count))
     {
       ext2_error ("reserved inode or inode > inodes count - "
 		  "block_group = %d,inode=%d", i, inum);
@@ -245,12 +251,15 @@
       goto sync_out;
     }
 
-  gdp->bg_free_inodes_count--;
+  gdp->bg_free_inodes_count = cpu_to_le16
+    (le16_to_cpu (gdp->bg_free_inodes_count) - 1);
   if (S_ISDIR (mode))
-    gdp->bg_used_dirs_count++;
+    gdp->bg_used_dirs_count = cpu_to_le16
+      (le16_to_cpu (gdp->bg_used_dirs_count) + 1);
   record_global_poke (gdp);
 
-  sblock->s_free_inodes_count--;
+  sblock->s_free_inodes_count = cpu_to_le32
+    (le32_to_cpu (sblock->s_free_inodes_count) - 1);
   sblock_dirty = 1;
 
  sync_out:
@@ -355,19 +364,19 @@
   for (i = 0; i < groups_count; i++)
     {
       gdp = group_desc (i);
-      desc_count += gdp->bg_free_inodes_count;
-      x = count_free (bptr (gdp->bg_inode_bitmap),
-		      sblock->s_inodes_per_group / 8);
+      desc_count += le16_to_cpu (gdp->bg_free_inodes_count);
+      x = count_free (bptr (le32_to_cpu (gdp->bg_inode_bitmap)),
+		      le32_to_cpu (sblock->s_inodes_per_group) / 8);
       ext2_debug ("group %d: stored = %d, counted = %lu",
-		  i, gdp->bg_free_inodes_count, x);
+		  i, le16_to_cpu (gdp->bg_free_inodes_count), x);
       bitmap_count += x;
     }
   ext2_debug ("stored = %u, computed = %lu, %lu",
-	      sblock->s_free_inodes_count, desc_count, bitmap_count);
+	      le32_to_cpu (sblock->s_free_inodes_count), desc_count, bitmap_count);
   spin_unlock (&global_lock);
   return desc_count;
 #else
-  return sblock->s_free_inodes_count;
+  return le32_to_cpu (sblock->s_free_inodes_count);
 #endif
 }
 
@@ -388,19 +397,20 @@
   for (i = 0; i < groups_count; i++)
     {
       gdp = group_desc (i);
-      desc_count += gdp->bg_free_inodes_count;
-      x = count_free (bptr (gdp->bg_inode_bitmap),
-		      sblock->s_inodes_per_group / 8);
-      if (gdp->bg_free_inodes_count != x)
+      desc_count += le16_to_cpu (gdp->bg_free_inodes_count);
+      x = count_free (bptr (le32_to_cpu (gdp->bg_inode_bitmap)),
+		      le32_to_cpu (sblock->s_inodes_per_group) / 8);
+      if (le16_to_cpu (gdp->bg_free_inodes_count) != x)
 	ext2_error ("wrong free inodes count in group %d, "
 		    "stored = %d, counted = %lu",
-		    i, gdp->bg_free_inodes_count, x);
+		    i, le16_to_cpu (gdp->bg_free_inodes_count), x);
       bitmap_count += x;
     }
-  if (sblock->s_free_inodes_count != bitmap_count)
+  if (le32_to_cpu (sblock->s_free_inodes_count) != bitmap_count)
     ext2_error ("wrong free inodes count in super block, "
 		"stored = %lu, counted = %lu",
-		(unsigned long) sblock->s_free_inodes_count, bitmap_count);
+		(unsigned long) le32_to_cpu (sblock->s_free_inodes_count),
+		bitmap_count);
 
   spin_unlock (&global_lock);
 }
Index: ext2fs/inode.c
===================================================================
RCS file: /cvsroot/hurd/hurd/ext2fs/inode.c,v
retrieving revision 1.62
diff -u -r1.62 inode.c
--- ext2fs/inode.c	8 Oct 2002 23:10:09 -0000	1.62
+++ ext2fs/inode.c	9 Aug 2003 12:04:01 -0000
@@ -212,13 +212,13 @@
   st->st_ino = np->cache_id;
   st->st_blksize = vm_page_size * 2;
 
-  st->st_nlink = di->i_links_count;
-  st->st_size = di->i_size;
-  st->st_gen = di->i_generation;
-
-  st->st_atime = di->i_atime;
-  st->st_mtime = di->i_mtime;
-  st->st_ctime = di->i_ctime;
+  st->st_nlink = le16_to_cpu (di->i_links_count);
+  st->st_size = le32_to_cpu (di->i_size);
+  st->st_gen = le32_to_cpu (di->i_generation);
+
+  st->st_atime = le32_to_cpu (di->i_atime);
+  st->st_mtime = le32_to_cpu (di->i_mtime);
+  st->st_ctime = le32_to_cpu (di->i_ctime);
 
 #ifdef XXX
   st->st_atime_usec = di->i_atime.ts_nsec / 1000;
@@ -226,53 +226,54 @@
   st->st_ctime_usec = di->i_ctime.ts_nsec / 1000;
 #endif
 
-  st->st_blocks = di->i_blocks;
+  st->st_blocks = le32_to_cpu (di->i_blocks);
 
   st->st_flags = 0;
-  if (di->i_flags & EXT2_APPEND_FL)
+  if (di->i_flags & cpu_to_le32 (EXT2_APPEND_FL))
     st->st_flags |= UF_APPEND;
-  if (di->i_flags & EXT2_NODUMP_FL)
+  if (di->i_flags & cpu_to_le32 (EXT2_NODUMP_FL))
     st->st_flags |= UF_NODUMP;
-  if (di->i_flags & EXT2_IMMUTABLE_FL)
+  if (di->i_flags & cpu_to_le32 (EXT2_IMMUTABLE_FL))
     st->st_flags |= UF_IMMUTABLE;
 
-  if (sblock->s_creator_os == EXT2_OS_HURD)
+  if (sblock->s_creator_os == cpu_to_le32 (EXT2_OS_HURD))
     {
-      st->st_mode = di->i_mode | (di->i_mode_high << 16);
+      st->st_mode = le16_to_cpu (di->i_mode)
+	| (le16_to_cpu (di->i_mode_high) << 16);
       st->st_mode &= ~S_ITRANS;
       if (di->i_translator)
 	st->st_mode |= S_IPTRANS;
 
-      st->st_uid = di->i_uid | (di->i_uid_high << 16);
-      st->st_gid = di->i_gid | (di->i_gid_high << 16);
+      st->st_uid = le16_to_cpu (di->i_uid) | (le16_to_cpu (di->i_uid_high) << 16);
+      st->st_gid = le16_to_cpu (di->i_gid) | (le16_to_cpu (di->i_gid_high) << 16);
 
-      st->st_author = di->i_author;
+      st->st_author = le32_to_cpu (di->i_author);
       if (st->st_author == -1)
 	st->st_author = st->st_uid;
     }
   else
     {
-      st->st_mode = di->i_mode & ~S_ITRANS;
-      st->st_uid = di->i_uid;
-      st->st_gid = di->i_gid;
+      st->st_mode = le16_to_cpu (di->i_mode) & ~S_ITRANS;
+      st->st_uid = le16_to_cpu (di->i_uid);
+      st->st_gid = le16_to_cpu (di->i_gid);
       st->st_author = st->st_uid;
       np->author_tracks_uid = 1;
     }
 
   /* Setup the ext2fs auxiliary inode info.  */
-  info->i_dtime = di->i_dtime;
-  info->i_flags = di->i_flags;
-  info->i_faddr = di->i_faddr;
+  info->i_dtime = le32_to_cpu (di->i_dtime);
+  info->i_flags = le32_to_cpu (di->i_flags);
+  info->i_faddr = le32_to_cpu (di->i_faddr);
   info->i_frag_no = di->i_frag;
   info->i_frag_size = di->i_fsize;
   info->i_osync = 0;
-  info->i_file_acl = di->i_file_acl;
+  info->i_file_acl = le32_to_cpu (di->i_file_acl);
   if (S_ISDIR (st->st_mode))
-    info->i_dir_acl = di->i_dir_acl;
+    info->i_dir_acl = le32_to_cpu (di->i_dir_acl);
   else
     {
       info->i_dir_acl = 0;
-      info->i_high_size = di->i_size_high;
+      info->i_high_size = le32_to_cpu (di->i_size_high);
       if (info->i_high_size)	/* XXX */
 	{
 	  ext2_warning ("cannot handle large file inode %Ld", np->cache_id);
@@ -288,7 +289,7 @@
   dn->last_page_partially_writable = 0;
 
   if (S_ISCHR (st->st_mode) || S_ISBLK (st->st_mode))
-    st->st_rdev = di->i_block[0];
+    st->st_rdev = le32_to_cpu (di->i_block[0]);
   else
     {
       memcpy (info->i_data, di->i_block,
@@ -327,7 +328,7 @@
 static inline error_t
 check_high_bits (struct node *np, long l)
 {
-  if (sblock->s_creator_os == EXT2_OS_HURD)
+  if (sblock->s_creator_os == cpu_to_le32 (EXT2_OS_HURD))
     return 0;
 
   /* Linux 2.3.42 has a mount-time option (not a bit stored on disk)
@@ -372,7 +373,7 @@
 error_t
 diskfs_validate_author_change (struct node *np, uid_t author)
 {
-  if (sblock->s_creator_os == EXT2_OS_HURD)
+  if (sblock->s_creator_os == cpu_to_le32 (EXT2_OS_HURD))
     return 0;
   else
     /* For non-hurd filesystems, the author & owner are the same.  */
@@ -415,7 +416,7 @@
       if (err)
 	return NULL;
 
-      di->i_generation = st->st_gen;
+      di->i_generation = cpu_to_le32 (st->st_gen);
 
       /* We happen to know that the stat mode bits are the same
 	 as the ext2fs mode bits. */
@@ -423,17 +424,17 @@
 
       /* Only the low 16 bits of these fields are standard across all ext2
 	 implementations.  */
-      di->i_mode = st->st_mode & 0xFFFF & ~S_ITRANS;
-      di->i_uid = st->st_uid & 0xFFFF;
-      di->i_gid = st->st_gid & 0xFFFF;
+      di->i_mode = cpu_to_le16 (st->st_mode & 0xFFFF & ~S_ITRANS);
+      di->i_uid = cpu_to_le16 (st->st_uid & 0xFFFF);
+      di->i_gid = cpu_to_le16 (st->st_gid & 0xFFFF);
 
-      if (sblock->s_creator_os == EXT2_OS_HURD)
+      if (sblock->s_creator_os == cpu_to_le32 (EXT2_OS_HURD))
 	/* If this is a hurd-compatible filesystem, write the high bits too. */
 	{
-	  di->i_mode_high = (st->st_mode >> 16) & 0xffff & ~S_ITRANS;
-	  di->i_uid_high = st->st_uid >> 16;
-	  di->i_gid_high = st->st_gid >> 16;
-	  di->i_author = st->st_author;
+	  di->i_mode_high = cpu_to_le16 ((st->st_mode >> 16) & 0xffff & ~S_ITRANS);
+	  di->i_uid_high = cpu_to_le16 (st->st_uid >> 16);
+	  di->i_gid_high = cpu_to_le16 (st->st_gid >> 16);
+	  di->i_author = cpu_to_le32 (st->st_author);
 	}
       else
 	/* No hurd extensions should be turned on.  */
@@ -444,11 +445,11 @@
 	  assert (np->author_tracks_uid && st->st_author == st->st_uid);
 	}
 
-      di->i_links_count = st->st_nlink;
+      di->i_links_count = cpu_to_le16 (st->st_nlink);
 
-      di->i_atime = st->st_atime;
-      di->i_mtime = st->st_mtime;
-      di->i_ctime = st->st_ctime;
+      di->i_atime = cpu_to_le32 (st->st_atime);
+      di->i_mtime = cpu_to_le32 (st->st_mtime);
+      di->i_ctime = cpu_to_le32 (st->st_ctime);
 #ifdef XXX
       di->i_atime.ts_nsec = st->st_atime_usec * 1000;
       di->i_mtime.ts_nsec = st->st_mtime_usec * 1000;
@@ -467,7 +468,7 @@
 	info->i_flags |= EXT2_NODUMP_FL;
       if (st->st_flags & UF_IMMUTABLE)
 	info->i_flags |= EXT2_IMMUTABLE_FL;
-      di->i_flags = info->i_flags;
+      di->i_flags = cpu_to_le32 (info->i_flags);
 
       if (st->st_mode == 0)
 	/* Set dtime non-zero to indicate a deleted file.
@@ -477,12 +478,12 @@
       else
 	{
 	  di->i_dtime = 0;
-	  di->i_size = st->st_size;
-	  di->i_blocks = st->st_blocks;
+	  di->i_size = le32_to_cpu (st->st_size);
+	  di->i_blocks = le32_to_cpu (st->st_blocks);
 	}
 
       if (S_ISCHR(st->st_mode) || S_ISBLK(st->st_mode))
-	di->i_block[0] = st->st_rdev;
+	di->i_block[0] = cpu_to_le32 (st->st_rdev);
       else
 	memcpy (di->i_block, np->dn->info.i_data,
 		EXT2_N_BLOCKS * sizeof di->i_block[0]);
@@ -612,13 +613,14 @@
 {
   st->f_type = FSTYPE_EXT2FS;
   st->f_bsize = block_size;
-  st->f_blocks = sblock->s_blocks_count;
-  st->f_bfree = sblock->s_free_blocks_count;
-  st->f_bavail = st->f_bfree - sblock->s_r_blocks_count;
-  if (st->f_bfree < sblock->s_r_blocks_count)
+  st->f_blocks = le32_to_cpu (sblock->s_blocks_count);
+  st->f_bfree = le32_to_cpu (sblock->s_free_blocks_count);
+  if (st->f_bfree < le32_to_cpu (sblock->s_r_blocks_count))
     st->f_bavail = 0;
-  st->f_files = sblock->s_inodes_count;
-  st->f_ffree = sblock->s_free_inodes_count;
+  else
+    st->f_bavail = st->f_bfree - le32_to_cpu (sblock->s_r_blocks_count);
+  st->f_files = le32_to_cpu (sblock->s_inodes_count);
+  st->f_ffree = le32_to_cpu (sblock->s_free_inodes_count);
   st->f_fsid = getpid ();
   st->f_namelen = 0;
   st->f_favail = st->f_ffree;
@@ -639,7 +641,7 @@
 
   assert (!diskfs_readonly);
 
-  if (sblock->s_creator_os != EXT2_OS_HURD)
+  if (sblock->s_creator_os != cpu_to_le32 (EXT2_OS_HURD))
     return EOPNOTSUPP;
 
   if (namelen + 2 > block_size)
@@ -650,7 +652,7 @@
     return err;
 
   di = dino (np->cache_id);
-  blkno = di->i_translator;
+  blkno = le32_to_cpu (di->i_translator);
 
   if (namelen && !blkno)
     {
@@ -658,7 +660,7 @@
       blkno =
 	ext2_new_block ((np->dn->info.i_block_group
 			 * EXT2_BLOCKS_PER_GROUP (sblock))
-			+ sblock->s_first_data_block,
+			+ le32_to_cpu (sblock->s_first_data_block),
 			0, 0, 0);
       if (blkno == 0)
 	{
@@ -666,7 +668,7 @@
 	  return ENOSPC;
 	}
 
-      di->i_translator = blkno;
+      di->i_translator = cpu_to_le32 (blkno);
       np->dn->info_i_translator = blkno;
       record_global_poke (di);
 
@@ -713,13 +715,13 @@
   unsigned datalen;
   const void *transloc;
 
-  assert (sblock->s_creator_os == EXT2_OS_HURD);
+  assert (sblock->s_creator_os == cpu_to_le32 (EXT2_OS_HURD));
 
   err = diskfs_catch_exception ();
   if (err)
     return err;
 
-  blkno = (dino (np->cache_id))->i_translator;
+  blkno = le32_to_cpu ((dino (np->cache_id))->i_translator);
   assert (blkno);
   transloc = bptr (blkno);
 
Index: ext2fs/pager.c
===================================================================
RCS file: /cvsroot/hurd/hurd/ext2fs/pager.c,v
retrieving revision 1.73
diff -u -r1.73 pager.c
--- ext2fs/pager.c	11 Jun 2002 21:38:01 -0000	1.73
+++ ext2fs/pager.c	9 Aug 2003 12:04:02 -0000
@@ -298,7 +298,7 @@
       block_t dev_block = pb->block << log2_dev_blocks_per_fs_block;
       size_t length = pb->num << log2_block_size, amount;
 
-      ext2_debug ("writing block %u[%ld]", pb->block, pb->num);
+      ext2_debug ("writing block %u[%Ld]", pb->block, pb->num);
 
       if (pb->offs > 0)
 	/* Put what we're going to write into a page-aligned buffer.  */
@@ -381,7 +381,7 @@
   else if (offset + left > node->allocsize)
     left = node->allocsize - offset;
 
-  ext2_debug ("writing inode %d page %d[%d]", node->cache_id, offset, left);
+  ext2_debug ("writing inode %Ld page %d[%d]", node->cache_id, offset, left);
 
   STAT_INC (file_pageouts);
 
@@ -558,10 +558,10 @@
 
 #ifdef EXT2FS_DEBUG
       if (dn->last_page_partially_writable)
-	ext2_debug ("made page %u[%lu] in inode %d partially writable",
+	ext2_debug ("made page %u[%Lu] in inode %Ld partially writable",
 		    page, node->allocsize - page, node->cache_id);
       else
-	ext2_debug ("made page %u[%u] in inode %d writable",
+	ext2_debug ("made page %u[%u] in inode %Ld writable",
 		    page, vm_page_size, node->cache_id);
 #endif
 
@@ -619,7 +619,7 @@
 	  block_t old_page_end_block =
 	    round_page (old_size) >> log2_block_size;
 
-	  ext2_debug ("growing inode %d to %lu bytes (from %lu)", node->cache_id,
+	  ext2_debug ("growing inode %Ld to %Lu bytes (from %Lu)", node->cache_id,
 		      new_size, old_size);
 
 	  if (dn->last_page_partially_writable
@@ -656,7 +656,7 @@
 
       STAT_INC (file_grows);
 
-      ext2_debug ("new size: %ld%s.", new_size,
+      ext2_debug ("new size: %Ld%s.", new_size,
 		  dn->last_page_partially_writable
 		  ? " (last page writable)": "");
       if (err)
@@ -680,6 +680,9 @@
 {
   struct pager *pager;
 
+#if 1
+  ext2_debug ("diskfs_file_update");
+#endif
   spin_lock (&node_to_page_lock);
   pager = node->dn->pager;
   if (pager)
@@ -688,12 +691,18 @@
 
   if (pager)
     {
+#if 1
+      ext2_debug ("pager_sync");
+#endif
       pager_sync (pager, wait);
       ports_port_deref (pager);
     }
 
   pokel_sync (&node->dn->indir_pokel, wait);
 
+#if 1
+  ext2_debug ("diskfs_node_update");
+#endif
   diskfs_node_update (node, wait);
 }
 
Index: ext2fs/truncate.c
===================================================================
RCS file: /cvsroot/hurd/hurd/ext2fs/truncate.c,v
retrieving revision 1.38
diff -u -r1.38 truncate.c
--- ext2fs/truncate.c	3 Dec 2000 04:41:37 -0000	1.38
+++ ext2fs/truncate.c	9 Aug 2003 12:04:02 -0000
@@ -77,7 +77,7 @@
 static inline void
 free_block_run_free_ptr (struct free_block_run *fbr, block_t *p)
 {
-  block_t block = *p;
+  block_t block = le32_to_cpu (*p);
   if (block)
     {
       *p = 0;
@@ -124,7 +124,7 @@
     {
       unsigned index;
       int modified = 0, all_freed = 1;
-      block_t *ind_bh = (block_t *)bptr (*p);
+      block_t *ind_bh = (block_t *)bptr (le32_to_cpu (*p));
       unsigned first = end < offset ? 0 : end - offset;
 
       for (index = first; index < addr_per_block; index++)
Index: pfinet/ethernet.c
===================================================================
RCS file: /cvsroot/hurd/hurd/pfinet/ethernet.c,v
retrieving revision 1.29
diff -u -r1.29 ethernet.c
--- pfinet/ethernet.c	29 May 2002 08:34:35 -0000	1.29
+++ pfinet/ethernet.c	9 Aug 2003 12:04:12 -0000
@@ -109,8 +109,12 @@
       return 1;
     }
 
+#ifdef OSFMACH
+  datalen = ETH_HLEN + msg->packetCnt - sizeof (struct packet_header);
+#else
   datalen = ETH_HLEN
     + msg->packet_type.msgt_number - sizeof (struct packet_header);
+#endif
 
   __mutex_lock (&net_bh_lock);
   skb = alloc_skb (datalen, GFP_ATOMIC);
@@ -147,6 +151,9 @@
   error_t err;
   device_t master_device;
   struct ether_device *edev = (struct ether_device *) dev->priv;
+#ifdef KERNEL_SECURITY_TOKEN_VALUE
+  security_token_t sec_token = KERNEL_SECURITY_TOKEN_VALUE;
+#endif
 
   assert (edev->ether_port == MACH_PORT_NULL);
 
@@ -157,13 +164,32 @@
   mach_port_insert_right (mach_task_self (), edev->readptname, edev->readptname,
 			  MACH_MSG_TYPE_MAKE_SEND);
 
+#ifdef MACH_PORT_RECEIVE_STATUS_COUNT
+  {
+    const mach_port_limits_t lim = { mpl_qlimit: 1 };
+    assert (MACH_PORT_RECEIVE_STATUS_COUNT == sizeof lim / sizeof (natural_t));
+    mach_port_set_attributes (mach_task_self (), edev->readptname,
+			      MACH_PORT_RECEIVE_STATUS,
+			      (mach_port_info_t) &lim,
+			      MACH_PORT_RECEIVE_STATUS_COUNT);
+  }
+#else
   mach_port_set_qlimit (mach_task_self (), edev->readptname, MACH_PORT_QLIMIT_MAX);
+#endif
 
   err = get_privileged_ports (0, &master_device);
   if (err)
     error (2, err, "cannot get device master port");
 
-  err = device_open (master_device, D_WRITE | D_READ, dev->name, &edev->ether_port);
+  err = device_open (master_device,
+#ifdef KERN_INVALID_LEDGER
+		     MACH_PORT_NULL,  /* OSF Mach */
+#endif
+		     D_WRITE | D_READ,
+#ifdef KERNEL_SECURITY_TOKEN_VALUE
+		     sec_token,  /* OSF Mach */
+#endif
+		     dev->name, &edev->ether_port);
   mach_port_deallocate (mach_task_self (), master_device);
   if (err)
     error (2, err, "%s", dev->name);
Index: pfinet/glue-include/linux/mm.h
===================================================================
RCS file: /cvsroot/hurd/hurd/pfinet/glue-include/linux/mm.h,v
retrieving revision 1.2
diff -u -r1.2 mm.h
--- pfinet/glue-include/linux/mm.h	5 Feb 2000 12:48:25 -0000	1.2
+++ pfinet/glue-include/linux/mm.h	9 Aug 2003 12:04:12 -0000
@@ -19,6 +19,7 @@
 #include <sys/mman.h>
 #include <stdint.h>
 
+#define PAGE_SHIFT 12
 #define PAGE_SIZE	(1 << PAGE_SHIFT)
 
 /* The one use of this is by net/ipv4/tcp.c::tcp_init, which
Index: pfinet/linux-src/arch/ppc/lib/checksum.S
===================================================================
RCS file: /cvsroot/hurd/hurd/pfinet/linux-src/arch/ppc/lib/checksum.S,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 checksum.S
--- pfinet/linux-src/arch/ppc/lib/checksum.S	4 Feb 2000 03:21:18 -0000	1.1.1.1
+++ pfinet/linux-src/arch/ppc/lib/checksum.S	9 Aug 2003 12:04:12 -0000
@@ -12,10 +12,14 @@
  * Severely hacked about by Paul Mackerras (paulus@cs.anu.edu.au).
  */
 
-#include <linux/sys.h>
-#include <asm/processor.h>
-#include <asm/errno.h>
-#include "../kernel/ppc_asm.tmpl"
+/* #include <linux/sys.h> */
+/* #include <asm/processor.h> */
+/* #include <asm/errno.h> */
+/* #include "../kernel/ppc_asm.tmpl" */
+
+#define _GLOBAL(x)\
+	.globl x;\
+x:
 
 	.text
 
@@ -24,19 +28,19 @@
  * len is in words and is always >= 5.
  */
 _GLOBAL(ip_fast_csum)
-	lwz	r0,0(r3)
-	lwzu	r5,4(r3)
-	addi	r4,r4,-2
-	addc	r0,r0,r5
-	mtctr	r4
-1:	lwzu	r4,4(r3)
-	adde	r0,r0,r4
+	lwz	%r0,0(%r3)
+	lwzu	%r5,4(%r3)
+	addi	%r4,%r4,-2
+	addc	%r0,%r0,%r5
+	mtctr	%r4
+1:	lwzu	%r4,4(%r3)
+	adde	%r0,%r0,%r4
 	bdnz	1b
-	addze	r0,r0		/* add in final carry */
-	rlwinm	r3,r0,16,0,31	/* fold two halves together */
-	add	r3,r0,r3
-	not	r3,r3
-	srwi	r3,r3,16
+	addze	%r0,%r0		/* add in final carry */
+	rlwinm	%r3,%r0,16,0,31	/* fold two halves together */
+	add	%r3,%r0,%r3
+	not	%r3,%r3
+	srwi	%r3,%r3,16
 	blr
 
 /*
@@ -44,15 +48,15 @@
  *   csum_tcpudp_magic(saddr, daddr, len, proto, sum)
  */	
 _GLOBAL(csum_tcpudp_magic)
-	rlwimi	r5,r6,16,0,15	/* put proto in upper half of len */
-	addc	r0,r3,r4	/* add 4 32-bit words together */
-	adde	r0,r0,r5
-	adde	r0,r0,r7
-	addze	r0,r0		/* add in final carry */
-	rlwinm	r3,r0,16,0,31	/* fold two halves together */
-	add	r3,r0,r3
-	not	r3,r3
-	srwi	r3,r3,16
+	rlwimi	%r5,%r6,16,0,15	/* put proto in upper half of len */
+	addc	%r0,%r3,%r4	/* add 4 32-bit words together */
+	adde	%r0,%r0,%r5
+	adde	%r0,%r0,%r7
+	addze	%r0,%r0		/* add in final carry */
+	rlwinm	%r3,%r0,16,0,31	/* fold two halves together */
+	add	%r3,%r0,%r3
+	not	%r3,%r3
+	srwi	%r3,%r3,16
 	blr
 
 /*
@@ -62,35 +66,35 @@
  * csum_partial(buff, len, sum)
  */
 _GLOBAL(csum_partial)
-	addic	r0,r5,0
-	subi	r3,r3,4
-	srwi.	r6,r4,2
+	addic	%r0,%r5,0
+	subi	%r3,%r3,4
+	srwi.	%r6,%r4,2
 	beq	3f		/* if we're doing < 4 bytes */
-	andi.	r5,r3,2		/* Align buffer to longword boundary */
+	andi.	%r5,%r3,2	/* Align buffer to longword boundary */
 	beq+	1f
-	lhz	r5,4(r3)	/* do 2 bytes to get aligned */
-	addi	r3,r3,2
-	subi	r4,r4,2
-	addc	r0,r0,r5
-	srwi.	r6,r4,2		/* # words to do */
+	lhz	%r5,4(%r3)	/* do 2 bytes to get aligned */
+	addi	%r3,%r3,2
+	subi	%r4,%r4,2
+	addc	%r0,%r0,%r5
+	srwi.	%r6,%r4,2	/* # words to do */
 	beq	3f
-1:	mtctr	r6
-2:	lwzu	r5,4(r3)	/* the bdnz has zero overhead, so it should */
-	adde	r0,r0,r5	/* be unnecessary to unroll this loop */
+1:	mtctr	%r6
+2:	lwzu	%r5,4(%r3)	/* the bdnz has zero overhead, so it should */
+	adde	%r0,%r0,%r5	/* be unnecessary to unroll this loop */
 	bdnz	2b
-	andi.	r4,r4,3
-3:	cmpi	0,r4,2
+	andi.	%r4,%r4,3
+3:	cmpi	0,%r4,2
 	blt+	4f
-	lhz	r5,4(r3)
-	addi	r3,r3,2
-	subi	r4,r4,2
-	adde	r0,r0,r5
-4:	cmpi	0,r4,1
+	lhz	%r5,4(%r3)
+	addi	%r3,%r3,2
+	subi	%r4,%r4,2
+	adde	%r0,%r0,%r5
+4:	cmpi	0,%r4,1
 	bne+	5f
-	lbz	r5,4(r3)
-	slwi	r5,r5,8		/* Upper byte of word */
-	adde	r0,r0,r5
-5:	addze	r3,r0		/* add in final carry */
+	lbz	%r5,4(%r3)
+	slwi	%r5,%r5,8	/* Upper byte of word */
+	adde	%r0,%r0,%r5
+5:	addze	%r3,%r0		/* add in final carry */
 	blr
 
 /*
@@ -103,81 +107,82 @@
  * csum_partial_copy_generic(src, dst, len, sum, src_err, dst_err)
  */
 _GLOBAL(csum_partial_copy_generic)
-	addic	r0,r6,0
-	subi	r3,r3,4
-	subi	r4,r4,4
-	srwi.	r6,r5,2
+	addic	%r0,%r6,0
+	subi	%r3,%r3,4
+	subi	%r4,%r4,4
+	srwi.	%r6,%r5,2
 	beq	3f		/* if we're doing < 4 bytes */
-	andi.	r9,r4,2		/* Align dst to longword boundary */
+	andi.	%r9,%r4,2	/* Align dst to longword boundary */
 	beq+	1f
-81:	lhz	r6,4(r3)	/* do 2 bytes to get aligned */
-	addi	r3,r3,2
-	subi	r5,r5,2
-91:	sth	r6,4(r4)
-	addi	r4,r4,2
-	addc	r0,r0,r6
-	srwi.	r6,r5,2		/* # words to do */
+81:	lhz	%r6,4(%r3)	/* do 2 bytes to get aligned */
+	addi	%r3,%r3,2
+	subi	%r5,%r5,2
+91:	sth	%r6,4(%r4)
+	addi	%r4,%r4,2
+	addc	%r0,%r0,%r6
+	srwi.	%r6,%r5,2	/* # words to do */
 	beq	3f
-1:	mtctr	r6
-82:	lwzu	r6,4(r3)	/* the bdnz has zero overhead, so it should */
-92:	stwu	r6,4(r4)	/* be unnecessary to unroll this loop */
-	adde	r0,r0,r6
+1:	mtctr	%r6
+82:	lwzu	%r6,4(%r3)	/* the bdnz has zero overhead, so it should */
+92:	stwu	%r6,4(%r4)	/* be unnecessary to unroll this loop */
+	adde	%r0,%r0,%r6
 	bdnz	82b
-	andi.	r5,r5,3
-3:	cmpi	0,r5,2
+	andi.	%r5,%r5,3
+3:	cmpi	0,%r5,2
 	blt+	4f
-83:	lhz	r6,4(r3)
-	addi	r3,r3,2
-	subi	r5,r5,2
-93:	sth	r6,4(r4)
-	addi	r4,r4,2
-	adde	r0,r0,r6
-4:	cmpi	0,r5,1
+83:	lhz	%r6,4(%r3)
+	addi	%r3,%r3,2
+	subi	%r5,%r5,2
+93:	sth	%r6,4(%r4)
+	addi	%r4,%r4,2
+	adde	%r0,%r0,%r6
+4:	cmpi	0,%r5,1
 	bne+	5f
-84:	lbz	r6,4(r3)
-94:	stb	r6,4(r4)
-	slwi	r6,r6,8		/* Upper byte of word */
-	adde	r0,r0,r6
-5:	addze	r3,r0		/* add in final carry */
+84:	lbz	%r6,4(%r3)
+94:	stb	%r6,4(%r4)
+	slwi	%r6,%r6,8	/* Upper byte of word */
+	adde	%r0,%r0,%r6
+5:	addze	%r3,%r0		/* add in final carry */
 	blr
 
+#if 0
 /* These shouldn't go in the fixup section, since that would
    cause the ex_table addresses to get out of order. */
 
 src_error_1:
-	li	r6,0
-	subi	r5,r5,2
-95:	sth	r6,4(r4)
-	addi	r4,r4,2
-	srwi.	r6,r5,2
+	li	%r6,0
+	subi	%r5,%r5,2
+95:	sth	%r6,4(%r4)
+	addi	%r4,%r4,2
+	srwi.	%r6,%r5,2
 	beq	3f
-	mtctr	r6
+	mtctr	%r6
 src_error_2:
-	li	r6,0
-96:	stwu	r6,4(r4)
+	li	%r6,0
+96:	stwu	%r6,4(%r4)
 	bdnz	96b
-3:	andi.	r5,r5,3
+3:	andi.	%r5,%r5,3
 	beq	src_error
 src_error_3:
-	li	r6,0
-	mtctr	r5
-	addi	r4,r4,3
-97:	stbu	r6,1(r4)
+	li	%r6,0
+	mtctr	%r5
+	addi	%r4,%r4,3
+97:	stbu	%r6,1(%r4)
 	bdnz	97b
 src_error:
-	cmpi	0,r7,0
+	cmpi	0,%r7,0
 	beq	1f
-	li	r6,-EFAULT
-	stw	r6,0(r7)
-1:	addze	r3,r0
+	li	%r6,-EFAULT
+	stw	%r6,0(%r7)
+1:	addze	%r3,%r0
 	blr
 
 dst_error:
-	cmpi	0,r8,0
+	cmpi	0,%r8,0
 	beq	1f
-	li	r6,-EFAULT
-	stw	r6,0(r8)
-1:	addze	r3,r0
+	li	%r6,-EFAULT
+	stw	%r6,0(%r8)
+1:	addze	%r3,%r0
 	blr
 
 .section __ex_table,"a"
@@ -192,3 +197,4 @@
 	.long	95b,dst_error
 	.long	96b,dst_error
 	.long	97b,dst_error
+#endif
Index: pfinet/linux-src/include/asm-ppc/checksum.h
===================================================================
RCS file: /cvsroot/hurd/hurd/pfinet/linux-src/include/asm-ppc/checksum.h,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 checksum.h
--- pfinet/linux-src/include/asm-ppc/checksum.h	4 Feb 2000 03:21:18 -0000	1.1.1.1
+++ pfinet/linux-src/include/asm-ppc/checksum.h	9 Aug 2003 12:04:12 -0000
@@ -82,11 +82,11 @@
 						   unsigned short proto,
 						   unsigned int sum) 
 {
-    __asm__("
-	addc %0,%0,%1
-	adde %0,%0,%2
-	adde %0,%0,%3
-	addze %0,%0
+    __asm__("\n\
+	addc %0,%0,%1\n\
+	adde %0,%0,%2\n\
+	adde %0,%0,%3\n\
+	addze %0,%0\n\
 	"
 	: "=r" (sum)
 	: "r" (daddr), "r"(saddr), "r"((proto<<16)+len), "0"(sum));
Index: proc/cpu-types.c
===================================================================
RCS file: /cvsroot/hurd/hurd/proc/cpu-types.c,v
retrieving revision 1.4
diff -u -r1.4 cpu-types.c
--- proc/cpu-types.c	20 Jul 1998 07:18:46 -0000	1.4
+++ proc/cpu-types.c	9 Aug 2003 12:04:13 -0000
@@ -77,8 +77,24 @@
 	[CPU_SUBTYPE_MMAX_APC_FPU] = "MMAX_APC_FPU",
 	[CPU_SUBTYPE_MMAX_APC_FPA] = "MMAX_APC_FPA",
 	[CPU_SUBTYPE_MMAX_XPC] = "MMAX_XPC",
+#ifdef OSFMACH
+	[CPU_SUBTYPE_SQT86] = "SQT86",
+#else
 	[CPU_SUBTYPE_PC532] = "PC532",
+#endif  /* OSFMACH */
       },
+#ifdef OSFMACH
+#define Ix86_SUBTYPES							    \
+      {									    \
+	[CPU_SUBTYPE_AT386] = "AT386",					    \
+	[CPU_SUBTYPE_EXL] = "EXL",					    \
+	[CPU_SUBTYPE_iPSC386] = "iPSC386",				    \
+	[CPU_SUBTYPE_SYMMETRY] = "SYMMETRY",				    \
+	[CPU_SUBTYPE_CBUS] = "CBUS",					    \
+	[CPU_SUBTYPE_MBUS] = "MBUS",					    \
+	[CPU_SUBTYPE_MPS] = "MPS",					    \
+      }
+#else
 #define Ix86_SUBTYPES							    \
       {									    \
 	[CPU_SUBTYPE_AT386] = "AT386",					    \
@@ -87,6 +103,7 @@
 	[CPU_SUBTYPE_SYMMETRY] = "SYMMETRY",				    \
 	[CPU_SUBTYPE_PS2] = "PS2",					    \
       }
+#endif  /* OSFMACH */
     [CPU_TYPE_I386] = Ix86_SUBTYPES,
 #ifdef CPU_TYPE_I486
     [CPU_TYPE_I486] = Ix86_SUBTYPES,
@@ -151,6 +168,10 @@
     [CPU_TYPE_I860] =
       {
 	[CPU_SUBTYPE_iPSC860] = "iPSC860",
+#ifdef OSFMACH
+	[CPU_SUBTYPE_PARAGON860] = "PARAGON860",
+	[CPU_SUBTYPE_PARAGON860_MP] = "PARAGON860_MP",
+#endif  /* OSFMACH */
 	[CPU_SUBTYPE_OKI860] = "OKI860",
       },
     [CPU_TYPE_ALPHA] =
@@ -160,4 +181,17 @@
 	[CPU_SUBTYPE_ALPHA_ISP] = "ALPHA_ISP",
 	[CPU_SUBTYPE_ALPHA_21064] = "ALPHA_21064",
       },
+#ifdef OSFMACH
+    [CPU_TYPE_POWERPC] =
+      {
+	[CPU_SUBTYPE_PPC601] = "PPC601",
+	[CPU_SUBTYPE_PPC603] = "PPC603",
+	[CPU_SUBTYPE_PPC604] = "PPC604",
+	[CPU_SUBTYPE_PPC602] = "PPC602",
+	[CPU_SUBTYPE_PPC603e] = "PPC603e",
+	[CPU_SUBTYPE_PPC603ev] = "PPC603ev",
+	[CPU_SUBTYPE_PPC604e] = "PPC604e",
+	[CPU_SUBTYPE_PPC620] = "PPC620",
+      },
+#endif  /* OSFMACH */
   };
Index: proc/host.c
===================================================================
RCS file: /cvsroot/hurd/hurd/proc/host.c,v
retrieving revision 1.18
diff -u -r1.18 host.c
--- proc/host.c	8 May 2002 09:24:49 -0000	1.18
+++ proc/host.c	9 Aug 2003 12:04:13 -0000
@@ -359,9 +359,14 @@
   err = host_info (mach_host_self (), HOST_BASIC_INFO,
 		   (host_info_t) &info, &n);
   assert (! err);
+  /* On the PowerPC, we get the contents of the processor version
+     register instead of the upper 16 bits, which encode the CPU
+     subtype.  */
   snprintf (uname_info.machine, sizeof uname_info.machine, "%s-%s",
 	    mach_cpu_types[info.cpu_type],
-	    mach_cpu_subtypes[info.cpu_type][info.cpu_subtype]);
+	    mach_cpu_subtypes[info.cpu_type]
+	    [info.cpu_type == CPU_TYPE_POWERPC ?
+	     info.cpu_subtype >> 16 : info.cpu_subtype]);
 
   /* Notice Mach's and our own version and initialize server version
      variables. */
Index: proc/info.c
===================================================================
RCS file: /cvsroot/hurd/hurd/proc/info.c,v
retrieving revision 1.45
diff -u -r1.45 info.c
--- proc/info.c	5 Jun 2002 23:28:46 -0000	1.45
+++ proc/info.c	9 Aug 2003 12:04:13 -0000
@@ -463,6 +463,10 @@
 
   pi->nthreads = nthreads;
 
+#ifdef NO_CREATION_TIME
+  pi->creation_time = p->p_creation_time;
+#endif
+  
   /* Release GLOBAL_LOCK around time consuming bits, and more importatantly,
      potential calls to P's msgport, which can block.  */
   mutex_unlock (&global_lock);
@@ -477,7 +481,7 @@
 #ifdef TASK_SCHED_TIMESHARE_INFO
       if (!err)
 	{
-	  tkcount = TASK_SCHED_TIMESHARE_INFO_COUNT;
+	  tkcount = POLICY_TIMESHARE_INFO_COUNT;
 	  err = task_info (task, TASK_SCHED_TIMESHARE_INFO,
 			   (int *)&pi->timeshare_base_info, &tkcount);
 	  if (err == KERN_INVALID_POLICY)
@@ -523,10 +527,17 @@
 
       if (*flags & PI_FETCH_THREAD_SCHED)
 	{
+#ifdef OSFMACH
+	  thcount = POLICY_TIMESHARE_INFO_COUNT;
+	  err = thread_info (thds[i], THREAD_SCHED_TIMESHARE_INFO,
+			     (thread_info_t) &pi->threadinfos[i].pis_pi,
+			     &thcount);
+#else
 	  thcount = THREAD_SCHED_INFO_COUNT;
 	  err = thread_info (thds[i], THREAD_SCHED_INFO,
 			     (thread_info_t) &pi->threadinfos[i].pis_si,
 			     &thcount);
+#endif  /* OSFMACH */
 	  if (err == MACH_SEND_INVALID_DEST)
 	    {
 	      pi->threadinfos[i].died = 1;
Index: proc/main.c
===================================================================
RCS file: /cvsroot/hurd/hurd/proc/main.c,v
retrieving revision 1.30
diff -u -r1.30 main.c
--- proc/main.c	15 Apr 2001 08:10:51 -0000	1.30
+++ proc/main.c	9 Aug 2003 12:04:13 -0000
@@ -112,10 +112,31 @@
   assert_perror (err);
   err = host_processor_set_priv (master_host_port, pset, &psetcntl);
   assert_perror (err);
-  thread_max_priority (mach_thread_self (), psetcntl, 0);
+#ifdef OSFMACH
+#if 0  /* XXX */
+  {
+    policy_timeshare_base_data_t base;
+    policy_timeshare_limit_data_t limit;
+
+    base.base_priority = 2;
+    limit.max_priority = 0;
+    err = thread_set_policy (mach_thread_self (), psetcntl, POLICY_TIMESHARE,
+			     (policy_base_t) &base, POLICY_TIMESHARE_BASE_COUNT,
+			     (policy_limit_t) &limit, POLICY_TIMESHARE_LIMIT_COUNT);
+    assert_perror (err);
+    
+    base.base_priority = 2;
+    err = task_policy (mach_task_self (), POLICY_TIMESHARE, (policy_base_t) &base,
+		       POLICY_TIMESHARE_BASE_COUNT, 0, 1);
+    assert_perror (err);
+  }
+#endif
+#else
+  err = thread_max_priority (mach_thread_self (), psetcntl, 0);
   assert_perror (err);
   err = task_priority (mach_task_self (), 2, 1);
   assert_perror (err);
+#endif  /* OSFMACH */
 
   mach_port_deallocate (mach_task_self (), pset);
   mach_port_deallocate (mach_task_self (), psetcntl);
@@ -125,7 +146,13 @@
        to panic or something.  */
     mach_port_t cons;
     error_t err;
+#ifdef OSFMACH
+    security_token_t sec_token = KERNEL_SECURITY_TOKEN_VALUE;
+    err = device_open (master_device_port, MACH_PORT_NULL, D_READ | D_WRITE,
+		       sec_token, "console", &cons);
+#else
     err = device_open (master_device_port, D_READ|D_WRITE, "console", &cons);
+#endif  /* OSFMACH */
     assert_perror (err);
     stdin = mach_open_devstream (cons, "r");
     stdout = stderr = mach_open_devstream (cons, "w");
Index: proc/mgt.c
===================================================================
RCS file: /cvsroot/hurd/hurd/proc/mgt.c,v
retrieving revision 1.65
diff -u -r1.65 mgt.c
--- proc/mgt.c	8 May 2002 09:24:52 -0000	1.65
+++ proc/mgt.c	9 Aug 2003 12:04:14 -0000
@@ -1,5 +1,5 @@
 /* Process management
-   Copyright (C) 1992,93,94,95,96,99,2000,01,02 Free Software Foundation, Inc.
+   Copyright (C) 1992,93,94,95,96,99,2000,01,02,03 Free Software Foundation, Inc.
 
 This file is part of the GNU Hurd.
 
@@ -32,6 +32,9 @@
 #include <sys/resource.h>
 #include <hurd/auth.h>
 #include <assert.h>
+#ifdef NO_CREATION_TIME
+#include <sys/time.h>
+#endif
 
 #include "proc.h"
 #include "process_S.h"
@@ -403,6 +406,17 @@
 /* Called on exception ports provided to proc_handle_exceptions.  Do
    the thread_set_state requested by proc_handle_exceptions and then
    send an exception_raise message as requested. */
+#ifdef OSFMACH
+kern_return_t
+S_proc_exception_raise (mach_port_t excport,
+			mach_port_t reply,
+			mach_msg_type_name_t reply_type,
+			mach_port_t thread,
+			mach_port_t task,
+			exception_type_t exception,
+			exception_data_t code,
+			mach_msg_type_number_t count)
+#else
 kern_return_t
 S_proc_exception_raise (mach_port_t excport,
 			mach_port_t reply,
@@ -412,6 +426,7 @@
 			integer_t exception,
 			integer_t code,
 			integer_t subcode)
+#endif
 {
   error_t err;
   struct proc *p;
@@ -428,9 +443,15 @@
     }
 
   /* Try to forward the message.  */
+#ifdef OSFMACH  /* XXX What to do here?  */
+  err = proc_exception_raise (e->forwardport, reply, reply_type,
+			      0, thread, task,
+			      exception, code, count);
+#else
   err = proc_exception_raise (e->forwardport,
 			      reply, reply_type, MACH_SEND_NOTIFY,
 			      thread, task, exception, code, subcode);
+#endif
 
   switch (err)
     {
@@ -451,16 +472,23 @@
       /* Some unexpected error in forwarding the message.  */
       /* FALLTHROUGH */
 
-    case MACH_SEND_NOTIFY_IN_PROGRESS:
+#ifdef MACH_SEND_NOTIFY_IN_PROGRESS
+      case MACH_SEND_NOTIFY_IN_PROGRESS:
       /* The port's queue is full; this means the thread didn't receive
 	 the exception message we forwarded last time it faulted.
 	 Declare that signal thread hopeless and the task crashed.  */
+#endif
 
       /* Translate the exception code into a signal number
 	 and mark the process as having died that way.  */
       hsd.exc = exception;
+#ifdef EXC_MASK_ALL
+      hsd.exc_code = code[0];
+      hsd.exc_subcode = code[1];
+#else
       hsd.exc_code = code;
       hsd.exc_subcode = subcode;
+#endif
       _hurd_exception2signal (&hsd, &signo);
       p->p_exiting = 1;
       p->p_status = W_EXITCODE (0, signo);
@@ -564,6 +592,10 @@
 
   condition_init (&p->p_wakeup);
 
+#ifdef NO_CREATION_TIME
+  gettimeofday (&p->p_creation_time, NULL);
+#endif
+
   return p;
 }
 
@@ -796,7 +828,11 @@
   int i;
   struct proc *foundp = 0;
 
+#ifdef OSFMACH
+  host_processor_sets (master_host_port, &psets, &npsets);
+#else
   host_processor_sets (mach_host_self (), &psets, &npsets);
+#endif
   for (i = 0; i < npsets; i++)
     {
       mach_port_t psetpriv;
Index: proc/proc.h
===================================================================
RCS file: /cvsroot/hurd/hurd/proc/proc.h,v
retrieving revision 1.27
diff -u -r1.27 proc.h
--- proc/proc.h	22 Dec 2001 21:00:25 -0000	1.27
+++ proc/proc.h	9 Aug 2003 12:04:14 -0000
@@ -1,5 +1,5 @@
 /* Process server definitions
-   Copyright (C) 1992,93,94,95,96,99,2000,01 Free Software Foundation, Inc.
+   Copyright (C) 1992,93,94,95,96,99,2000,01,03 Free Software Foundation, Inc.
 
 This file is part of the GNU Hurd.
 
@@ -26,6 +26,9 @@
 #include <sys/mman.h>
 #include <hurd/ports.h>
 #include <cthreads.h>
+#ifdef NO_CREATION_TIME
+#include <sys/time.h>
+#endif
 
 struct proc
 {
@@ -68,6 +71,10 @@
   struct rusage p_rusage;	/* my usage if I'm dead, to return via wait */
 
   struct rusage p_child_rusage;	/* accumulates p_rusage of all dead children */
+
+#ifdef NO_CREATION_TIME
+  struct timeval p_creation_time; /* time of registration by proc server */
+#endif
 
   unsigned int p_exec:1;	/* has called proc_mark_exec */
   unsigned int p_stopped:1;	/* has called proc_mark_stop */
Index: proc/proc_exc.defs
===================================================================
RCS file: /cvsroot/hurd/hurd/proc/proc_exc.defs,v
retrieving revision 1.3
diff -u -r1.3 proc_exc.defs
--- proc/proc_exc.defs	9 Feb 1996 20:22:32 -0000	1.3
+++ proc/proc_exc.defs	9 Aug 2003 12:04:14 -0000
@@ -31,9 +31,34 @@
 subsystem proc_exc 2400;
 
 #include <mach/std_types.defs>
+#ifdef OSFMACH
+#include <mach/mach_types.defs>
+#endif
 
 ServerPrefix S_;
 
+#ifdef OSFMACH
+type exception_data_t = array[*:2] of integer_t;
+type exception_type_t = int;
+
+skip;  /* was old style interface */
+
+routine proc_exception_raise (
+	exception_port: mach_port_t;
+	replyport reply: mach_port_poly_t;
+	msgoption flags: integer_t;
+	thread: mach_port_t;
+	task: mach_port_t;
+	exception: exception_type_t;
+	code: exception_data_t
+	);
+
+skip;  /* exception_raise_state */
+
+skip;  /* exception_raise_state_identity */
+
+#else
+
 routine proc_exception_raise (
 	exception_port: mach_port_t;
 	replyport reply: mach_port_poly_t;
@@ -44,5 +69,4 @@
 	code: integer_t;
 	subcode: integer_t);
 
-
-
+#endif  /* OSFMACH */
Index: proc/stubs.c
===================================================================
RCS file: /cvsroot/hurd/hurd/proc/stubs.c,v
retrieving revision 1.6
diff -u -r1.6 stubs.c
--- proc/stubs.c	13 Mar 2000 23:52:57 -0000	1.6
+++ proc/stubs.c	9 Aug 2003 12:04:14 -0000
@@ -28,6 +28,17 @@
 #define RPCID_SIG_POST 23000
 
 
+#ifdef OSFMACH
+struct msg_sig_post_request
+{
+  mach_msg_header_t head;
+  mach_msg_body_t body;
+  mach_msg_port_descriptor_t refport;
+  NDR_record_t NDR;
+  int signal;
+  natural_t sigcode;
+};
+#else
 struct msg_sig_post_request
 {
   mach_msg_header_t head;
@@ -38,6 +49,7 @@
   mach_msg_type_t refporttype;
   mach_port_t refport;
 };
+#endif  /* OSFMACH */
 
 /* Send the Mach message indicated by msg_spec.   call cthread_exit
    when it has been delivered. */
@@ -58,8 +70,10 @@
     case MACH_SEND_TIMED_OUT:
     case MACH_SEND_INTERRUPTED:
     case MACH_SEND_INVALID_NOTIFY:
+#ifndef OSFMACH
     case MACH_SEND_NO_NOTIFY:
     case MACH_SEND_NOTIFY_IN_PROGRESS:
+#endif  /* OSFMACH */
       assert_perror (err);
       break;
 
@@ -95,6 +109,23 @@
       0,			/* msgh_seqno */
       RPCID_SIG_POST,		/* msgh_id */
     },
+#ifdef OSFMACH
+    {
+      /* Message body */
+      1,			/* msgh_descriptor_count */
+    },
+    {
+      /* Port descriptor */
+      refport,			/* name */
+      0,			/* pad1 */
+      0,			/* pad2 */
+      19,			/* disposition */
+      MACH_MSG_PORT_DESCRIPTOR,	/* type */
+    },
+    NDR_record,
+    signal,
+    0
+#else
     {
       /* Type descriptor for signo */
       MACH_MSG_TYPE_INTEGER_32, /* msgt_name */
@@ -130,6 +161,7 @@
       0,			/* msgt_unused */
     },
     refport
+#endif  /* OSFMACH */
   };
 
   err = mach_msg ((mach_msg_header_t *)&message,
@@ -157,8 +189,10 @@
 	 None of them should be possible in our usage.  */
     case MACH_SEND_INTERRUPTED:
     case MACH_SEND_INVALID_NOTIFY:
+#ifndef OSFMACH
     case MACH_SEND_NO_NOTIFY:
     case MACH_SEND_NOTIFY_IN_PROGRESS:
+#endif  /* OSFMACH */
       assert_perror (err);
       break;
 
Index: sutils/swapon.c
===================================================================
RCS file: /cvsroot/hurd/hurd/sutils/swapon.c,v
retrieving revision 1.9
diff -u -r1.9 swapon.c
--- sutils/swapon.c	26 Jun 2002 18:19:07 -0000	1.9
+++ sutils/swapon.c	9 Aug 2003 12:04:21 -0000
@@ -320,7 +320,11 @@
   int quiet_now = 0;
 
  try_again:
+#if 1
+  err = store_device_open (file, 0, &store);
+#else
   err = store_open (file, 0, 0, &store);
+#endif
   if (err)
     {
       error (0, err, "%s", file);
@@ -397,6 +401,26 @@
 	}
     }
 
+#ifdef OSFMACH
+  {
+    mach_port_t backing_store;  /* XXX swapoff needs this port */
+    size_t i;
+    err = default_pager_backing_store_create (def_pager,
+					      DEFAULT_PAGER_BACKING_STORE_MAXPRI,
+					      4096, &backing_store);
+    if (err)
+      error (15, err, "Cannot create backing store");
+    for (i = 0; i < store->num_runs; i++) {
+      err = default_pager_add_segment (backing_store,
+				       store->port,
+				       store->runs[i].start,
+				       store->runs[i].length,
+				       store->block_size);
+      if (err)
+	error (16, err, "Cannot add segment");
+    }
+  }
+#else
   if (old_protocol)
     {
       /* The default pager does not support the new protocol.
@@ -431,6 +455,7 @@
 	  goto try_again;
 	}
     }
+#endif
 
   store_free (store);
 
Index: term/devio.c
===================================================================
RCS file: /cvsroot/hurd/hurd/term/devio.c,v
retrieving revision 1.33
diff -u -r1.33 devio.c
--- term/devio.c	26 Jun 2002 19:22:58 -0000	1.33
+++ term/devio.c	9 Aug 2003 12:04:21 -0000
@@ -43,6 +43,25 @@
 #undef EXTA
 #undef EXTB
 
+
+#ifdef OSFMACH
+#define B50	1
+#define B75	2
+#define B110	3
+#define B134	4
+#define B150	5
+#define B200	6
+#define B300	7
+#define B600	8
+#define B1200	9
+#define B1800	10
+#define B2400	11
+#define B4800	12
+#define B9600	13
+#define EXTA	14
+#define EXTB	15
+#endif  /* OSFMACH */
+
 #include <assert.h>
 #include <errno.h>
 #include <error.h>
@@ -457,6 +476,9 @@
 initial_open ()
 {
   error_t err;
+#ifdef OSFMACH
+  security_token_t sec_token = KERNEL_SECURITY_TOKEN_VALUE;
+#endif
 
   assert (open_pending != FAKE);
 
@@ -475,8 +497,14 @@
 
   phys_reply = ports_get_send_right (phys_reply_pi);
 
+#ifdef OSFMACH
+  err = device_open_request (device_master, phys_reply,
+			     MACH_PORT_NULL, D_READ | D_WRITE,
+			     sec_token, tty_arg);
+#else
   err = device_open_request (device_master, phys_reply,
 			     D_READ|D_WRITE, tty_arg);
+#endif  /* OSFMACH */
   if (err)
     {
       mach_port_deallocate (mach_task_self (), phys_reply);
@@ -508,6 +536,9 @@
 devio_assert_dtr ()
 {
   error_t err;
+#ifdef OSFMACH
+  security_token_t sec_token = KERNEL_SECURITY_TOKEN_VALUE;
+#endif
 
   /* The first time is special. */
   if (phys_device == MACH_PORT_NULL)
@@ -519,8 +550,14 @@
   if (open_pending == FAKE)
     return 0;
 
+#ifdef OSFMACH
+  err = device_open_request (device_master, phys_reply,
+			     MACH_PORT_NULL, D_READ | D_WRITE,
+			     sec_token, tty_arg);
+#else
   err = device_open_request (device_master, phys_reply,
 			     D_READ|D_WRITE, tty_arg);
+#endif  /* OSFMACH */
 
   if (err)
     return err;
@@ -720,6 +757,16 @@
 {
   return EOPNOTSUPP;
 }
+
+#ifdef OSFMACH
+kern_return_t
+device_read_reply_overwrite (mach_port_t replyport,
+			     kern_return_t retcode,
+			     io_buf_len_t bytes_read)
+{
+  return EOPNOTSUPP;
+}
+#endif  /* OSFMACH */
 
 kern_return_t
 device_write_reply (mach_port_t replyport,
Index: tmpfs/tmpfs.c
===================================================================
RCS file: /cvsroot/hurd/hurd/tmpfs/tmpfs.c,v
retrieving revision 1.15
diff -u -r1.15 tmpfs.c
--- tmpfs/tmpfs.c	25 Jun 2002 05:07:25 -0000	1.15
+++ tmpfs/tmpfs.c	9 Aug 2003 12:04:21 -0000
@@ -194,7 +194,22 @@
 	      {
 		/* Set as a percentage of the machine's physical memory.  */
 		struct vm_statistics vmstats;
+#ifdef OSFMACH
+		/* XXX must be privileged for host_statistics () */
+		mach_msg_type_number_t cnt = HOST_VM_INFO_COUNT;
+		mach_port_t host;
+		error_t err = get_privileged_ports (&host, NULL);
+		if (err)
+		  {
+		    argp_error (state, "cannot get master host port: %s",
+				strerror (err));
+		    return err;
+		  }
+		err = host_statistics (host, HOST_VM_INFO,
+				       (host_info_t) &vmstats, &cnt);
+#else
 		error_t err = vm_statistics (mach_task_self (), &vmstats);
+#endif
 		if (err)
 		  {
 		    argp_error (state, "cannot find total physical memory: %s",
Index: trans/streamio.c
===================================================================
RCS file: /cvsroot/hurd/hurd/trans/streamio.c,v
retrieving revision 1.10
diff -u -r1.10 streamio.c
--- trans/streamio.c	21 Jun 2002 19:12:03 -0000	1.10
+++ trans/streamio.c	9 Aug 2003 12:04:21 -0000
@@ -776,7 +776,15 @@
 			      phys_reply_writes, MACH_MSG_TYPE_MAKE_SEND);
     }
 
+#ifdef KERN_INVALID_LEDGER
+  {
+    security_token_t sec_token = KERNEL_SECURITY_TOKEN_VALUE;
+    err = device_open_request (device_master, phys_reply, MACH_PORT_NULL,
+			       mode, sec_token, name);
+  }
+#else
   err = device_open_request (device_master, phys_reply, mode, name);
+#endif
   if (err)
     {
       mach_port_deallocate (mach_task_self (), phys_reply);
@@ -1154,6 +1162,15 @@
 {
   return EOPNOTSUPP;
 }
+
+#ifdef OSFMACH
+kern_return_t
+device_read_reply_overwrite (mach_port_t reply, kern_return_t returncode,
+			     io_buf_len_t amount)
+{
+  return EOPNOTSUPP;
+}
+#endif
 
 kern_return_t
 device_write_reply (mach_port_t reply, kern_return_t returncode, int amount)
Index: utils/devprobe.c
===================================================================
RCS file: /cvsroot/hurd/hurd/utils/devprobe.c,v
retrieving revision 1.9
diff -u -r1.9 devprobe.c
--- utils/devprobe.c	13 May 2002 17:34:23 -0000	1.9
+++ utils/devprobe.c	9 Aug 2003 12:04:21 -0000
@@ -55,7 +55,10 @@
       switch (key)
 	{
 	  error_t err;
-	  device_t device;  
+	  device_t device;
+#ifdef OSFMACH
+	  security_token_t sec_token = KERNEL_SECURITY_TOKEN_VALUE;
+#endif
 
 	case 's': case 'q':
 	  /* Don't print any output.  Since our exit status only reflects
@@ -74,7 +77,12 @@
 		argp_failure (state, 3, err, "Can't get device master port");
 	    }
 
+#ifdef OSFMACH
+	  err = device_open (device_master, MACH_PORT_NULL, D_READ,
+			     sec_token, arg, &device);
+#else
 	  err = device_open (device_master, D_READ, arg, &device);
+#endif  /* OSFMACH */
 	  if (err == 0)
 	    /* Got it.  */
 	    {
Index: utils/shd.c
===================================================================
RCS file: /cvsroot/hurd/hurd/utils/shd.c,v
retrieving revision 1.10
diff -u -r1.10 shd.c
--- utils/shd.c	3 May 2002 22:56:30 -0000	1.10
+++ utils/shd.c	9 Aug 2003 12:04:22 -0000
@@ -42,7 +42,9 @@
     {
       pid = waitpid (WAIT_ANY, &status, WUNTRACED | (waitfor ? 0 : WNOHANG));
 
-      if (pid == -1)
+      if (!pid)
+	return;
+      else if (pid == -1)
 	{
 	  if (errno != ECHILD && errno != EWOULDBLOCK)
 	    error (0, errno, "waitpid");
Index: utils/vminfo.c
===================================================================
RCS file: /cvsroot/hurd/hurd/utils/vminfo.c,v
retrieving revision 1.5
diff -u -r1.5 vminfo.c
--- utils/vminfo.c	13 Jun 2002 20:58:06 -0000	1.5
+++ utils/vminfo.c	9 Aug 2003 12:04:22 -0000
@@ -28,7 +28,11 @@
 
 #include <mach.h>
 #include <mach/vm_statistics.h>
+#ifdef OSFMACH
+#include <mach/default_pager_object.h>
+#else
 #include <mach/default_pager.h>
+#endif
 #include <hurd.h>
 
 const char *argp_program_version = STANDARD_HURD_VERSION (vminfo);
@@ -166,10 +170,23 @@
       vm_inherit_t inh;
       int shared;
       vm_offset_t hole_addr = addr;
-
+#ifdef OSFMACH
+      vm_region_basic_info_data_t info;
+      mach_msg_type_number_t cnt;
+
+      cnt = VM_REGION_BASIC_INFO_COUNT;
+      err = vm_region (task, &addr, &size, VM_REGION_BASIC_INFO,
+		       (vm_region_info_t) &info, &cnt, &obj);
+      prot = info.protection;
+      max_prot = info.max_protection;
+      inh = info.inheritance;
+      shared = info.shared;
+      offs = info.offset;
+#else
       err =
 	vm_region (task, &addr, &size, &prot, &max_prot, &inh, &shared,
 		   &obj, &offs);
+#endif
       if (err)
 	{
 	  if (err != EKERN_NO_SPACE)
Index: utils/vmstat.c
===================================================================
RCS file: /cvsroot/hurd/hurd/utils/vmstat.c,v
retrieving revision 1.22
diff -u -r1.22 vmstat.c
--- utils/vmstat.c	3 Aug 2003 14:19:32 -0000	1.22
+++ utils/vmstat.c	9 Aug 2003 12:04:23 -0000
@@ -29,7 +29,11 @@
 
 #include <mach.h>
 #include <mach/vm_statistics.h>
+#ifdef OSFMACH
+#include <mach/default_pager_object.h>
+#else
 #include <mach/default_pager.h>
+#endif
 #include <hurd.h>
 #include <hurd/paths.h>
 
@@ -184,6 +188,10 @@
 {
   /* General vm statistics.  */
   struct vm_statistics vmstats;
+#ifdef OSFMACH
+  /* OSF Mach doesn't have the pagesize field in struct vm_statistics.  */
+  vm_size_t pagesize;
+#endif
 
   /* default pager port (must be privileged to fetch this).  */
   mach_port_t def_pager;
@@ -193,7 +201,22 @@
 static error_t
 vm_state_refresh (struct vm_state *state)
 {
+#ifdef OSFMACH
+  /* XXX must be privileged for host_statistics () */
+  mach_msg_type_number_t cnt = HOST_VM_INFO_COUNT;
+  mach_port_t host;
+  error_t err = get_privileged_ports (&host, NULL);
+  if (!err)
+    {
+      err = host_statistics (host, HOST_VM_INFO,
+			     (host_info_t) &state->vmstats, &cnt);
+      mach_port_deallocate (mach_task_self (), host);
+    }
+  if (!err)
+    err = host_page_size (mach_host_self (), &state->pagesize);
+#else
   error_t err = vm_statistics (mach_task_self (), &state->vmstats);
+#endif
 
   if (err)
     return err;
@@ -210,17 +233,36 @@
   val_t val =
     (val_t)(*(integer_t *)((char *)&state->vmstats + field->offs));
   if (field->type == SIZE)
+#ifdef OSFMACH
+    val *= state->pagesize;
+#else
     val *= state->vmstats.pagesize;
+#endif
   return val;
 }
 
+#ifdef OSFMACH
+static val_t
+get_pagesize (struct vm_state *state, const struct field *field)
+{
+  return state->pagesize;
+}
+#endif
+
 static val_t
 get_size (struct vm_state *state, const struct field *field)
 {
+#ifdef OSFMACH
+  return
+    (state->vmstats.free_count + state->vmstats.active_count
+     + state->vmstats.inactive_count + state->vmstats.wire_count)
+    * state->pagesize;
+#else
   return
     (state->vmstats.free_count + state->vmstats.active_count
      + state->vmstats.inactive_count + state->vmstats.wire_count)
     * state->vmstats.pagesize;
+#endif
 }
 
 static val_t
@@ -304,7 +346,11 @@
 			      - state->def_pager_info.dpi_free_space))
 
 /* Returns the byte offset of the field FIELD in a vm_statistics structure. */
+#ifdef OSFMACH
+#define _F(field_name)  offsetof (struct host_paging_info, field_name)
+#else
 #define _F(field_name)  offsetof (struct vm_statistics, field_name)
+#endif
 
 #define K 1024
 #define M (1024*K)
@@ -313,8 +359,13 @@
 /* vm_statistics fields we know about.  */
 static const struct field fields[] =
 {
+#ifdef OSFMACH
+  {"pagesize",     "pgsz", "System pagesize",
+   CONST, PAGESZ, 16*K,         1, 0, get_pagesize },
+#else
   {"pagesize",	   "pgsz", "System pagesize",
    CONST, PAGESZ, 16*K,		1, _F (pagesize) },
+#endif
   {"size",	   "size", "Usable physical memory",
    CONST, SIZE,   VAL_MAX_MEM,	1, 0, get_size },
   {"free",	   "free", "Unused physical memory",
@@ -457,10 +508,17 @@
 	output_fields |= (1 << (field - fields));
 
   /* Returns an appropiate SIZE_UNITS for printing FIELD.  */
+#ifdef OSFMACH
+#define SIZE_UNITS(field)						      \
+  (size_units >= 0							      \
+   ? size_units								      \
+   : ((field)->type == PAGESZ ? 0 : state.pagesize))
+#else
 #define SIZE_UNITS(field)						      \
   (size_units >= 0							      \
    ? size_units								      \
    : ((field)->type == PAGESZ ? 0 : state.vmstats.pagesize))
+#endif
 
     /* Prints SEP if the variable FIRST is 0, otherwise, prints START (if
        it's non-zero), and sets first to 0.  */
Index: utils/w.c
===================================================================
RCS file: /cvsroot/hurd/hurd/utils/w.c,v
retrieving revision 1.30
diff -u -r1.30 w.c
--- utils/w.c	28 May 2002 23:56:34 -0000	1.30
+++ utils/w.c	9 Aug 2003 12:04:23 -0000
@@ -354,9 +354,15 @@
   if (err)
     error (3, err, "ps_context_find_proc_stat");
 
+#ifdef NO_CREATION_TIME
+  err = proc_stat_set_flags (ps, PSTAT_PROC_INFO);
+  if (!err && !(ps->flags & PSTAT_PROC_INFO))
+    err = EGRATUITOUS;
+#else
   err = proc_stat_set_flags (ps, PSTAT_TASK_BASIC);
   if (!err && !(ps->flags & PSTAT_TASK_BASIC))
     err = EGRATUITOUS;
+#endif
   if (err)
     {
       error (0, err, "cannot find boot time");
@@ -364,9 +370,13 @@
     }
   else
     {
+#ifdef NO_CREATION_TIME
+      *when = proc_stat_proc_info (ps)->creation_time;
+#else
       time_value_t *const tv = &proc_stat_task_basic_info (ps)->creation_time;
       when->tv_sec = tv->seconds;
       when->tv_usec = tv->microseconds;
+#endif
     }
 
   ps_context_free (context);

