<div dir="ltr">Greg, <div><br></div><div>I was looking again to <span style="font-family:arial,sans-serif;font-size:13px">documentation, but didn't find a explanation about the show and store functions. I'm missing something ? </span></div>
<div><span style="font-family:arial,sans-serif;font-size:13px"><br></span></div><div><span style="font-family:arial,sans-serif;font-size:13px">Yes, everything work if I simple use the buffer from store function, but I was looking for where it came from. </span></div>
<div><span style="font-family:arial,sans-serif;font-size:13px">Like, It was from user space? So, I need to take care like </span><font face="arial, sans-serif">simple_write_to_buffer does with user space memory ? </font></div>
<div><font face="arial, sans-serif"><br></font></div><div><font face="arial, sans-serif">I said that because of file file_operations read and write, that I know that comes from user space. But kobj_attribute I didn't understand yet. </font></div>
<div><span style="font-family:arial,sans-serif;font-size:13px"><br></span></div><div><span style="font-family:arial,sans-serif;font-size:13px">What I meant posting one piece of my code was just show what I doing in high level. </span></div>
<div><font face="arial, sans-serif">But, for some reason gmail sent in the middle of my writing. </font></div><div><font face="arial, sans-serif"><br></font></div><div><font face="arial, sans-serif"><br></font></div><div>
<font face="arial, sans-serif"><br></font></div><div><font face="arial, sans-serif"><div>static ssize_t id_store(struct kobject *kobj, struct kobj_attribute *attr,</div><div><span class="" style="white-space:pre">                        </span> const char *buf, size_t count)</div>
<div>{</div><div><span class="" style="white-space:pre">        </span>char *buffer;</div><div><span class="" style="white-space:pre">        </span>buffer = kcalloc(cnt, sizeof(char), GFP_KERNEL);</div><div><span class="" style="white-space:pre">        </span>if (buffer) {</div>
<div><span class="" style="white-space:pre">                </span>if (copy_from_user(buffer, buf, cnt) == cnt) {</div><div><span class="" style="white-space:pre">                        </span>if (strcmp(buffer, "Tanure") == 0)</div><div><span class="" style="white-space:pre">                                </span>return cnt;</div>
<div><span class="" style="white-space:pre">                        </span>}</div><div><span class="" style="white-space:pre">                </span>}</div><div><span class="" style="white-space:pre">        </span>}</div><div><span class="" style="white-space:pre">        </span>return -EINVAL;</div>
<div>}</div><div><br></div><div>The copy_from_user returns 6 when I write my name in the file. So, 6 means that copy_from_user fails to copy 6 bytes from buf. </div><div>So there is my question, buf is a user pointer ? Or Can I just copy without problems ? </div>
<div><br></div><div>All this e-mails got me in trouble here. I got kicked from eudyptula challenge, what I still begging to be able to finish. </div><div><br></div><div>Thanks Greg for all the help.</div></font></div>
<div><span style="font-family:arial,sans-serif;font-size:13px"><br>
</span></div><div><span style="font-family:arial,sans-serif;font-size:13px"><br></span></div></div><div class="gmail_extra"><br clear="all"><div><div dir="ltr"><div>--</div>Lucas Tanure <br>+55 (19) 988176559<br></div></div>
<br><br><div class="gmail_quote">On Wed, Sep 3, 2014 at 9:56 PM, Greg KH <span dir="ltr"><<a href="mailto:greg@kroah.com" target="_blank">greg@kroah.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
A: No.<br>
Q: Should I include quotations after my reply?<br>
<br>
<a href="http://daringfireball.net/2007/07/on_top" target="_blank">http://daringfireball.net/2007/07/on_top</a><br>
<div class=""><br>
On Wed, Sep 03, 2014 at 09:39:50PM -0300, Lucas Tanure wrote:<br>
> Greg, <br>
><br>
> I'm still trying to understand the sysfs. <br>
<br>
</div>Why? What are you using "raw kobjects" for? You should almost never<br>
need them.<br>
<div class=""><br>
> I indeed read the documentation, I was using your "Sample kobject<br>
> implementation" as base of my code.<br>
<br>
</div>Great, then it should "just work", right? :)<br>
<br>
Care to post your non-working code?<br>
<br>
thanks,<br>
<br>
greg k-h<br>
</blockquote></div><br></div>