projects
/
cascardo
/
kernel
/
samples
/
char2
/
.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
| inline |
side by side
Check truncate and append flags.
[cascardo/kernel/samples/char2/.git]
/
hellochar.c
diff --git
a/hellochar.c
b/hellochar.c
index
ee09b1e
..
71605f6
100644
(file)
--- 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;
}