syscall_emul.cc (10929:b2bbfec74eca) syscall_emul.cc (10930:ddc3d96d6313)
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;

--- 202 unchanged lines hidden (view full) ---

211{
212 int index = 0;
213 int target_fd = p->getSyscallArg(tc, index);
214 int sim_fd = p->sim_fd(target_fd);
215 int status = 0;
216 if (sim_fd > 2)
217 status = close(sim_fd);
218 if (status >= 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;

--- 202 unchanged lines hidden (view full) ---

211{
212 int index = 0;
213 int target_fd = p->getSyscallArg(tc, index);
214 int sim_fd = p->sim_fd(target_fd);
215 int status = 0;
216 if (sim_fd > 2)
217 status = close(sim_fd);
218 if (status >= 0)
219 p->free_fdmap_entry(target_fd);
219 p->reset_fd_entry(target_fd);
220 return status;
221}
222
223
224SyscallReturn
225readFunc(SyscallDesc *desc, int num, LiveProcess *p, ThreadContext *tc)
226{
227 int index = 0;

--- 364 unchanged lines hidden (view full) ---

592dupFunc(SyscallDesc *desc, int num, LiveProcess *process, ThreadContext *tc)
593{
594 int index = 0;
595 int tgt_fd = process->getSyscallArg(tc, index);
596 int sim_fd = process->sim_fd(tgt_fd);
597 if (sim_fd < 0)
598 return -EBADF;
599
220 return status;
221}
222
223
224SyscallReturn
225readFunc(SyscallDesc *desc, int num, LiveProcess *p, ThreadContext *tc)
226{
227 int index = 0;

--- 364 unchanged lines hidden (view full) ---

592dupFunc(SyscallDesc *desc, int num, LiveProcess *process, ThreadContext *tc)
593{
594 int index = 0;
595 int tgt_fd = process->getSyscallArg(tc, index);
596 int sim_fd = process->sim_fd(tgt_fd);
597 if (sim_fd < 0)
598 return -EBADF;
599
600 Process::FdMap *fdo = process->sim_fd_obj(tgt_fd);
600 FDEntry *fde = process->get_fd_entry(tgt_fd);
601
602 int result = dup(sim_fd);
603 return (result == -1) ? -errno :
601
602 int result = dup(sim_fd);
603 return (result == -1) ? -errno :
604 process->alloc_fd(result, fdo->filename, fdo->flags, fdo->mode, false);
604 process->alloc_fd(result, fde->filename, fde->flags, fde->mode, false);
605}
606
607
608SyscallReturn
609fcntlFunc(SyscallDesc *desc, int num, LiveProcess *process,
610 ThreadContext *tc)
611{
612 int index = 0;

--- 290 unchanged lines hidden ---
605}
606
607
608SyscallReturn
609fcntlFunc(SyscallDesc *desc, int num, LiveProcess *process,
610 ThreadContext *tc)
611{
612 int index = 0;

--- 290 unchanged lines hidden ---