diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2018-08-30 12:27:00 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2018-08-30 12:40:53 +0200 |
commit | e3e55fa3aa698bb92fa4362a36e102749c13c124 (patch) | |
tree | 1468535be961e1dacdd34f3a6762e1e6b2e28f33 /fs/tftp.c | |
parent | 3f245bc37d71e3a86db3cc78a615eb7c8ce8ba1c (diff) | |
download | barebox-e3e55fa3aa698bb92fa4362a36e102749c13c124.tar.gz barebox-e3e55fa3aa698bb92fa4362a36e102749c13c124.tar.xz |
fs: tftp: improve file size handling
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@pengutronix.de>
Diffstat (limited to 'fs/tftp.c')
-rw-r--r-- | fs/tftp.c | 10 |
1 files changed, 8 insertions, 2 deletions
@@ -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; |