summaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2013-10-16 10:58:53 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2013-10-16 10:59:25 +0200
commit42cb98c6ae92e1f46105d055d24ea249af44bf3f (patch)
tree37e164b56880cf551ffa9ee400154d25bfc76348 /fs
parent0ce908358260db4de67a6f5e9e27f97da6e22c3f (diff)
downloadbarebox-42cb98c6ae92e1f46105d055d24ea249af44bf3f.tar.gz
barebox-42cb98c6ae92e1f46105d055d24ea249af44bf3f.tar.xz
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 d4f5bb1e011ac653a167031554f0ac9e028e9e36 | 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>
Diffstat (limited to 'fs')
-rw-r--r--fs/fs.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/fs/fs.c b/fs/fs.c
index ce7b425546..7d558e90d0 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -722,8 +722,7 @@ int open(const char *pathname, int flags, ...)
if (ret)
goto out;
-
- if (flags & O_TRUNC) {
+ if (!(s.st_mode & S_IFCHR) && (flags & O_TRUNC)) {
ret = fsdrv->truncate(&fsdev->dev, f, 0);
f->size = 0;
if (ret)