From: Thadeu Lima de Souza Cascardo Date: Wed, 19 May 2010 16:23:22 +0000 (-0400) Subject: Check truncate and append flags. X-Git-Url: http://git.cascardo.info/?p=cascardo%2Fkernel%2Fsamples%2Fchar2%2F.git;a=commitdiff_plain;h=5b94b5e132c4e676bfbbe9bf61249d2893bae429 Check truncate and append flags. --- 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; }