Previously we used FILE_SIZE_STREAM unconditionally. Instead, fill the inode size with a valid filesize if we have one and only if not fall back to FILE_SIZE_STREAM. Signed-off-by: Sascha Hauer <s.hauer@xxxxxxxxxxxxxx> --- fs/tftp.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/fs/tftp.c b/fs/tftp.c index 9274e931a2..30256ada6e 100644 --- a/fs/tftp.c +++ b/fs/tftp.c @@ -458,7 +458,6 @@ static int tftp_open(struct device_d *dev, FILE *file, const char *filename) return PTR_ERR(priv); file->priv = priv; - file->size = SZ_2G; return 0; } @@ -619,7 +618,6 @@ static struct inode *tftp_get_inode(struct super_block *sb, const struct inode * inode->i_ino = get_next_ino(); inode->i_mode = mode; - inode->i_size = FILE_SIZE_STREAM; switch (mode & S_IFMT) { default: @@ -660,17 +658,25 @@ static struct dentry *tftp_lookup(struct inode *dir, struct dentry *dentry, struct fs_device_d *fsdev = container_of(sb, struct fs_device_d, sb); struct inode *inode; struct file_priv *priv; + int filesize; priv = tftp_do_open(&fsdev->dev, O_RDONLY, dentry); if (IS_ERR(priv)) return NULL; + filesize = priv->filesize; + tftp_do_close(priv); inode = tftp_get_inode(dir->i_sb, dir, S_IFREG | S_IRWXUGO); if (!inode) return ERR_PTR(-ENOMEM); + if (filesize) + inode->i_size = filesize; + else + inode->i_size = FILE_SIZE_STREAM; + d_add(dentry, inode); return NULL; -- 2.18.0 _______________________________________________ barebox mailing list barebox@xxxxxxxxxxxxxxxxxxx http://lists.infradead.org/mailman/listinfo/barebox