aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2006-05-29 11:52:49 -0700
committerH. Peter Anvin <hpa@zytor.com>2006-05-29 11:52:49 -0700
commit29cfec508f796b3efc73311eb89fd60ca7002b4e (patch)
tree6bd2e92e481c00793dbf16fdcca13ad61ba1e9cd
parent7301e503e0b771d08d8fe78e4c2a88d4e70d65ae (diff)
downloadklibc-29cfec508f796b3efc73311eb89fd60ca7002b4e.tar.gz
[klibc] nfsmount: cleanup; use <inttypes.h> typesklibc-1.3.25
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>
-rw-r--r--usr/kinit/nfsmount/dummypmap.c12
-rw-r--r--usr/kinit/nfsmount/dummypmap.h6
-rw-r--r--usr/kinit/nfsmount/main.c4
-rw-r--r--usr/kinit/nfsmount/mount.c22
-rw-r--r--usr/kinit/nfsmount/nfsmount.h7
-rw-r--r--usr/kinit/nfsmount/portmap.c14
-rw-r--r--usr/kinit/nfsmount/sunrpc.c4
-rw-r--r--usr/kinit/nfsmount/sunrpc.h43
8 files changed, 61 insertions, 51 deletions
diff --git a/usr/kinit/nfsmount/dummypmap.c b/usr/kinit/nfsmount/dummypmap.c
index 17e9cfe4dea5f..a91602b590b2c 100644
--- a/usr/kinit/nfsmount/dummypmap.c
+++ b/usr/kinit/nfsmount/dummypmap.c
@@ -23,15 +23,15 @@ extern const char *progname;
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 @@ static int bind_portmap(void)
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 557be4367dec8..5ff10cfd0009d 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 b46b665999f37..4c8a3b65898d3 100644
--- a/usr/kinit/nfsmount/main.c
+++ b/usr/kinit/nfsmount/main.c
@@ -132,7 +132,7 @@ static void parse_opts(char *opts)
}
}
-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 main(int argc, char *argv[])
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 2fe766d9df419..1c6d3f3c5a898 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 @@ struct mount_call {
*/
#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 @@ static inline int pad_len(int len)
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 inline void dump_fh(const char *data, int len)
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 @@ static inline int umount_v3(const char *path, struct client *clnt)
}
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 3f1d4c7742aae..48d24c07d92f0 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 @@ enum nfs_proto {
#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 bf38356cd88f8..ccf5b363ad0f4 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 @@ static struct portmap_call call = {
}
};
-__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 e92f1ddbb04bd..915d412988988 100644
--- a/usr/kinit/nfsmount/sunrpc.c
+++ b/usr/kinit/nfsmount/sunrpc.c
@@ -139,7 +139,7 @@ static int rpc_call_udp(struct client *clnt, struct rpc *rpc)
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 @@ struct client *tcp_client(__u32 server, __u16 port, __u32 flags)
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 292140209b392..00f19cd823685 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 @@ struct client {
#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 */