Re: [Linux-fbdev-devel] Behaviour change of /dev/fb0?

Antonino A. Daplas
2006-04-15T00:53:58Z

Richard Purdie wrote:
> Ignoring whether this is a good idea or not, under 2.6.15 you could run
>
> dd if=/dev/zero of=/dev/fb0
>
> which would clear the framebuffer. It would end up saying "dd: /dev/fb0:
> No space left on device".
>
> Under 2.6.16 (and a recent git kernel), the same command clears the
> screen but then hangs. Was the change in behaviour intentional?
>
> I've noticed this on a couple of ARM based Zaurus handhelds under both
> w100fb and pxafb.
>

After reading 'man 2 read' more thoroughly, I've adjusted fb_write()'s
return codes appropriately. Can you try this patch and let me know if it
fixes your problem.

Tony

fbdev: Fix return error of fb_write()

- return -EFBIG if file offset is past the maximum allowable offset
- return -EFBIG and write to end of framebuffer if size is bigger than the
framebuffer length
- return -ENOSPC and write to end of framebuffer if size is bigger than the
framebuffer length - file offset

Signed-off-by: Antonino Daplas <adaplas@pol.net>
---

drivers/video/fbmem.c | 12 +++++++++---
1 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c
index 944855b..8a643bf 100644
--- a/drivers/video/fbmem.c
+++ b/drivers/video/fbmem.c
@@ -669,13 +669,19 @@ fb_write(struct file *file, const char _
total_size = info->fix.smem_len;

if (p > total_size)
- return 0;
+ return -EFBIG;

- if (count >= total_size)
+ if (count >= total_size) {
+ err = -EFBIG;
count = total_size;
+ }
+
+ if (count + p > total_size) {
+ if (!err)
+ err = -ENOSPC;

- if (count + p > total_size)
count = total_size - p;
+ }

buffer = kmalloc((count > PAGE_SIZE) ? PAGE_SIZE : count,
GFP_KERNEL);