Hello Samuel,

Here is a first batch of housekeeping cleanups for libdiskfs (fixing
headers, resolving compiler warnings, etc.).

I capped this batch at 20 files to keep it easy to review. I went in
alphabetical order, but deliberately skipped the files involved in the
pending v6 journaling patch so we don't cross wires or create merge
conflicts.

I'll circle back to those at the end.

Kind regards,

Milos
From 6850a970c23a8ea207022ba7abf35d5d061b9caa Mon Sep 17 00:00:00 2001
From: Milos Nikic <[email protected]>
Date: Thu, 2 Apr 2026 22:28:27 -0700
Subject: [PATCH] libdiskfs: Cleanup headers, suppress warnings, and remove
 dead code

This patch batches several housekeeping fixes across libdiskfs to
improve compatibility with modern, strict compilers.

    Replaced the monolithic "priv.h" with precise system and Mach/Hurd
    headers to resolve implicit function declarations.

    Added explicit (void) casts to fflush(), getc(), and signal() to
    suppress warn_unused_result warnings.

    Added explicit (void *) casts to ports_create_port() out-parameters
    to resolve -Wincompatible-pointer-types.

    disk-pager.c: Converted obsolete GNU-style struct initializers to
    standard C99 designated initializers.

    demuxer.c: Refactored the diskfs_demuxer routing chain to use a
    fallback cascade, eliminating bug-prone assignments within conditionals.

    file-chmod.c: Split a bug-prone assignment out of an if-condition.

    file-exec.c: Added explicit (int) casts to fix narrowing conversion
    warnings when extracting S_ISUID and S_ISGID flags.

    dead-name.c: Removed a stale #if 0 dead-code block.
---
 libdiskfs/boot-start.c      | 50 +++++++++++++++++++++++++++----------
 libdiskfs/conch-set.c       |  2 +-
 libdiskfs/console.c         | 12 ++++++---
 libdiskfs/dead-name.c       | 28 +++------------------
 libdiskfs/demuxer.c         | 43 +++++++++++++++++++------------
 libdiskfs/dir-chg.c         | 12 ++++++++-
 libdiskfs/dir-clear.c       |  7 +++++-
 libdiskfs/dir-readdir.c     | 14 ++++++++++-
 libdiskfs/direnter.c        |  4 ++-
 libdiskfs/dirremove.c       |  4 ++-
 libdiskfs/dirrewrite.c      |  4 ++-
 libdiskfs/disk-pager.c      | 23 ++++++++++++++---
 libdiskfs/file-access.c     |  8 +++++-
 libdiskfs/file-chauthor.c   |  4 ++-
 libdiskfs/file-chflags.c    |  7 ++++++
 libdiskfs/file-chg.c        | 16 ++++++++++--
 libdiskfs/file-chmod.c      | 14 ++++++++++-
 libdiskfs/file-chown.c      |  8 ++++++
 libdiskfs/file-exec.c       | 24 +++++++++++++++---
 libdiskfs/file-getcontrol.c | 13 +++++++++-
 20 files changed, 222 insertions(+), 75 deletions(-)

diff --git a/libdiskfs/boot-start.c b/libdiskfs/boot-start.c
index be47e1b8..c909f2cd 100644
--- a/libdiskfs/boot-start.c
+++ b/libdiskfs/boot-start.c
@@ -21,19 +21,43 @@
 /* Written by Michael I. Bushnell.  */
 
 #include "priv.h"
+#include <stdlib.h>
+#include <errno.h>
 #include <stdio.h>
+#include <unistd.h>
 #include <hurd.h>
 #include <hurd/fsys.h>
 #include <hurd/exec.h>
 #include <hurd/startup.h>
 #include <hurd/paths.h>
+#include <hurd/process.h>
+#include <hurd/port.h>
+#include <hurd/hurd_types.h>
+#include <hurd/fs.h>
+#include <mach.h>
+#include <mach/mig_errors.h>
+#include <mach_init.h>
+#include <mach/std_types.h>
+#include <mach/task_special_ports.h>
+#include <mach/message.h>
+#include <mach/mach_types.h>
+#include <mach/kern_return.h>
+#include <mach/mach_port.h>
+#include <mach/port.h>
+#include <mach/mach_traps.h>
+#include <mach/mach_interface.h>
+#include <sys/types.h>
+#include <sys/mman.h>
+#include <libports/ports.h>
+#include <libdiskfs/diskfs.h>
+#include <assert-backtrace.h>
+#include <pthread.h>
 #include <fcntl.h>
+#include <device/device_types.h>
 #include <device/device.h>
-#include <sys/reboot.h>
 #include <string.h>
 #include <argz.h>
 #include <error.h>
-#include "exec_S.h"
 #include "exec_startup_S.h"
 #include "fsys_S.h"
 #include "fsys_reply_U.h"
@@ -150,7 +174,7 @@ diskfs_start_bootstrap (void)
 	 	Hurd server bootstrap: bootfs[bootdev] exec ourfs
       */
       printf ("\nContinuing on new root filesystem %s:", diskfs_disk_name);
-      fflush (stdout);
+      (void) fflush (stdout);
     }
   else
     {
@@ -159,7 +183,7 @@ diskfs_start_bootstrap (void)
 
       printf ("Hurd server bootstrap: %s[%s]",
 	      program_invocation_short_name, diskfs_disk_name);
-      fflush (stdout);
+      (void) fflush (stdout);
 
       /* Get the execserver going and wait for its fsys_startup */
       pthread_mutex_init (&execstartlock, NULL);
@@ -270,7 +294,7 @@ diskfs_start_bootstrap (void)
     {
       printf ("\nCannot find startup program `%s': %s\n",
 	      initname, strerror (err));
-      fflush (stdout);
+      (void) fflush (stdout);
       free (exec_argv);
       assert_perror_backtrace (err);	/* XXX this won't reboot properly */
     }
@@ -288,7 +312,7 @@ diskfs_start_bootstrap (void)
   assert_backtrace (pathbuf[0] == '\0');
 
   err = ports_create_port (diskfs_control_class, diskfs_port_bucket,
-			   sizeof (struct port_info), &bootinfo);
+			   sizeof (struct port_info), (void*)&bootinfo);
   assert_perror_backtrace (err);
   bootpt = ports_get_send_right (bootinfo);
 
@@ -307,11 +331,11 @@ diskfs_start_bootstrap (void)
   if (_diskfs_boot_pause)
     {
       printf ("pausing for %s...\n", exec_argv);
-      fflush (stdout);
-      getc (stdin);
+      (void) fflush (stdout);
+      (void) getc (stdin);
     }
   printf (" %s", basename (exec_argv));
-  fflush (stdout);
+  (void) fflush (stdout);
   err = exec_exec (diskfs_exec, startup_pt, MACH_MSG_TYPE_COPY_SEND,
 		   newt, 0, (data_t)exec_argv, exec_argvlen, (data_t)exec_env, exec_envlen,
 		   fdarray, MACH_MSG_TYPE_COPY_SEND, 3,
@@ -684,7 +708,7 @@ start_execserver (void)
   assert_backtrace (diskfs_exec_server_task != MACH_PORT_NULL);
 
   err = ports_create_port (diskfs_execboot_class, diskfs_port_bucket,
-			   sizeof (struct port_info), &execboot_info);
+			   sizeof (struct port_info), (void *)&execboot_info);
   assert_perror_backtrace (err);
   right = ports_get_send_right (execboot_info);
   ports_port_deref (execboot_info);
@@ -696,12 +720,12 @@ start_execserver (void)
   if (_diskfs_boot_pause)
     {
       printf ("pausing for exec\n");
-      fflush (stdout);
-      getc (stdin);
+      (void) fflush (stdout);
+      (void) getc (stdin);
     }
   err = task_resume (diskfs_exec_server_task);
   assert_perror_backtrace (err);
 
   printf (" exec");
-  fflush (stdout);
+  (void) fflush (stdout);
 }
diff --git a/libdiskfs/conch-set.c b/libdiskfs/conch-set.c
index 86d3905d..47f66bfa 100644
--- a/libdiskfs/conch-set.c
+++ b/libdiskfs/conch-set.c
@@ -15,7 +15,7 @@
    along with this program; if not, write to the Free Software
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
 
-#include "priv.h"
+#include "diskfs.h"
 #include <hurd/iohelp.h>
 #include <fcntl.h>
 
diff --git a/libdiskfs/console.c b/libdiskfs/console.c
index 9bf7cd2d..1859689c 100644
--- a/libdiskfs/console.c
+++ b/libdiskfs/console.c
@@ -19,7 +19,6 @@
    along with this program; if not, write to the Free Software
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
 
-#include <stdlib.h>
 #include <stdio.h>
 #include <unistd.h>
 #include <fcntl.h>
@@ -28,11 +27,18 @@
 #include <signal.h>
 #include <assert-backtrace.h>
 
+#include <mach_init.h>
+#include <mach-shortcuts.h>
+#include <mach.h>
 #include <mach/mach.h>
+#include <mach/mach_traps.h>
+#include <mach/port.h>
 #include <device/device.h>
+#include <device/device_types.h>
 #include <hurd.h>
 
 #include "priv.h"
+#include "diskfs.h"
 
 /* Make sure errors go somewhere reasonable.  */
 void
@@ -80,6 +86,6 @@ diskfs_console_stdio (void)
     }
 
   /* And make sure we don't die just because we got some error there.  */
-  signal (SIGPIPE, SIG_IGN);
-  signal (SIGLOST, SIG_IGN);
+  (void) signal (SIGPIPE, SIG_IGN);
+  (void) signal (SIGLOST, SIG_IGN);
 }
diff --git a/libdiskfs/dead-name.c b/libdiskfs/dead-name.c
index 5e0cf787..2cb2624d 100644
--- a/libdiskfs/dead-name.c
+++ b/libdiskfs/dead-name.c
@@ -18,34 +18,14 @@
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA. */
 
-#include "priv.h"
+#include <mach/port.h>
+#include <mach/notify.h>
+#include <libfshelp/fshelp.h>
+#include <libports/ports.h>
 
 void
 ports_dead_name (void *notify, mach_port_t dead_name)
 {
-#if 0
-  /* FIXME: This makes no sense, the dead name could be np->sockaddr, but not
-     the protid; it's pointless to look it up this way.  It also leaks a
-     reference.  */
-  struct protid *pi = ports_lookup_port (diskfs_port_bucket, dead_name,
-					 diskfs_protid_class);
-  struct node *np;
-
-  if (pi)
-    {
-      np = pi->po->np;
-      pthread_mutex_lock (&np->lock);
-      if (dead_name == np->sockaddr)
-	{
-	  mach_port_deallocate (mach_task_self (), np->sockaddr);
-	  np->sockaddr = MACH_PORT_NULL;
-	  diskfs_nput (np);
-	}
-      else
-	pthread_mutex_unlock (&np->lock);
-    }
-#endif
-
   fshelp_remove_active_translator (dead_name);
 
   ports_interrupt_notified_rpcs (notify, dead_name, MACH_NOTIFY_DEAD_NAME);
diff --git a/libdiskfs/demuxer.c b/libdiskfs/demuxer.c
index 4a1c4fb4..ce4f9d40 100644
--- a/libdiskfs/demuxer.c
+++ b/libdiskfs/demuxer.c
@@ -15,35 +15,46 @@
    along with this program; if not, write to the Free Software
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
 
-#include "priv.h"
 
+#include "diskfs.h"
 #include "io_S.h"
 #include "fs_S.h"
-#include "../libports/notify_S.h"
+#include <libports/notify_S.h>
 #include "fsys_S.h"
-#include "../libports/interrupt_S.h"
+#include <libports/interrupt_S.h>
 #include "ifsock_S.h"
 #include "startup_notify_S.h"
 #include "exec_startup_S.h"
+#include <mach/message.h>
+#include <mach/mig_errors.h>
+#include <mach/boolean.h>
 
 int
 diskfs_demuxer (mach_msg_header_t *inp,
-		mach_msg_header_t *outp)
+                mach_msg_header_t *outp)
 {
-  mig_routine_t routine;
-  if ((routine = diskfs_io_server_routine (inp)) ||
-      (routine = diskfs_fs_server_routine (inp)) ||
-      (routine = ports_notify_server_routine (inp)) ||
-      (routine = diskfs_fsys_server_routine (inp)) ||
-      (routine = ports_interrupt_server_routine (inp)) ||
-      (diskfs_shortcut_ifsock ?
-       (routine = diskfs_ifsock_server_routine (inp)) : 0) ||
-      (routine = diskfs_startup_notify_server_routine (inp)) ||
-      (routine = diskfs_exec_startup_server_routine (inp)))
+  mig_routine_t routine = diskfs_io_server_routine (inp);
+
+  if (!routine)
+    routine = diskfs_fs_server_routine (inp);
+  if (!routine)
+    routine = ports_notify_server_routine (inp);
+  if (!routine)
+    routine = diskfs_fsys_server_routine (inp);
+  if (!routine)
+    routine = ports_interrupt_server_routine (inp);
+  if (!routine && diskfs_shortcut_ifsock)
+    routine = diskfs_ifsock_server_routine (inp);
+  if (!routine)
+    routine = diskfs_startup_notify_server_routine (inp);
+  if (!routine)
+    routine = diskfs_exec_startup_server_routine (inp);
+
+  if (routine)
     {
       (*routine) (inp, outp);
       return TRUE;
     }
-  else
-    return FALSE;
+
+  return FALSE;
 }
diff --git a/libdiskfs/dir-chg.c b/libdiskfs/dir-chg.c
index 0657c45b..24c1d0ce 100644
--- a/libdiskfs/dir-chg.c
+++ b/libdiskfs/dir-chg.c
@@ -15,7 +15,17 @@
    along with this program; if not, write to the Free Software
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
 
-#include "priv.h"
+#include <errno.h>
+#include <stdlib.h>
+#include <pthread.h>
+
+#include "diskfs.h"
+#include <sys/stat.h>
+#include <hurd/hurd_types.h>
+#include <mach_init.h>
+#include <mach/port.h>
+#include <mach-shortcuts.h>
+#include <mach/message.h>
 #include "fs_S.h"
 #include "fs_notify_U.h"
 
diff --git a/libdiskfs/dir-clear.c b/libdiskfs/dir-clear.c
index 02a800ed..bad4bc5d 100644
--- a/libdiskfs/dir-clear.c
+++ b/libdiskfs/dir-clear.c
@@ -15,7 +15,12 @@
    along with this program; if not, write to the Free Software
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
 
-#include "priv.h"
+#include <errno.h>
+
+#include "diskfs.h"
+#include <alloca.h>
+#include <assert-backtrace.h>
+#include <hurd/hurd_types.h>
 
 /* Clear the `.' and `..' entries from directory DP.  Its parent is PDP,
    and the user responsible for this is identified by CRED.  Both 
diff --git a/libdiskfs/dir-readdir.c b/libdiskfs/dir-readdir.c
index a314e9d1..4fdbf8df 100644
--- a/libdiskfs/dir-readdir.c
+++ b/libdiskfs/dir-readdir.c
@@ -19,8 +19,20 @@
 
 /* Written by Michael I. Bushnell.  */
 
+#include <errno.h>
+#include <pthread.h>
 #include <fcntl.h>
-#include "priv.h"
+
+#include "diskfs.h"
+#include <idvec.h>
+#include <mach/machine/boolean.h>
+#include <mach/machine/kern_return.h>
+#include <mach/machine/vm_types.h>
+#include <hurd/hurd_types.h>
+#include <sys/stat.h>
+#include <mach-shortcuts.h>
+#include <mach/message.h>
+#include <assert-backtrace.h>
 #include "fs_S.h"
 
 kern_return_t
diff --git a/libdiskfs/direnter.c b/libdiskfs/direnter.c
index cb9b76ca..7e9a0876 100644
--- a/libdiskfs/direnter.c
+++ b/libdiskfs/direnter.c
@@ -19,7 +19,9 @@
    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA. */
 
 
-#include "priv.h"
+#include "diskfs.h"
+#include <bits/types/error_t.h>
+#include <hurd/hurd_types.h>
 
 /* Add NP to directory DP under the name NAME.  This will only be
    called after an unsuccessful call to diskfs_lookup of type CREATE
diff --git a/libdiskfs/dirremove.c b/libdiskfs/dirremove.c
index 239daa72..667f036d 100644
--- a/libdiskfs/dirremove.c
+++ b/libdiskfs/dirremove.c
@@ -18,7 +18,9 @@
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA. */
 
-#include "priv.h"
+#include "diskfs.h"
+#include <bits/types/error_t.h>
+#include <hurd/hurd_types.h>
 
 /* This will only be called after a successful call to diskfs_lookup
    of type REMOVE; this call should remove the name found from the
diff --git a/libdiskfs/dirrewrite.c b/libdiskfs/dirrewrite.c
index 8f713960..44a50c6e 100644
--- a/libdiskfs/dirrewrite.c
+++ b/libdiskfs/dirrewrite.c
@@ -19,7 +19,9 @@
    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA. */
 
 
-#include "priv.h"
+#include "diskfs.h"
+#include <bits/types/error_t.h>
+#include <hurd/hurd_types.h>
 
 /* This will only be called after a successful call to diskfs_lookup
    of type RENAME; this call should change the name found in directory
diff --git a/libdiskfs/disk-pager.c b/libdiskfs/disk-pager.c
index 886ce157..ca8e7522 100644
--- a/libdiskfs/disk-pager.c
+++ b/libdiskfs/disk-pager.c
@@ -16,8 +16,25 @@
    along with this program; if not, write to the Free Software
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
 
-#include "priv.h"
+#include <errno.h>
+#include <signal.h>
+#include <stddef.h>
+#include <setjmp.h>
+
 #include "diskfs-pager.h"
+#include "diskfs.h"
+#include <idvec.h>
+#include <libports/ports.h>
+#include <libpager/pager.h>
+#include <mach-shortcuts.h>
+#include <mach/message.h>
+#include <mach/port.h>
+#include <mach_init.h>
+#include <mach/memory_object.h>
+#include <mach/std_types.h>
+#include <mach/vm_prot.h>
+#include <mach/vm_inherit.h>
+#include <assert-backtrace.h>
 #include <hurd/sigpreempt.h>
 #include <error.h>
 
@@ -29,8 +46,8 @@ struct pager_requests *diskfs_disk_pager_requests;
 static void fault_handler (int sig, long int sigcode, struct sigcontext *scp);
 static struct hurd_signal_preemptor preemptor =
   {
-  preemptor: NULL,
-  handler: (sighandler_t) &fault_handler,
+  .preemptor =  NULL,
+  .handler =  (sighandler_t) &fault_handler,
   };
 
 void
diff --git a/libdiskfs/file-access.c b/libdiskfs/file-access.c
index f7e129aa..11823d66 100644
--- a/libdiskfs/file-access.c
+++ b/libdiskfs/file-access.c
@@ -15,9 +15,15 @@
    along with this program; if not, write to the Free Software
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
 
-#include "priv.h"
 #include "fs_S.h"
 #include <fcntl.h>
+#include <errno.h>
+#include <pthread.h>
+
+#include <libfshelp/fshelp.h>
+#include <mach/machine/kern_return.h>
+#include <sys/stat.h>
+#include "diskfs.h"
 
 kern_return_t
 diskfs_S_file_check_access (struct protid *cred,
diff --git a/libdiskfs/file-chauthor.c b/libdiskfs/file-chauthor.c
index 6e49c53f..f4c4283c 100644
--- a/libdiskfs/file-chauthor.c
+++ b/libdiskfs/file-chauthor.c
@@ -18,7 +18,9 @@
 #include "lithp.h"
 
 #include "priv.h"
-#include fth_TH_dot_h
+#include "diskfs.h"
+#include <hurd/hurd_types.h>
+#include <sys/types.h>
 
 /* Implement file_chauthor as dethcribed in <hurd/fth.defth>. */
 kern_return_t
diff --git a/libdiskfs/file-chflags.c b/libdiskfs/file-chflags.c
index a29ff07c..f05e6a3f 100644
--- a/libdiskfs/file-chflags.c
+++ b/libdiskfs/file-chflags.c
@@ -15,8 +15,15 @@
    along with this program; if not, write to the Free Software
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
 
+#include <errno.h>
+#include <idvec.h>
+
 #include "priv.h"
 #include "fs_S.h"
+#include "diskfs.h"
+#include <libfshelp/fshelp.h>
+#include <hurd/hurd_types.h>
+#include <mach/machine/kern_return.h>
 
 /* Implement file_chflags as described in <hurd/fs.defs>. */
 kern_return_t
diff --git a/libdiskfs/file-chg.c b/libdiskfs/file-chg.c
index 9da43e79..cdca88d6 100644
--- a/libdiskfs/file-chg.c
+++ b/libdiskfs/file-chg.c
@@ -15,8 +15,20 @@
    along with this program; if not, write to the Free Software
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
 
-#include "priv.h"
-#include "fs_notify_S.h"
+#include "fs_S.h"
+#include <stdlib.h>
+#include <errno.h>
+#include <pthread.h>
+
+#include "diskfs.h"
+#include <idvec.h>
+#include <hurd/hurd_types.h>
+#include <sys/types.h>
+#include <mach_init.h>
+#include <mach/port.h>
+#include <mach/message.h>
+#include <mach/machine/kern_return.h>
+#include <mach-shortcuts.h>
 #include "fs_notify_U.h"
 
 kern_return_t
diff --git a/libdiskfs/file-chmod.c b/libdiskfs/file-chmod.c
index 13f2cb93..ab63ff2f 100644
--- a/libdiskfs/file-chmod.c
+++ b/libdiskfs/file-chmod.c
@@ -15,8 +15,19 @@
    along with this program; if not, write to the Free Software
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
 
+#include <fcntl.h>
+#include <sys/stat.h>
+#include <idvec.h>
+
 #include "priv.h"
 #include "fs_S.h"
+#include "diskfs.h"
+#include <idvec.h>
+#include <hurd/hurd_types.h>
+#include <sys/types.h>
+#include <libfshelp/fshelp.h>
+#include <mach/machine/kern_return.h>
+#include <mach-shortcuts.h>
 
 /* Implement file_chmod as described in <hurd/fs.defs>. */
 kern_return_t
@@ -27,7 +38,8 @@ diskfs_S_file_chmod (struct protid *cred,
 
   CHANGE_NODE_FIELD (cred,
 		     ({
-		       if (!(err = fshelp_isowner (&np->dn_stat, cred->user)))
+		       err = fshelp_isowner (&np->dn_stat, cred->user);
+		       if (!(err))
 			 {
 			   if (!idvec_contains (cred->user->uids, 0))
 			     {
diff --git a/libdiskfs/file-chown.c b/libdiskfs/file-chown.c
index ecb851f2..e9a50ed7 100644
--- a/libdiskfs/file-chown.c
+++ b/libdiskfs/file-chown.c
@@ -15,8 +15,16 @@
    along with this program; if not, write to the Free Software
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
 
+#include <idvec.h>
+#include <errno.h>
+
 #include "priv.h"
 #include "fs_S.h"
+#include "diskfs.h"
+#include <hurd/hurd_types.h>
+#include <sys/types.h>
+#include <libfshelp/fshelp.h>
+
 
 /* Implement file_chown as described in <hurd/fs.defs>. */
 kern_return_t
diff --git a/libdiskfs/file-exec.c b/libdiskfs/file-exec.c
index 254e52ad..f1decf60 100644
--- a/libdiskfs/file-exec.c
+++ b/libdiskfs/file-exec.c
@@ -22,11 +22,29 @@
 
 #include "priv.h"
 #include "fs_S.h"
+#include <pthread.h>
+
 #include <sys/stat.h>
 #include <fcntl.h>
+#include <hurd.h>
 #include <hurd/exec.h>
 #include <hurd/paths.h>
-#include <string.h>
+#include <hurd/port.h>
+#include <hurd/hurd_types.h>
+#include <hurd/userlink.h>
+#include <idvec.h>
+#include <errno.h>
+#include "diskfs.h"
+#include <sys/types.h>
+#include <mach/port.h>
+#include <mach_init.h>
+#include <mach-shortcuts.h>
+#include <mach/mach_types.h>
+#include <mach/message.h>
+#include <mach/mig_errors.h>
+#include <mach/machine/kern_return.h>
+#include <libports/ports.h>
+#include <libfshelp/fshelp.h>
 #include <idvec.h>
 
 kern_return_t
@@ -140,8 +158,8 @@ diskfs_S_file_exec_paths (struct protid *cred,
   if ((mode & S_IFMT) == S_IFDIR)
     RETURN (EACCES);
 
-  suid = mode & S_ISUID;
-  sgid = mode & S_ISGID;
+  suid = (int)(mode & S_ISUID);
+  sgid = (int)(mode & S_ISGID);
   if (!_diskfs_nosuid && (suid || sgid))
     {
       int secure = 0;
diff --git a/libdiskfs/file-getcontrol.c b/libdiskfs/file-getcontrol.c
index 8f98f4b3..74936771 100644
--- a/libdiskfs/file-getcontrol.c
+++ b/libdiskfs/file-getcontrol.c
@@ -18,6 +18,17 @@
 #include "priv.h"
 #include "fs_S.h"
 #include <hurd/fshelp.h>
+#include <pthread.h>
+#include <idvec.h>
+#include <errno.h>
+
+#include "diskfs.h"
+#include <mach/port.h>
+#include <mach-shortcuts.h>
+#include <mach/message.h>
+#include <mach/machine/kern_return.h>
+#include <libports/ports.h>
+#include <libfshelp/fshelp.h>
 
 /* Implement file_getcontrol as described in <hurd/fs.defs>. */
 kern_return_t
@@ -36,7 +47,7 @@ diskfs_S_file_getcontrol (struct protid *cred,
     return err;
 
   err = ports_create_port (diskfs_control_class, diskfs_port_bucket,
-			     sizeof (struct port_info), &newpi);
+			     sizeof (struct port_info), (void*)&newpi);
   if (err)
     return err;
 
-- 
2.53.0

Reply via email to