fopen() on /dev/console

Joel Sherrill joel at rtems.org
Fri Feb 14 16:02:40 UTC 2020


Hi

I was porting some code from Linux to RTEMS. It doesn't use stdin/out,
error directly but does all debug IO to a configured file. Most of the time
when running on Linux, the device is /dev/stderr. For the RTEMS port,
I added link(/dev/console, /dev/stderr) to the init task and that worked.
But the application uses fopen(name, "w") to open the logging file.
This works on Linux. On RTEMS, this failed because "w" implies
ftruncate() and that returned -1.

I got around this by changing the logging helper to use fopen(name, "a").

I haven't done a POSIX deep dive and consulted with my POSIX contacts
yet for a strict POSIX ruling but I think we probably want the "w" to work
on RTEMS if it works on Lnux.

I can put together a test case but I would like to settle on the accepted
behavior first.

--joel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/devel/attachments/20200214/b628352b/attachment-0001.html>


More information about the devel mailing list