syscall_emul.cc (4118:ddd23e5282d7) | syscall_emul.cc (5282:2dba627b6646) |
---|---|
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)); | 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 | |
354 if (fd < 0) 355 return -EBADF; 356 | 353 if (fd < 0) 354 return -EBADF; 355 |
356 Process::FdMap *fdo = process->sim_fd_obj(tc->getSyscallArg(0)); 357 |
|
357 int result = dup(fd); | 358 int result = dup(fd); |
358 return (result == -1) ? -errno : process->alloc_fd(result); | 359 return (result == -1) ? -errno : process->alloc_fd(result, fdo->filename, fdo->flags, fdo->mode, false); |
359} 360 361 362SyscallReturn 363fcntlFunc(SyscallDesc *desc, int num, LiveProcess *process, 364 ThreadContext *tc) 365{ 366 int fd = tc->getSyscallArg(0); --- 70 unchanged lines hidden (view full) --- 437 int fds[2], sim_fds[2]; 438 int pipe_retval = pipe(fds); 439 440 if (pipe_retval < 0) { 441 // error 442 return pipe_retval; 443 } 444 | 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 |
445 sim_fds[0] = process->alloc_fd(fds[0]); 446 sim_fds[1] = process->alloc_fd(fds[1]); | 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); |
447 | 448 |
449 process->setReadPipeSource(sim_fds[0], sim_fds[1]); |
|
448 // Alpha Linux convention for pipe() is that fd[0] is returned as 449 // the return value of the function, and fd[1] is returned in r20. 450 tc->setIntReg(SyscallPseudoReturnReg, sim_fds[1]); 451 return sim_fds[0]; 452} 453 454 455SyscallReturn --- 92 unchanged lines hidden --- | 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 --- |