1/* 2 * Copyright (c) 2003-2005 The Regents of The University of Michigan 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are 7 * met: redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer; --- 336 unchanged lines hidden (view full) --- 345 return (result == -1) ? -errno : result; 346} 347 348 349SyscallReturn 350dupFunc(SyscallDesc *desc, int num, LiveProcess *process, ThreadContext *tc) 351{ 352 int fd = process->sim_fd(tc->getSyscallArg(0)); |
353 if (fd < 0) 354 return -EBADF; 355 |
356 Process::FdMap *fdo = process->sim_fd_obj(tc->getSyscallArg(0)); 357 |
358 int result = dup(fd); |
359 return (result == -1) ? -errno : process->alloc_fd(result, fdo->filename, fdo->flags, fdo->mode, false); |
360} 361 362 363SyscallReturn 364fcntlFunc(SyscallDesc *desc, int num, LiveProcess *process, 365 ThreadContext *tc) 366{ 367 int fd = tc->getSyscallArg(0); --- 70 unchanged lines hidden (view full) --- 438 int fds[2], sim_fds[2]; 439 int pipe_retval = pipe(fds); 440 441 if (pipe_retval < 0) { 442 // error 443 return pipe_retval; 444 } 445 |
446 sim_fds[0] = process->alloc_fd(fds[0], "PIPE-READ", O_WRONLY, -1, true); 447 sim_fds[1] = process->alloc_fd(fds[1], "PIPE-WRITE", O_RDONLY, -1, true); |
448 |
449 process->setReadPipeSource(sim_fds[0], sim_fds[1]); |
450 // Alpha Linux convention for pipe() is that fd[0] is returned as 451 // the return value of the function, and fd[1] is returned in r20. 452 tc->setIntReg(SyscallPseudoReturnReg, sim_fds[1]); 453 return sim_fds[0]; 454} 455 456 457SyscallReturn --- 92 unchanged lines hidden --- |