uimove works only if null terminated string is writen
uimove works only if null terminated string is writen
- Subject: uimove works only if null terminated string is writen
- From: sanjay yaragatti <email@hidden>
- Date: Mon, 25 Sep 2006 12:57:04 +0100 (BST)
Hi all,
I had recently posted a mail asking about the
problems faced in dev_write of a character deive using
uiomove.I am now able to print the data after doing
the uiomove() opearation i,e print the data after
copying from user space to kernel space. I have
observed that uimove() api in the driver works only
when u write a null terminated string from the user
space application. How do i write a single character
from user space application which is not null
terminated??
write(device_fd, (char *)&c, 1); //doesnt work
write(device_fd, str, strlen(str)); // works fine
Here is the sample user space application through
which i am writng to and reading from the driver.
int main()
{
FILE *fp = NULL;
int device_fd = -1;
char str[50] = {0};
char file_name[40] = {0};
printf("Enter the file name\n");
scanf("%s", file_name);
device_fd = open(dev_name, O_RDWR);
fp = fopen(file_name, "r");
if (fp == NULL)
{
printf("File open failed\n");
return ;
}
//while ((c = fgetc(fp)) != EOF) // doesnt work
while ((retval= fgets(str,sizeof(str),fp)) != NULL)
{
//ret = write(device_fd, (char *)&c, 1); // doesnt
work
ret = write(device_fd, str, 10); // works fine
}
}
__________________________________________________________
Yahoo! India Answers: Share what you know. Learn something new
http://in.answers.yahoo.com/
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-kernel mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden