From 5b94b5e132c4e676bfbbe9bf61249d2893bae429 Mon Sep 17 00:00:00 2001 From: Thadeu Lima de Souza Cascardo Date: Wed, 19 May 2010 12:23:22 -0400 Subject: [PATCH] Check truncate and append flags. --- hellochar.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/hellochar.c b/hellochar.c index ee09b1e..71605f6 100644 --- a/hellochar.c +++ b/hellochar.c @@ -37,6 +37,12 @@ struct hello_buffer *hello; static int hello_open(struct inode *ino, struct file *fp) { + if (fp->f_flags & O_TRUNC) { + memset(hello->buffer, 0, MAXLEN); + hello->len = 0; + } + if (fp->f_flags & O_APPEND) + fp->f_pos = hello->len; return 0; } -- 2.20.1