Changeset bb9ec2d in mainline for uspace/lib/c/generic/io/io.c


Ignore:
Timestamp:
2017-03-07T20:47:35Z (8 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
a737667e
Parents:
e796dc8
git-author:
Jiri Zarevucky <zarevucky.jiri@…> (2017-03-07 20:47:35)
git-committer:
Jakub Jermar <jakub@…> (2017-03-07 20:47:35)
Message:

Merge from lp:~zarevucky-jiri/helenos/vfs-2.5/ revision 1941-1944

Original commit messages:

1944: Jiri Zarevucky 2013-08-06 Replace legacy file descriptor presetting with inbox.
1943: Jiri Zarevucky 2013-08-06 Do not preserve open state when passing file descriptor to another task. Allow receiver to specify, whether the descriptor is low or high.
1942: Jiri Zarevucky 2013-08-06 C style.
1941: Jiri Zarevucky 2013-08-06 Make loader accept file reference instead of a pathname.

Modifications:

  • Keep version of elf_load_file() that accepts file name
  • Changes required for loading dynamically linked executables
  • Update to newer list_foreach
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/generic/io/io.c

    re796dc8 rbb9ec2d  
    4545#include <vfs/vfs.h>
    4646#include <vfs/vfs_sess.h>
     47#include <vfs/inbox.h>
    4748#include <ipc/loc.h>
    4849#include <adt/list.h>
     
    101102static LIST_INITIALIZE(files);
    102103
    103 void __stdio_init(int filc)
    104 {
    105         if (filc > 0) {
    106                 stdin = fdopen(0, "r");
     104void __stdio_init(void)
     105{
     106        /* The first three standard file descriptors are assigned for compatibility.
     107         * This will probably be removed later.
     108         */
     109         
     110        int infd = inbox_get("stdin");
     111        if (infd >= 0) {
     112                int stdinfd = vfs_clone(infd, false);
     113                assert(stdinfd == 0);
     114                _vfs_open(stdinfd, MODE_READ);
     115                stdin = fdopen(stdinfd, "r");
    107116        } else {
    108117                stdin = &stdin_null;
     
    110119        }
    111120       
    112         if (filc > 1) {
    113                 stdout = fdopen(1, "w");
     121        int outfd = inbox_get("stdout");
     122        if (outfd >= 0) {
     123                int stdoutfd = vfs_clone(outfd, false);
     124                assert(stdoutfd <= 1);
     125                while (stdoutfd < 1) {
     126                        stdoutfd = vfs_clone(outfd, false);
     127                }
     128                _vfs_open(stdoutfd, MODE_APPEND);
     129                stdout = fdopen(stdoutfd, "a");
    114130        } else {
    115131                stdout = &stdout_kio;
     
    117133        }
    118134       
    119         if (filc > 2) {
    120                 stderr = fdopen(2, "w");
     135        int errfd = inbox_get("stderr");
     136        if (errfd >= 0) {
     137                int stderrfd = vfs_clone(errfd, false);
     138                assert(stderrfd <= 2);
     139                while (stderrfd < 2) {
     140                        stderrfd = vfs_clone(errfd, false);
     141                }
     142                _vfs_open(stderrfd, MODE_APPEND);
     143                stderr = fdopen(stderrfd, "a");
    121144        } else {
    122145                stderr = &stderr_kio;
Note: See TracChangeset for help on using the changeset viewer.