[klibc] nfsmount: cleanup; use <inttypes.h> types

Using double-underscore types for pure userspace is silly, and encourages
including <linux/types.h> which is unsafe.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
diff --git a/usr/kinit/nfsmount/dummypmap.c b/usr/kinit/nfsmount/dummypmap.c
index 17e9cfe..a91602b 100644
--- a/usr/kinit/nfsmount/dummypmap.c
+++ b/usr/kinit/nfsmount/dummypmap.c
@@ -23,15 +23,15 @@
 
 struct portmap_call {
 	struct rpc_call rpc;
-	__u32 program;
-	__u32 version;
-	__u32 proto;
-	__u32 port;
+	uint32_t program;
+	uint32_t version;
+	uint32_t proto;
+	uint32_t port;
 };
 
 struct portmap_reply {
 	struct rpc_reply rpc;
-	__u32 port;
+	uint32_t port;
 };
 
 static int bind_portmap(void)
@@ -56,7 +56,7 @@
 	return sock;
 }
 
-static const char *protoname(__u32 proto)
+static const char *protoname(uint32_t proto)
 {
 	switch (ntohl(proto)) {
 	case IPPROTO_TCP:
diff --git a/usr/kinit/nfsmount/dummypmap.h b/usr/kinit/nfsmount/dummypmap.h
index 557be43..5ff10cf 100644
--- a/usr/kinit/nfsmount/dummypmap.h
+++ b/usr/kinit/nfsmount/dummypmap.h
@@ -4,10 +4,10 @@
  * Functions for the portmap spoofer
  */
 
-#ifndef KINIT_DUMMYPORTMAP_H
-#define KINIT_DUMMYPORTMAP_H
+#ifndef NFSMOUNT_DUMMYPORTMAP_H
+#define NFSMOUNT_DUMMYPORTMAP_H
 
 #include <unistd.h>
 pid_t start_dummy_portmap(const char *file);
 
-#endif				/* KINIT_DUMMYPORTMAP_H */
+#endif /* NFSMOUNT_DUMMYPORTMAP_H */
diff --git a/usr/kinit/nfsmount/main.c b/usr/kinit/nfsmount/main.c
index b46b665..4c8a3b6 100644
--- a/usr/kinit/nfsmount/main.c
+++ b/usr/kinit/nfsmount/main.c
@@ -132,7 +132,7 @@
 	}
 }
 
-static __u32 parse_addr(const char *ip)
+static uint32_t parse_addr(const char *ip)
 {
 	struct in_addr in;
 	if (inet_aton(ip, &in) == 0) {
@@ -161,7 +161,7 @@
 
 int nfsmount_main(int argc, char *argv[])
 {
-	__u32 server;
+	uint32_t server;
 	char *rem_name;
 	char *rem_path;
 	char *hostname;
diff --git a/usr/kinit/nfsmount/mount.c b/usr/kinit/nfsmount/mount.c
index 2fe766d..1c6d3f3 100644
--- a/usr/kinit/nfsmount/mount.c
+++ b/usr/kinit/nfsmount/mount.c
@@ -11,11 +11,11 @@
 #include "nfsmount.h"
 #include "sunrpc.h"
 
-static __u32 mount_port;
+static uint32_t mount_port;
 
 struct mount_call {
 	struct rpc_call rpc;
-	__u32 path_len;
+	uint32_t path_len;
 	char path[0];
 };
 
@@ -31,22 +31,22 @@
  */
 #define NFS_MAXFHSIZE_WIRE 64
 struct nfs_fh_wire {
-	__u32 size;
+	uint32_t size;
 	char data[NFS_MAXFHSIZE_WIRE];
 } __attribute__ ((packed));
 
 struct mount_reply {
 	struct rpc_reply reply;
-	__u32 status;
+	uint32_t status;
 	struct nfs_fh_wire fh;
 } __attribute__ ((packed));
 
-#define MNT_REPLY_MINSIZE (sizeof(struct rpc_reply) + sizeof(__u32))
+#define MNT_REPLY_MINSIZE (sizeof(struct rpc_reply) + sizeof(uint32_t))
 
-static int get_ports(__u32 server, const struct nfs_mount_data *data)
+static int get_ports(uint32_t server, const struct nfs_mount_data *data)
 {
-	__u32 nfs_ver, mount_ver;
-	__u32 proto;
+	uint32_t nfs_ver, mount_ver;
+	uint32_t proto;
 
 	if (data->flags & NFS_MOUNT_VER3) {
 		nfs_ver = NFS3_VERSION;
@@ -84,7 +84,7 @@
 	return (len + 3) & ~3;
 }
 
-static inline void dump_params(__u32 server,
+static inline void dump_params(uint32_t server,
 			       const char *path,
 			       const struct nfs_mount_data *data)
 {
@@ -143,7 +143,7 @@
 
 static struct mount_reply mnt_reply;
 
-static int mount_call(__u32 proc, __u32 version,
+static int mount_call(uint32_t proc, uint32_t version,
 		      const char *path, struct client *clnt)
 {
 	struct mount_call *mnt_call = NULL;
@@ -251,7 +251,7 @@
 }
 
 int nfs_mount(const char *pathname, const char *hostname,
-	      __u32 server, const char *rem_path, const char *path,
+	      uint32_t server, const char *rem_path, const char *path,
 	      struct nfs_mount_data *data)
 {
 	struct client *clnt = NULL;
diff --git a/usr/kinit/nfsmount/nfsmount.h b/usr/kinit/nfsmount/nfsmount.h
index 3f1d4c7..48d24c0 100644
--- a/usr/kinit/nfsmount/nfsmount.h
+++ b/usr/kinit/nfsmount/nfsmount.h
@@ -2,13 +2,16 @@
  * nfsmount/nfsmount.h
  */
 
+#ifndef NFSMOUNT_NFSMOUNT_H
+#define NFSMOUNT_NFSMOUNT_H
+
 #include <linux/nfs_mount.h>
 
 extern int nfs_port;
 
 extern int nfsmount_main(int argc, char *argv[]);
 int nfs_mount(const char *rem_name, const char *hostname,
-	      __u32 server, const char *rem_path,
+	      uint32_t server, const char *rem_path,
 	      const char *path, struct nfs_mount_data *data);
 
 enum nfs_proto {
@@ -32,3 +35,5 @@
 #else
 #define DEBUG(x) do { } while(0)
 #endif
+
+#endif /* NFSMOUNT_NFSMOUNT_H */
diff --git a/usr/kinit/nfsmount/portmap.c b/usr/kinit/nfsmount/portmap.c
index bf38356..ccf5b36 100644
--- a/usr/kinit/nfsmount/portmap.c
+++ b/usr/kinit/nfsmount/portmap.c
@@ -9,15 +9,15 @@
 
 struct portmap_call {
 	struct rpc_call rpc;
-	__u32 program;
-	__u32 version;
-	__u32 proto;
-	__u32 port;
+	uint32_t program;
+	uint32_t version;
+	uint32_t proto;
+	uint32_t port;
 };
 
 struct portmap_reply {
 	struct rpc_reply rpc;
-	__u32 port;
+	uint32_t port;
 };
 
 static struct portmap_call call = {
@@ -28,12 +28,12 @@
 	}
 };
 
-__u32 portmap(__u32 server, __u32 program, __u32 version, __u32 proto)
+uint32_t portmap(uint32_t server, uint32_t program, uint32_t version, uint32_t proto)
 {
 	struct portmap_reply reply;
 	struct client *clnt;
 	struct rpc rpc;
-	__u32 port = 0;
+	uint32_t port = 0;
 
 	if ((clnt = tcp_client(server, RPC_PMAP_PORT, 0)) == NULL) {
 		if ((clnt = udp_client(server, RPC_PMAP_PORT, 0)) == NULL) {
diff --git a/usr/kinit/nfsmount/sunrpc.c b/usr/kinit/nfsmount/sunrpc.c
index e92f1dd..915d412 100644
--- a/usr/kinit/nfsmount/sunrpc.c
+++ b/usr/kinit/nfsmount/sunrpc.c
@@ -139,7 +139,7 @@
 	return ret;
 }
 
-struct client *tcp_client(__u32 server, __u16 port, __u32 flags)
+struct client *tcp_client(uint32_t server, uint16_t port, uint32_t flags)
 {
 	struct client *clnt = malloc(sizeof(*clnt));
 	struct sockaddr_in addr;
@@ -184,7 +184,7 @@
 	return clnt;
 }
 
-struct client *udp_client(__u32 server, __u16 port, __u32 flags)
+struct client *udp_client(uint32_t server, uint16_t port, uint32_t flags)
 {
 	struct client *clnt = malloc(sizeof(*clnt));
 	struct sockaddr_in addr;
diff --git a/usr/kinit/nfsmount/sunrpc.h b/usr/kinit/nfsmount/sunrpc.h
index 2921402..00f19cd 100644
--- a/usr/kinit/nfsmount/sunrpc.h
+++ b/usr/kinit/nfsmount/sunrpc.h
@@ -1,8 +1,11 @@
 /*
  * sunrpc.h - open-coded SunRPC structures
  */
+#ifndef NFSMOUNT_SUNRPC_H
+#define NFSMOUNT_SUNRPC_H
+
 #include <sys/types.h>
-#include <linux/types.h>	/* for __u32 */
+#include <inttypes.h>
 
 #define SUNRPC_PORT	111
 #define MOUNT_PORT	627
@@ -36,35 +39,35 @@
 #define SYSTEM_ERR	5
 
 struct rpc_udp_header {
-	__u32 xid;
-	__u32 msg_type;
+	uint32_t xid;
+	uint32_t msg_type;
 };
 
 struct rpc_header {
-	__u32 frag_hdr;
+	uint32_t frag_hdr;
 	struct rpc_udp_header udp;
 };
 
 struct rpc_call {
 	struct rpc_header hdr;
-	__u32 rpc_vers;
+	uint32_t rpc_vers;
 
-	__u32 program;
-	__u32 prog_vers;
-	__u32 proc;
-	__u32 cred_flavor;
+	uint32_t program;
+	uint32_t prog_vers;
+	uint32_t proc;
+	uint32_t cred_flavor;
 
-	__u32 cred_len;
-	__u32 vrf_flavor;
-	__u32 vrf_len;
+	uint32_t cred_len;
+	uint32_t vrf_flavor;
+	uint32_t vrf_len;
 };
 
 struct rpc_reply {
 	struct rpc_header hdr;
-	__u32 reply_state;
-	__u32 vrf_flavor;
-	__u32 vrf_len;
-	__u32 state;
+	uint32_t reply_state;
+	uint32_t vrf_flavor;
+	uint32_t vrf_len;
+	uint32_t state;
 };
 
 struct rpc {
@@ -85,10 +88,12 @@
 
 #define CLI_RESVPORT	00000001
 
-struct client *tcp_client(__u32 server, __u16 port, __u32 flags);
-struct client *udp_client(__u32 server, __u16 port, __u32 flags);
+struct client *tcp_client(uint32_t server, uint16_t port, uint32_t flags);
+struct client *udp_client(uint32_t server, uint16_t port, uint32_t flags);
 void client_free(struct client *client);
 
 int rpc_call(struct client *client, struct rpc *rpc);
 
-__u32 portmap(__u32 server, __u32 program, __u32 version, __u32 proto);
+uint32_t portmap(uint32_t server, uint32_t program, uint32_t version, uint32_t proto);
+
+#endif /* NFSMOUNT_SUNRPC_H */