Help answer threads with 0 replies.
Go Back > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Linux - Kernel This forum is for all discussion relating to the Linux kernel.


  Search this Thread
Old 10-12-2009, 03:12 AM   #1
LQ Newbie
Registered: Oct 2009
Posts: 2

Rep: Reputation: 0
Question Problem with char driver write function - infinite loop


I've a problem with a really simple write function in my first char driver.
The function is as follows:

static char hello_world[]="Hello World\n";
static ssize_t driver_write (struct file *instanz, const char *user, size_t count,
 loff_t *offset ) {

  int nc = 0;
  if (count > strlen(hello_world)+1) return strlen(hello_world)+1-count;

  return copy_from_user(hello_world,user,count);
If I try wo write on the associated Device, the write call works but it seems that is produces an infinite loop.
So the write function seems to be call infinite times.
By the printk in the write function i can see that behavior.

The failure goes from a simple echo > /dev/device to an C program using fwrite.

I'm grateful for each hint.

Johannes S.

Last edited by Cherubim; 10-12-2009 at 03:30 AM. Reason: typo
Old 10-13-2009, 02:08 AM   #2
LQ Newbie
Registered: Oct 2009
Posts: 2

Original Poster
Rep: Reputation: 0
Problem fixed.. I'be to return the values of the written bytes and not of the not written.
Correct is:

  nc = copy_from_user(hello_world,user,count);
  return count-nc;


char, device, driver, function, write

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
RHEL 5 Install Problem - Infinite Reboot Loop aramsey Linux - Enterprise 4 09-19-2008 05:22 AM
Apache mod_rewrite CondRewrite infinite loop problem jika Linux - Server 2 05-01-2007 08:25 AM
Infinite Loop ewt3y Programming 3 08-16-2005 10:48 AM
infinite loop beginner_84 Programming 5 08-15-2004 03:32 AM
facing problem in increment operator of set :infinite LOOP ashwinipahuja Programming 0 06-03-2004 01:05 AM > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 08:24 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration