<html dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style id="owaParaStyle" type="text/css">
<!--
p
{margin-top:0;
margin-bottom:0}
-->
P {margin-top:0;margin-bottom:0;}</style>
</head>
<body ocsi="0" fpstyle="1">
<div style="direction: ltr;font-family: Tahoma;color: #000000;font-size: 10pt;">Hi,<br>
<br>
Can I presume that using errno with RTEMS does not work? To me I'm baffled that a RTEMS_SUCCESSFULL value must be returned in order to retain the errno value.<br>
<br>
regards,<br>
Indy<br>
<div style="font-family: Times New Roman; color: #000000; font-size: 16px">
<hr tabindex="-1">
<div style="direction: ltr;" id="divRpF770939"><font color="#000000" face="Tahoma" size="2"><b>From:</b> Inderjit Singh<br>
<b>Sent:</b> 24 August 2015 15:07<br>
<b>To:</b> Chris Johns; devel@rtems.org<br>
<b>Subject:</b> RE: rtems_set_errno_and_return_minus_one in driver not returning correct value<br>
</font><br>
</div>
<div></div>
<div>
<div style="direction:ltr; font-family:Tahoma; color:#000000; font-size:10pt"><br>
Ok I experimented on and this is what I found out:<br>
<br>
This is what I'm doing:<br>
<br>
<b>App:</b><br>
fd = open(RTEMS_SYSFLASH_DEVICE_NAME, O_RDWR);<br>
printk("Errno: (%d:%s).", errno, strerror(errno));<br>
assert(0); <br>
<br>
<b>Driver:</b><br>
rtems_device_driver rtems_sysflash_open(rtems_device_major_number major, rtems_device_minor_number unused, void *args)<br>
{<br>
uint32_t result;<br>
uint32_t status;<br>
rtems_libio_rw_args_t *rw_args;<br>
<br>
errno = EALREADY;<br>
return -1;<br>
}<br>
<br>
<b>Printout:<br>
</b>Errno: (22:Invalid argument).<b><br>
<br>
</b><br>
<b>Now, </b>If I change the return value to RTEMS_SUCCESSFULL in driver like<br>
<b>Driver:</b> <br>
...<br>
errno = EALREADY;<br>
return RTEMS_SUCCESSFULL;<br>
}<br>
<br>
<b>Printout:<br>
</b> Errno: (120:Socket already connected)<b><br>
<br>
<br>
</b>So it seems the one must return RTEMS_SUCCESSFUL to retain the errno value. This is not how it should behave right?<br>
<br>
Regards,<br>
Indy<br>
<b></b>________________________________________<br>
From: devel [devel-bounces@rtems.org] on behalf of Inderjit Singh [inderjit.singh@aacmicrotec.com]<br>
Sent: 24 August 2015 09:08<br>
To: Chris Johns; devel@rtems.org<br>
Subject: RE: rtems_set_errno_and_return_minus_one in driver not returning correct value<br>
<br>
Hi Chris,<br>
<br>
I am pretty sure the driver is working fine yes. I had this issue for some time and ignored the error messages during development as I always get a negative value. Now the driver is working is as it should and I am enforcing the error to test this.<br>
<br>
Regards,<br>
Indy<br>
________________________________________<br>
From: Chris Johns [chrisj@rtems.org]<br>
Sent: 24 August 2015 01:19<br>
To: Inderjit Singh; devel@rtems.org<br>
Subject: Re: rtems_set_errno_and_return_minus_one in driver not returning correct value<br>
<br>
On 21/08/2015 10:22 pm, Inderjit Singh wrote:<br>
> Hi,<br>
><br>
> In my RTEMS driver I set and return error value by following macro:<br>
><br>
> rtems_set_errno_and_return_minus_one(EALREADY);<br>
><br>
> But in my rtems app when I print the error out by:<br>
><br>
> fd = open(RTEMS_SYSFLASH_DEVICE_NAME, O_RDWR);<br>
> if(fd < 0) {<br>
> printk("Couldn't Open device (%d:%d:%s).", fd, errno, strerror(errno));<br>
> exit(-1);<br>
> }<br>
><br>
> *OUTPUT:* Couldn't Open device (-1:22:Invalid argument).<br>
><br>
> No matter what errno value i set I always get the same (22: Invalid<br>
> argument). I don't understand why. Any help would be appreciated.<br>
><br>
<br>
Are you sure the driver is correctly installed and registered and<br>
reaching your code ? Maybe some other part of the file system is<br>
detecting an error and returning the error code you are seeing for some<br>
other reason. I would add a print statement where you set the error code<br>
to see if that code is being reached.<br>
<br>
Chris<br>
_______________________________________________<br>
devel mailing list<br>
devel@rtems.org<br>
http://lists.rtems.org/mailman/listinfo/devel<br>
</div>
</div>
</div>
</div>
</body>
</html>