fs: ignore O_TRUNC open flag for devices
The O_TRUNC flag has to be ignored when opening devices. Otherwise
cp /somefile /dev/somedev fails. This is broken since:
| commit d4f5bb1e01
| Author: Sascha Hauer <s.hauer@pengutronix.de>
| Date: Sat Sep 28 13:12:50 2013 +0200
|
| copy_file: Add missing O_TRUNC
|
| Without it, when copying a smaller file over a larger file the
| resulting file still has the remaining space from the larger file.
|
| Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This commit is contained in:
parent
0ce9083582
commit
42cb98c6ae
3
fs/fs.c
3
fs/fs.c
|
@ -722,8 +722,7 @@ int open(const char *pathname, int flags, ...)
|
||||||
if (ret)
|
if (ret)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
|
if (!(s.st_mode & S_IFCHR) && (flags & O_TRUNC)) {
|
||||||
if (flags & O_TRUNC) {
|
|
||||||
ret = fsdrv->truncate(&fsdev->dev, f, 0);
|
ret = fsdrv->truncate(&fsdev->dev, f, 0);
|
||||||
f->size = 0;
|
f->size = 0;
|
||||||
if (ret)
|
if (ret)
|
||||||
|
|
Loading…
Reference in New Issue