projects
/
oweals
/
u-boot.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
aspeed: Add support for Clocks needed by MACs
[oweals/u-boot.git]
/
net
/
nfs.c
diff --git
a/net/nfs.c
b/net/nfs.c
index 08bdd92d8020d92b511fffec7081c4030233f1d8..83ed0a7c37c9af87b918f15e018853d70fb63d17 100644
(file)
--- a/
net/nfs.c
+++ b/
net/nfs.c
@@
-142,13
+142,6
@@
RPC_ADD_CREDENTIALS - Add RPC authentication/verifier entries
**************************************************************************/
static uint32_t *rpc_add_credentials(uint32_t *p)
{
**************************************************************************/
static uint32_t *rpc_add_credentials(uint32_t *p)
{
- int hl;
- int hostnamelen;
- char hostname[256];
-
- strcpy(hostname, "");
- hostnamelen = strlen(hostname);
-
/* Here's the executive summary on authentication requirements of the
* various NFS server implementations: Linux accepts both AUTH_NONE
* and AUTH_UNIX authentication (also accepts an empty hostname field
/* Here's the executive summary on authentication requirements of the
* various NFS server implementations: Linux accepts both AUTH_NONE
* and AUTH_UNIX authentication (also accepts an empty hostname field
@@
-158,17
+151,11
@@
static uint32_t *rpc_add_credentials(uint32_t *p)
* it (if the BOOTP/DHCP reply didn't give one, just use an empty
* hostname). */
* it (if the BOOTP/DHCP reply didn't give one, just use an empty
* hostname). */
- hl = (hostnamelen + 3) & ~3;
-
/* Provide an AUTH_UNIX credential. */
*p++ = htonl(1); /* AUTH_UNIX */
/* Provide an AUTH_UNIX credential. */
*p++ = htonl(1); /* AUTH_UNIX */
- *p++ = htonl(hl+20); /* auth length */
- *p++ = htonl(0); /* stamp */
- *p++ = htonl(hostnamelen); /* hostname string */
- if (hostnamelen & 3)
- *(p + hostnamelen / 4) = 0; /* add zero padding */
- memcpy(p, hostname, hostnamelen);
- p += hl / 4;
+ *p++ = htonl(20); /* auth length */
+ *p++ = 0; /* stamp */
+ *p++ = 0; /* hostname string */
*p++ = 0; /* uid */
*p++ = 0; /* gid */
*p++ = 0; /* auxiliary gid list */
*p++ = 0; /* uid */
*p++ = 0; /* gid */
*p++ = 0; /* auxiliary gid list */
@@
-185,39
+172,39
@@
RPC_LOOKUP - Lookup RPC Port numbers
**************************************************************************/
static void rpc_req(int rpc_prog, int rpc_proc, uint32_t *data, int datalen)
{
**************************************************************************/
static void rpc_req(int rpc_prog, int rpc_proc, uint32_t *data, int datalen)
{
- struct rpc_t pkt;
+ struct rpc_t
rpc_
pkt;
unsigned long id;
uint32_t *p;
int pktlen;
int sport;
id = ++rpc_id;
unsigned long id;
uint32_t *p;
int pktlen;
int sport;
id = ++rpc_id;
- pkt.u.call.id = htonl(id);
- pkt.u.call.type = htonl(MSG_CALL);
-
pkt.u.call.rpcvers = htonl(2);
/* use RPC version 2 */
- pkt.u.call.prog = htonl(rpc_prog);
+
rpc_
pkt.u.call.id = htonl(id);
+
rpc_
pkt.u.call.type = htonl(MSG_CALL);
+
rpc_pkt.u.call.rpcvers = htonl(2);
/* use RPC version 2 */
+
rpc_
pkt.u.call.prog = htonl(rpc_prog);
switch (rpc_prog) {
case PROG_NFS:
if (supported_nfs_versions & NFSV2_FLAG)
switch (rpc_prog) {
case PROG_NFS:
if (supported_nfs_versions & NFSV2_FLAG)
-
pkt.u.call.vers = htonl(2);
/* NFS v2 */
+
rpc_pkt.u.call.vers = htonl(2);
/* NFS v2 */
else /* NFSV3_FLAG */
else /* NFSV3_FLAG */
-
pkt.u.call.vers = htonl(3);
/* NFS v3 */
+
rpc_pkt.u.call.vers = htonl(3);
/* NFS v3 */
break;
case PROG_PORTMAP:
case PROG_MOUNT:
default:
break;
case PROG_PORTMAP:
case PROG_MOUNT:
default:
-
pkt.u.call.vers = htonl(2);
/* portmapper is version 2 */
+
rpc_pkt.u.call.vers = htonl(2);
/* portmapper is version 2 */
}
}
- pkt.u.call.proc = htonl(rpc_proc);
- p = (uint32_t *)&(pkt.u.call.data);
+
rpc_
pkt.u.call.proc = htonl(rpc_proc);
+ p = (uint32_t *)&(
rpc_
pkt.u.call.data);
if (datalen)
memcpy((char *)p, (char *)data, datalen*sizeof(uint32_t));
if (datalen)
memcpy((char *)p, (char *)data, datalen*sizeof(uint32_t));
- pktlen = (char *)p + datalen
*sizeof(uint32_t) - (char *)&
pkt;
+ pktlen = (char *)p + datalen
* sizeof(uint32_t) - (char *)&rpc_
pkt;
memcpy((char *)net_tx_packet + net_eth_hdr_size() + IP_UDP_HDR_SIZE,
memcpy((char *)net_tx_packet + net_eth_hdr_size() + IP_UDP_HDR_SIZE,
-
(char *)&pkt
, pktlen);
+
&rpc_pkt.u.data[0]
, pktlen);
if (rpc_prog == PROG_PORTMAP)
sport = SUNRPC_PORT;
if (rpc_prog == PROG_PORTMAP)
sport = SUNRPC_PORT;
@@
-445,7
+432,7
@@
static int rpc_lookup_reply(int prog, uchar *pkt, unsigned len)
{
struct rpc_t rpc_pkt;
{
struct rpc_t rpc_pkt;
- memcpy(
(unsigned char *)&rpc_pkt
, pkt, len);
+ memcpy(
&rpc_pkt.u.data[0]
, pkt, len);
debug("%s\n", __func__);
debug("%s\n", __func__);
@@
-477,7
+464,7
@@
static int nfs_mount_reply(uchar *pkt, unsigned len)
debug("%s\n", __func__);
debug("%s\n", __func__);
- memcpy(
(unsigned char *)&rpc_pkt
, pkt, len);
+ memcpy(
&rpc_pkt.u.data[0]
, pkt, len);
if (ntohl(rpc_pkt.u.reply.id) > rpc_id)
return -NFS_RPC_ERR;
if (ntohl(rpc_pkt.u.reply.id) > rpc_id)
return -NFS_RPC_ERR;
@@
-503,7
+490,7
@@
static int nfs_umountall_reply(uchar *pkt, unsigned len)
debug("%s\n", __func__);
debug("%s\n", __func__);
- memcpy(
(unsigned char *)&rpc_pkt
, pkt, len);
+ memcpy(
&rpc_pkt.u.data[0]
, pkt, len);
if (ntohl(rpc_pkt.u.reply.id) > rpc_id)
return -NFS_RPC_ERR;
if (ntohl(rpc_pkt.u.reply.id) > rpc_id)
return -NFS_RPC_ERR;
@@
-527,7
+514,7
@@
static int nfs_lookup_reply(uchar *pkt, unsigned len)
debug("%s\n", __func__);
debug("%s\n", __func__);
- memcpy(
(unsigned char *)&rpc_pkt
, pkt, len);
+ memcpy(
&rpc_pkt.u.data[0]
, pkt, len);
if (ntohl(rpc_pkt.u.reply.id) > rpc_id)
return -NFS_RPC_ERR;
if (ntohl(rpc_pkt.u.reply.id) > rpc_id)
return -NFS_RPC_ERR;
@@
-557,11
+544,13
@@
static int nfs_lookup_reply(uchar *pkt, unsigned len)
return -NFS_RPC_PROG_MISMATCH;
case 4:
default:
return -NFS_RPC_PROG_MISMATCH;
case 4:
default:
- printf("*** ERROR: NFS version not supported: Requested: V%d, accepted: min V%d - max V%d\n",
- (supported_nfs_versions & NFSV2_FLAG) ?
+ puts("*** ERROR: NFS version not supported");
+ debug(": Requested: V%d, accepted: min V%d - max V%d\n",
+ (supported_nfs_versions & NFSV2_FLAG) ?
2 : 3,
2 : 3,
- ntohl(rpc_pkt.u.reply.data[0]),
- ntohl(rpc_pkt.u.reply.data[1]));
+ ntohl(rpc_pkt.u.reply.data[0]),
+ ntohl(rpc_pkt.u.reply.data[1]));
+ puts("\n");
}
break;
case NFS_RPC_PROG_UNAVAIL:
}
break;
case NFS_RPC_PROG_UNAVAIL:
@@
-569,8
+558,8
@@
static int nfs_lookup_reply(uchar *pkt, unsigned len)
case NFS_RPC_GARBAGE_ARGS:
case NFS_RPC_SYSTEM_ERR:
default: /* Unknown error on 'accept state' flag */
case NFS_RPC_GARBAGE_ARGS:
case NFS_RPC_SYSTEM_ERR:
default: /* Unknown error on 'accept state' flag */
-
printf
("*** ERROR: accept state error (%d)\n",
-
ntohl(rpc_pkt.u.reply.astatus));
+
debug
("*** ERROR: accept state error (%d)\n",
+ ntohl(rpc_pkt.u.reply.astatus));
break;
}
return -1;
break;
}
return -1;
@@
-592,7
+581,7
@@
static int nfs3_get_attributes_offset(uint32_t *data)
{
if (ntohl(data[1]) != 0) {
/* 'attributes_follow' flag is TRUE,
{
if (ntohl(data[1]) != 0) {
/* 'attributes_follow' flag is TRUE,
- * so we have attributes on 21
byte
s */
+ * so we have attributes on 21
dword
s */
/* Skip unused values :
type; 32 bits value,
mode; 32 bits value,
/* Skip unused values :
type; 32 bits value,
mode; 32 bits value,
@@
-671,7
+660,7
@@
static int nfs_read_reply(uchar *pkt, unsigned len)
debug("%s\n", __func__);
debug("%s\n", __func__);
- memcpy(
(uchar *)&rpc_pkt
, pkt, sizeof(rpc_pkt.u.reply));
+ memcpy(
&rpc_pkt.u.data[0]
, pkt, sizeof(rpc_pkt.u.reply));
if (ntohl(rpc_pkt.u.reply.id) > rpc_id)
return -NFS_RPC_ERR;
if (ntohl(rpc_pkt.u.reply.id) > rpc_id)
return -NFS_RPC_ERR;
@@
-781,7
+770,7
@@
static void nfs_handler(uchar *pkt, unsigned dest, struct in_addr sip,
if (reply == -NFS_RPC_DROP) {
break;
} else if (reply == -NFS_RPC_ERR) {
if (reply == -NFS_RPC_DROP) {
break;
} else if (reply == -NFS_RPC_ERR) {
-
puts
("*** ERROR: Cannot umount\n");
+
debug
("*** ERROR: Cannot umount\n");
net_set_state(NETLOOP_FAIL);
} else {
puts("\ndone\n");
net_set_state(NETLOOP_FAIL);
} else {
puts("\ndone\n");
@@
-845,7
+834,7
@@
static void nfs_handler(uchar *pkt, unsigned dest, struct in_addr sip,
if (!rlen)
nfs_download_state = NETLOOP_SUCCESS;
if (rlen < 0)
if (!rlen)
nfs_download_state = NETLOOP_SUCCESS;
if (rlen < 0)
-
printf
("NFS READ error (%d)\n", rlen);
+
debug
("NFS READ error (%d)\n", rlen);
nfs_state = STATE_UMOUNT_REQ;
nfs_send();
}
nfs_state = STATE_UMOUNT_REQ;
nfs_send();
}
@@
-864,7
+853,7
@@
void nfs_start(void)
if (nfs_path == NULL) {
net_set_state(NETLOOP_FAIL);
if (nfs_path == NULL) {
net_set_state(NETLOOP_FAIL);
-
puts
("*** ERROR: Fail allocate memory\n");
+
debug
("*** ERROR: Fail allocate memory\n");
return;
}
return;
}
@@
-875,8
+864,8
@@
void nfs_start(void)
(net_ip.s_addr >> 16) & 0xFF,
(net_ip.s_addr >> 24) & 0xFF);
(net_ip.s_addr >> 16) & 0xFF,
(net_ip.s_addr >> 24) & 0xFF);
-
printf
("*** Warning: no boot file name; using '%s'\n",
-
nfs_path);
+
debug
("*** Warning: no boot file name; using '%s'\n",
+ nfs_path);
} else {
char *p = net_boot_file_name;
} else {
char *p = net_boot_file_name;
@@
-894,10
+883,10
@@
void nfs_start(void)
nfs_filename = basename(nfs_path);
nfs_path = dirname(nfs_path);
nfs_filename = basename(nfs_path);
nfs_path = dirname(nfs_path);
-
printf
("Using %s device\n", eth_get_name());
+
debug
("Using %s device\n", eth_get_name());
-
printf
("File transfer via NFS from server %pI4; our IP address is %pI4",
-
&nfs_server_ip, &net_ip);
+
debug
("File transfer via NFS from server %pI4; our IP address is %pI4",
+ &nfs_server_ip, &net_ip);
/* Check if we need to send across this subnet */
if (net_gateway.s_addr && net_netmask.s_addr) {
/* Check if we need to send across this subnet */
if (net_gateway.s_addr && net_netmask.s_addr) {
@@
-907,18
+896,17
@@
void nfs_start(void)
our_net.s_addr = net_ip.s_addr & net_netmask.s_addr;
server_net.s_addr = net_server_ip.s_addr & net_netmask.s_addr;
if (our_net.s_addr != server_net.s_addr)
our_net.s_addr = net_ip.s_addr & net_netmask.s_addr;
server_net.s_addr = net_server_ip.s_addr & net_netmask.s_addr;
if (our_net.s_addr != server_net.s_addr)
-
printf
("; sending through gateway %pI4",
-
&net_gateway);
+
debug
("; sending through gateway %pI4",
+ &net_gateway);
}
}
-
printf
("\nFilename '%s/%s'.", nfs_path, nfs_filename);
+
debug
("\nFilename '%s/%s'.", nfs_path, nfs_filename);
if (net_boot_file_expected_size_in_blocks) {
if (net_boot_file_expected_size_in_blocks) {
-
printf
(" Size is 0x%x Bytes = ",
-
net_boot_file_expected_size_in_blocks << 9);
+
debug
(" Size is 0x%x Bytes = ",
+ net_boot_file_expected_size_in_blocks << 9);
print_size(net_boot_file_expected_size_in_blocks << 9, "");
}
print_size(net_boot_file_expected_size_in_blocks << 9, "");
}
- printf("\nLoad address: 0x%lx\n"
- "Loading: *\b", load_addr);
+ debug("\nLoad address: 0x%lx\nLoading: *\b", load_addr);
net_set_timeout_handler(nfs_timeout, nfs_timeout_handler);
net_set_udp_handler(nfs_handler);
net_set_timeout_handler(nfs_timeout, nfs_timeout_handler);
net_set_udp_handler(nfs_handler);