diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2019-02-04 12:54:21 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2019-02-06 08:31:13 +0100 |
commit | 1455e221ae3023270a4716be6b47c038249955fd (patch) | |
tree | 4c9292c8244064ae28d4e56e95c93f9366c277b2 | |
parent | 20eea939a6fef5a02d55e83b997cd8c86607d83f (diff) | |
download | barebox-1455e221ae3023270a4716be6b47c038249955fd.tar.gz barebox-1455e221ae3023270a4716be6b47c038249955fd.tar.xz |
fs: devfs: forbid truncation when cdev has no truncate operation
When a cdev doesn't have a truncate callback then forbid truncation
and fail with -EPERM.
Before this we had always failed with -ENOSPC in this situation.
We checked for f->fsdev->dev.num_resources being nonzero, but this
check was absolutely meaningless. It goes back to ancient times when
the resources of a device were automatically added to devfs.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r-- | fs/devfs.c | 6 |
1 files changed, 1 insertions, 5 deletions
diff --git a/fs/devfs.c b/fs/devfs.c index aa44e32613..a7400df1c5 100644 --- a/fs/devfs.c +++ b/fs/devfs.c @@ -175,11 +175,7 @@ static int devfs_truncate(struct device_d *dev, FILE *f, loff_t size) if (cdev->ops->truncate) return cdev->ops->truncate(cdev, size); - if (f->fsdev->dev.num_resources < 1) - return -ENOSPC; - if (size > resource_size(&f->fsdev->dev.resource[0])) - return -ENOSPC; - return 0; + return -EPERM; } static struct inode *devfs_alloc_inode(struct super_block *sb) |