summaryrefslogtreecommitdiff
path: root/net
diff options
context:
space:
mode:
authorMarek Szyprowski <m.szyprowski@samsung.com>2020-03-17 14:03:10 +0100
committerJaehoon Chung <jh80.chung@samsung.com>2023-10-17 13:19:20 +0900
commit40849b544ea11e848511cdaba40fb2f3409eb629 (patch)
tree704d457437c89e53114c33120c8aa75dceae17c0 /net
parent4918aa4633e0c702e2d3981a8c453c79cb1c9bff (diff)
downloadu-boot-40849b544ea11e848511cdaba40fb2f3409eb629.tar.gz
u-boot-40849b544ea11e848511cdaba40fb2f3409eb629.tar.bz2
u-boot-40849b544ea11e848511cdaba40fb2f3409eb629.zip
net: nfs: add support for partial downloads from given offset
Add support for downloading file from the given offset (in bytes) and limit the size up to given bytes. Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com> Change-Id: I9f442d375d6b37986cb7c10f93c11d265886cceb
Diffstat (limited to 'net')
-rw-r--r--net/nfs.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/net/nfs.c b/net/nfs.c
index 6f83a48416..9d6eb105ad 100644
--- a/net/nfs.c
+++ b/net/nfs.c
@@ -56,6 +56,8 @@ static unsigned long rpc_id;
static int nfs_offset = -1;
static int nfs_len;
static const ulong nfs_timeout = CONFIG_NFS_TIMEOUT;
+u32 net_boot_file_size_limit;
+u32 net_boot_file_offset;
static char dirfh[NFS_FHSIZE]; /* NFSv2 / NFSv3 file handle of directory */
static char filefh[NFS3_FHSIZE]; /* NFSv2 / NFSv3 file handle */
@@ -756,7 +758,7 @@ static int nfs_read_reply(uchar *pkt, unsigned len)
if (((uchar *)&(rpc_pkt.u.reply.data[0]) - (uchar *)(&rpc_pkt) + rlen) > len)
return -9999;
- if (store_block(data_ptr, nfs_offset, rlen))
+ if (store_block(data_ptr, nfs_offset - net_boot_file_offset, rlen))
return -9999;
return rlen;
@@ -858,7 +860,7 @@ static void nfs_handler(uchar *pkt, unsigned dest, struct in_addr sip,
nfs_send();
} else {
nfs_state = STATE_READ_REQ;
- nfs_offset = 0;
+ nfs_offset = net_boot_file_offset;
nfs_len = NFS_READ_SIZE;
nfs_send();
}
@@ -889,6 +891,11 @@ static void nfs_handler(uchar *pkt, unsigned dest, struct in_addr sip,
net_set_timeout_handler(nfs_timeout, nfs_timeout_handler);
if (rlen > 0) {
nfs_offset += rlen;
+ if (nfs_offset - net_boot_file_offset ==
+ net_boot_file_size_limit) {
+ nfs_download_state = NETLOOP_SUCCESS;
+ nfs_state = STATE_UMOUNT_REQ;
+ }
nfs_send();
} else if ((rlen == -NFSERR_ISDIR) || (rlen == -NFSERR_INVAL)) {
/* symbolic link */