Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 368ee04 in mainline for uspace/lib/c/generic/task.c


Ignore:
Timestamp:
2017-04-05T18:10:39Z (5 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master
Children:
93ad8166
Parents:
39f892a9 (diff), 2166728 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge from lp:~jakub/helenos/vfs-2.5-cherrypick

This merge cherry-picks some of the changesets from Jiri Zarevucky's:

lp:~zarevucky-jiri/helenos/vfs-2.5

and then continues independently, yet sometime in a similar vein.

Roughly speaking, Jiri's branch is merged entirely up to its revision
1926 and then cherry-picked on and off until its revision 1965. Among
these changes are:

  • relativization of the API,
  • client-side roots,
  • server-side mounts,
  • inbox for passing arbitrary files from parent to child,
  • some streamlining and cleanup.

Additional changes include:

  • addressing issues introduced by the above changes,
  • client-side I/O cursors (file positions),
  • all HelenOS file system APIs begin with the vfs_ prefix and can be used after including vfs/vfs.h,
  • removal of some POSIX-ish headers and definitions,
  • additional cleanup.
File:
1 edited

Legend:

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

    r39f892a9 r368ee04  
    4848#include "private/ns.h"
    4949#include <vfs/vfs.h>
     50#include <unistd.h>
    5051
    5152task_id_t task_get_id(void)
     
    107108{
    108109        /* Send default files */
    109         int *files[4];
    110         int fd_stdin;
    111         int fd_stdout;
    112         int fd_stderr;
    113        
    114         if ((stdin != NULL) && (vfs_fhandle(stdin, &fd_stdin) == EOK))
    115                 files[0] = &fd_stdin;
    116         else
    117                 files[0] = NULL;
    118        
    119         if ((stdout != NULL) && (vfs_fhandle(stdout, &fd_stdout) == EOK))
    120                 files[1] = &fd_stdout;
    121         else
    122                 files[1] = NULL;
    123        
    124         if ((stderr != NULL) && (vfs_fhandle(stderr, &fd_stderr) == EOK))
    125                 files[2] = &fd_stderr;
    126         else
    127                 files[2] = NULL;
    128        
    129         files[3] = NULL;
    130        
    131         return task_spawnvf(id, wait, path, args, files);
     110       
     111        int fd_stdin = -1;
     112        int fd_stdout = -1;
     113        int fd_stderr = -1;
     114       
     115        if (stdin != NULL) {
     116                (void) vfs_fhandle(stdin, &fd_stdin);
     117        }
     118       
     119        if (stdout != NULL) {
     120                (void) vfs_fhandle(stdout, &fd_stdout);
     121        }
     122
     123        if (stderr != NULL) {
     124                (void) vfs_fhandle(stderr, &fd_stderr);
     125        }
     126       
     127        return task_spawnvf(id, wait, path, args, fd_stdin, fd_stdout,
     128            fd_stderr);
    132129}
    133130
     
    138135 * Files are passed as null-terminated array of pointers to fdi_node_t.
    139136 *
    140  * @param id    If not NULL, the ID of the task is stored here on success.
    141  * @param wait  If not NULL, setup waiting for task's return value and store
    142  *              the information necessary for waiting here on success.
    143  * @param path  Pathname of the binary to execute.
    144  * @param argv  Command-line arguments.
    145  * @param files Standard files to use.
     137 * @param id      If not NULL, the ID of the task is stored here on success.
     138 * @param wait    If not NULL, setup waiting for task's return value and store
     139 * @param path    Pathname of the binary to execute.
     140 * @param argv    Command-line arguments.
     141 * @param std_in  File to use as stdin.
     142 * @param std_out File to use as stdout.
     143 * @param std_err File to use as stderr.
    146144 *
    147145 * @return Zero on success or negative error code.
     
    149147 */
    150148int task_spawnvf(task_id_t *id, task_wait_t *wait, const char *path,
    151     const char *const args[], int *const files[])
     149    const char *const args[], int fd_stdin, int fd_stdout, int fd_stderr)
    152150{
    153151        /* Connect to a program loader. */
     
    169167                goto error;
    170168       
    171         /* Send program pathname. */
    172         rc = loader_set_pathname(ldr, path);
     169        /* Send program binary. */
     170        rc = loader_set_program_path(ldr, path);
    173171        if (rc != EOK)
    174172                goto error;
     
    180178       
    181179        /* Send files */
    182         rc = loader_set_files(ldr, files);
    183         if (rc != EOK)
    184                 goto error;
     180        int root = vfs_root();
     181        if (root >= 0) {
     182                rc = loader_add_inbox(ldr, "root", root);
     183                vfs_put(root);
     184                if (rc != EOK)
     185                        goto error;
     186        }
     187       
     188        if (fd_stdin >= 0) {
     189                rc = loader_add_inbox(ldr, "stdin", fd_stdin);
     190                if (rc != EOK)
     191                        goto error;
     192        }
     193       
     194        if (fd_stdout >= 0) {
     195                rc = loader_add_inbox(ldr, "stdout", fd_stdout);
     196                if (rc != EOK)
     197                        goto error;
     198        }
     199       
     200        if (fd_stderr >= 0) {
     201                rc = loader_add_inbox(ldr, "stderr", fd_stderr);
     202                if (rc != EOK)
     203                        goto error;
     204        }               
    185205       
    186206        /* Load the program. */
Note: See TracChangeset for help on using the changeset viewer.