From: Steffen Trumtrar <s.trumtrar@pengutronix.de>
To: Sascha Hauer <s.hauer@pengutronix.de>
Cc: Barebox List <barebox@lists.infradead.org>
Subject: Re: [PATCH 4/5] fs: tftp: hide files which are actually not present on the server
Date: Thu, 30 Aug 2018 13:40:08 +0200 [thread overview]
Message-ID: <20180830114008.xhpsinblhtvkip5a@pengutronix.de> (raw)
In-Reply-To: <20180830104527.4057-5-s.hauer@pengutronix.de>
On Thu, Aug 30, 2018 at 12:45:26PM +0200, Sascha Hauer wrote:
> In tftp_lookup we claimed that every desired file is there. This leads
> to problems when a user only tests if a file is present and makes
> decisions upon this information. Rather than claiming that all files
> are present do a tftp_do_open() on the files and see if it is really
> there.
>
> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
> ---
> fs/tftp.c | 33 +++++++++++++++++++++++++--------
> 1 file changed, 25 insertions(+), 8 deletions(-)
>
> diff --git a/fs/tftp.c b/fs/tftp.c
> index 0baf0c2890..9274e931a2 100644
> --- a/fs/tftp.c
> +++ b/fs/tftp.c
> @@ -391,14 +391,6 @@ static struct file_priv *tftp_do_open(struct device_d *dev,
> case O_WRONLY:
> priv->push = 1;
> priv->state = STATE_WRQ;
> - if (!(accmode & O_TRUNC)) {
> - /*
> - * TFTP always truncates the existing file, so this
> - * flag is mandatory when opening a file for writing.
> - */
> - ret = -ENOSYS;
> - goto out;
> - }
> break;
> case O_RDWR:
> ret = -ENOSYS;
> @@ -646,10 +638,34 @@ static struct inode *tftp_get_inode(struct super_block *sb, const struct inode *
> return inode;
> }
>
> +static int tftp_create(struct inode *dir, struct dentry *dentry, umode_t mode)
> +{
> + struct inode *inode;
> +
> + inode = tftp_get_inode(dir->i_sb, dir, mode);
> + if (!inode)
> + return -EPERM;
> +
> + inode->i_size = 0;
> +
> + d_instantiate(dentry, inode);
> +
> + return 0;
> +}
> +
> static struct dentry *tftp_lookup(struct inode *dir, struct dentry *dentry,
> unsigned int flags)
> {
> + struct super_block *sb = dir->i_sb;
> + struct fs_device_d *fsdev = container_of(sb, struct fs_device_d, sb);
> struct inode *inode;
> + struct file_priv *priv;
> +
> + priv = tftp_do_open(&fsdev->dev, O_RDONLY, dentry);
> + if (IS_ERR(priv))
> + return NULL;
> +
> + tftp_do_close(priv);
>
> inode = tftp_get_inode(dir->i_sb, dir, S_IFREG | S_IRWXUGO);
> if (!inode)
> @@ -663,6 +679,7 @@ static struct dentry *tftp_lookup(struct inode *dir, struct dentry *dentry,
> static const struct inode_operations tftp_dir_inode_operations =
> {
> .lookup = tftp_lookup,
> + .create = tftp_create,
> };
>
> static const struct super_operations tftp_ops;
Tested-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>
Thx,
Steffen
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2018-08-30 11:40 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-30 10:45 TFTP improvements Sascha Hauer
2018-08-30 10:45 ` [PATCH 1/5] fs: tftp: overhaul debugging Sascha Hauer
2018-08-30 10:45 ` [PATCH 2/5] fs: tftp: fix memory hole Sascha Hauer
2018-08-30 10:45 ` [PATCH 3/5] fs: tftp: fix return value Sascha Hauer
2018-08-30 10:45 ` [PATCH 4/5] fs: tftp: hide files which are actually not present on the server Sascha Hauer
2018-08-30 11:40 ` Steffen Trumtrar [this message]
2018-08-30 10:45 ` [PATCH 5/5] fs: tftp: improve file size handling Sascha Hauer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180830114008.xhpsinblhtvkip5a@pengutronix.de \
--to=s.trumtrar@pengutronix.de \
--cc=barebox@lists.infradead.org \
--cc=s.hauer@pengutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox