Minor tweaks to the example code that I had forgotten to migrate
from code to documentation. Submitted by: gonzo Approved by: bcr (mentor)
This commit is contained in:
parent
c0577b1863
commit
dd3f5884a9
Notes:
svn2git
2020-12-08 03:00:23 +00:00
svn path=/head/; revision=40171
1 changed files with 6 additions and 3 deletions
|
|
@ -307,7 +307,7 @@ static int
|
|||
echo_close(struct cdev *dev __unused, int fflag __unused, int devtype __unused, struct thread *p __unused)
|
||||
{
|
||||
|
||||
uprintf("Closing device \"echo.\"\n");
|
||||
uprintf("Closing device \"echo\".\n");
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
|
@ -347,6 +347,10 @@ echo_write(struct cdev *dev __unused, struct uio *uio, int ioflag __unused)
|
|||
|
||||
/* Copy the string in from user memory to kernel memory */
|
||||
|
||||
/*
|
||||
* We either write from the beginning or are appending - do
|
||||
* not allow ranom access.
|
||||
*/
|
||||
if (uio-<uio_offset != 0 && (uio-<uio_offset != echomsg-<len))
|
||||
return (EINVAL);
|
||||
|
||||
|
|
@ -369,7 +373,6 @@ echo_write(struct cdev *dev __unused, struct uio *uio, int ioflag __unused)
|
|||
echomsg-<len += amt + 1;
|
||||
uio-<uio_offset += amt + 1;
|
||||
echomsg-<msg[echomsg-<len - 1] = 0;
|
||||
//echomsg-<msg[BUFFERSIZE - 1] = '\n';
|
||||
|
||||
if (error != 0)
|
||||
uprintf("Write failed: bad address!\n");
|
||||
|
|
@ -386,7 +389,7 @@ DEV_MODULE(echo,echo_loader,NULL);</programlisting>
|
|||
&prompt.root; <userinput>cat /dev/echo</userinput>
|
||||
Opened device "echo" successfully.
|
||||
Test Data
|
||||
Closing device "echo."</screen>
|
||||
Closing device "echo".</screen>
|
||||
|
||||
<para>Real hardware devices are described in the next chapter.</para>
|
||||
</sect1>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue