#include "etherboot.h"
-#include "init.h"
+#include <gpxe/init.h>
#include "proto.h"
-#include "in.h"
+#include <gpxe/in.h>
#include "nic.h"
/* NOTE: the NFS code is heavily inspired by the NetBSD netboot code (read:
rpc->u.reply.astatus) {
/* rpc_printerror() is called for any RPC related error,
* suppress output if no low level RPC error happened. */
- DBG("RPC error: (%d,%d,%d)\n", ntohl(rpc->u.reply.rstatus),
+ DBG("RPC error: (%ld,%ld,%ld)\n", ntohl(rpc->u.reply.rstatus),
ntohl(rpc->u.reply.verifier),
ntohl(rpc->u.reply.astatus));
}
*p++ = htonl(ver);
*p++ = htonl(IP_UDP);
*p++ = 0;
- if ( ! addr->sin_port ) {
- addr->sin_port = SUNRPC_PORT;
- }
for (retries = 0; retries < MAX_RPC_RETRIES; retries++) {
long timeout;
udp_transmit(addr->sin_addr.s_addr, sport, addr->sin_port,
/**************************************************************************
NFS - Download extended BOOTP data, or kernel image from NFS server
**************************************************************************/
-static int nfs ( char *url __unused,
- struct sockaddr_in *server,
- char *name,
- int ( * process ) ( unsigned char *data,
- unsigned int blocknum,
- unsigned int len, int eof ) ) {
+static int nfs ( char *url __unused, struct sockaddr_in *server,
+ char *name, struct buffer *buffer ) {
static int recursion = 0;
int sport;
int err, namelen = strlen(name);
char dirname[300], *fname;
char dirfh[NFS_FHSIZE]; /* file handle of directory */
char filefh[NFS_FHSIZE]; /* file handle of kernel image */
- unsigned int block;
int rlen, size, offs, len;
struct rpc_t *rpc;
mount_server.sin_addr = nfs_server.sin_addr = server->sin_addr;
mount_server.sin_port = rpc_lookup(server, PROG_MOUNT, 1, sport);
if ( ! mount_server.sin_port ) {
- DBG ( "Cannot get mount port from %!:%d\n",
- server->sin_addr.s_addr, server->sin_port );
+ DBG ( "Cannot get mount port from %s:%d\n",
+ inet_ntoa ( server->sin_addr ), server->sin_port );
return 0;
}
nfs_server.sin_port = rpc_lookup(server, PROG_NFS, 2, sport);
if ( ! mount_server.sin_port ) {
- DBG ( "Cannot get nfs port from %!:%d\n",
- server->sin_addr.s_addr, server->sin_port );
+ DBG ( "Cannot get nfs port from %s:%d\n",
+ inet_ntoa ( server->sin_addr ), server->sin_port );
return 0;
}
}
offs = 0;
- block = 1; /* blocks are numbered starting from 1 */
size = -1; /* will be set properly with the first reply */
len = NFS_READ_SIZE; /* first request is always full size */
do {
// An error occured. NFS servers tend to sending
// errors 21 / 22 when symlink instead of real file
// is requested. So check if it's a symlink!
- block = nfs_readlink(&nfs_server, dirfh, dirname,
- filefh, sport);
- if ( 0 == block ) {
+ if ( nfs_readlink(&nfs_server, dirfh, dirname,
+ filefh, sport) == 0 ) {
printf("\nLoading symlink:%s ..",dirname);
goto nfssymlink;
}
return 0;
}
if (err) {
- printf("reading at offset %d: ", offs);
+ printf("\nError reading at offset %d: ", offs);
nfs_printerror(err);
nfs_reset();
return 0;
rlen = len; /* shouldn't happen... */
}
- err = process((char *)&rpc->u.reply.data[19], block, rlen,
- (offs+rlen == size));
- if (err <= 0) {
+ if ( ! fill_buffer ( buffer, &rpc->u.reply.data[19],
+ offs, rlen ) ) {
nfs_reset();
- return err;
+ return 0;
}
- block++;
offs += rlen;
/* last request is done with matching requested read size */
if (size-offs < NFS_READ_SIZE) {
INIT_FN ( INIT_RPC, rpc_init, nfs_reset, nfs_reset );
-static struct protocol nfs_protocol __protocol = {
- "nfs", nfs
+struct protocol nfs_protocol __protocol = {
+ .name = "nfs",
+ .default_port = SUNRPC_PORT,
+ .load = nfs,
};