[PATCH 1/7] fs: implement ftruncate

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Sascha Hauer <s.hauer@xxxxxxxxxxxxxx>
---
 fs/fs.c          | 22 ++++++++++++++++++++++
 include/unistd.h |  1 +
 2 files changed, 23 insertions(+)

diff --git a/fs/fs.c b/fs/fs.c
index f61ee091b5..051af8d19f 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -742,6 +742,28 @@ int creat(const char *pathname, mode_t mode)
 }
 EXPORT_SYMBOL(creat);
 
+int ftruncate(int fd, loff_t length)
+{
+	struct fs_driver_d *fsdrv;
+	FILE *f;
+	int ret;
+
+	if (check_fd(fd))
+		return -errno;
+
+	f = &files[fd];
+
+	fsdrv = f->fsdev->driver;
+
+	ret = fsdrv->truncate(&f->fsdev->dev, f, length);
+	if (ret)
+		return ret;
+
+	f->size = length;
+
+	return 0;
+}
+
 int ioctl(int fd, int request, void *buf)
 {
 	struct fs_driver_d *fsdrv;
diff --git a/include/unistd.h b/include/unistd.h
index 31f430a5b6..f392e6dd6c 100644
--- a/include/unistd.h
+++ b/include/unistd.h
@@ -20,5 +20,6 @@ int symlink(const char *pathname, const char *newpath);
 int readlink(const char *path, char *buf, size_t bufsiz);
 int chdir(const char *pathname);
 const char *getcwd(void);
+int ftruncate(int fd, loff_t length);
 
 #endif /* __UNISTD_H */
-- 
2.11.0


_______________________________________________
barebox mailing list
barebox@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/barebox



[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux