RTEMS shell and chdir

Joel Sherrill joel.sherrill at oarcorp.com
Tue Jul 15 21:44:17 UTC 2014


On 7/15/2014 4:02 PM, Peter Dufault wrote:
> A friend started trying RTEMS and noted that the RTEMS shell doesn't work as he expected - each shell maintains its own current working directory.   Furthermore, a "chdir()" in a routine that then creates a shell doesn't get the working directory from the "chdir()".
>
> Searching about "current working directory" and "pthreads" or POSIX threads results in Linux and other man pages that state that the current working directory is shared across all threads in a process.  The RTEMS shell seems to be calling "getcwd()" to get back the directory for the shell.  Is there a single current working directory in RTEMS?  Should "chdir" in one shell result in all shells having a different current working directory?  How does it work now?
POSIX has the concept of a per-process environment. RTEMS has that
same concept but since the entire application is one process, a change
to the per-process environment could impact threads in a way that
you don't want.

Thus you can set a thread to have a private per-process environment.
This lets a thread have a separate uid, gid, chroot(), cwd() and a few other
characteristics.

The shell and ftp daemon use this feature. When you login, you actually
get a user id. I think fileio (for sure telnetd) example let you login
as root
or rtems and you have different file access permissions.

By default, all threads have the same per-process variables.  Which
is POSIX compliant.

Your friend was smart enough to recognize that this wasn't POSIX
behavior.  But since you can have multiple shell instances, it does
make sense that one chdir() only impacts that one shell.
> Peter
> -----------------
> Peter Dufault
> HD Associates, Inc.      Software and System Engineering
>
> _______________________________________________
> users mailing list
> users at rtems.org
> http://lists.rtems.org/mailman/listinfo/users

-- 
Joel Sherrill, Ph.D.             Director of Research & Development
joel.sherrill at OARcorp.com        On-Line Applications Research
Ask me about RTEMS: a free RTOS  Huntsville AL 35805
Support Available                (256) 722-9985




More information about the users mailing list