syscall_emul.cc (10203:3b9e1fa3da47) syscall_emul.cc (10223:34f48d0dac97)
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;

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

64 process->getSyscallArg(tc, index),
65 process->getSyscallArg(tc, index),
66 process->getSyscallArg(tc, index),
67 process->getSyscallArg(tc, index));
68
69 SyscallReturn retval = (*funcPtr)(this, callnum, process, tc);
70
71 DPRINTFR(SyscallVerbose, "%d: %s: syscall %s returns %d\n",
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;

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

64 process->getSyscallArg(tc, index),
65 process->getSyscallArg(tc, index),
66 process->getSyscallArg(tc, index),
67 process->getSyscallArg(tc, index));
68
69 SyscallReturn retval = (*funcPtr)(this, callnum, process, tc);
70
71 DPRINTFR(SyscallVerbose, "%d: %s: syscall %s returns %d\n",
72 curTick(),tc->getCpuPtr()->name(), name, retval.value());
72 curTick(), tc->getCpuPtr()->name(), name, retval.encodedValue());
73
74 if (!(flags & SyscallDesc::SuppressReturnValue))
75 process->setSyscallReturn(tc, retval);
76}
77
78
79SyscallReturn
80unimplementedFunc(SyscallDesc *desc, int callnum, LiveProcess *process,

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

361
362SyscallReturn
363readlinkFunc(SyscallDesc *desc, int num, LiveProcess *p, ThreadContext *tc,
364 int index)
365{
366 string path;
367
368 if (!tc->getMemProxy().tryReadString(path, p->getSyscallArg(tc, index)))
73
74 if (!(flags & SyscallDesc::SuppressReturnValue))
75 process->setSyscallReturn(tc, retval);
76}
77
78
79SyscallReturn
80unimplementedFunc(SyscallDesc *desc, int callnum, LiveProcess *process,

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

361
362SyscallReturn
363readlinkFunc(SyscallDesc *desc, int num, LiveProcess *p, ThreadContext *tc,
364 int index)
365{
366 string path;
367
368 if (!tc->getMemProxy().tryReadString(path, p->getSyscallArg(tc, index)))
369 return (TheISA::IntReg)-EFAULT;
369 return -EFAULT;
370
371 // Adjust path for current working directory
372 path = p->fullPath(path);
373
374 Addr bufPtr = p->getSyscallArg(tc, index);
375 size_t bufsiz = p->getSyscallArg(tc, index);
376
377 BufferArg buf(bufPtr, bufsiz);

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

385
386SyscallReturn
387unlinkFunc(SyscallDesc *desc, int num, LiveProcess *p, ThreadContext *tc)
388{
389 string path;
390
391 int index = 0;
392 if (!tc->getMemProxy().tryReadString(path, p->getSyscallArg(tc, index)))
370
371 // Adjust path for current working directory
372 path = p->fullPath(path);
373
374 Addr bufPtr = p->getSyscallArg(tc, index);
375 size_t bufsiz = p->getSyscallArg(tc, index);
376
377 BufferArg buf(bufPtr, bufsiz);

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

385
386SyscallReturn
387unlinkFunc(SyscallDesc *desc, int num, LiveProcess *p, ThreadContext *tc)
388{
389 string path;
390
391 int index = 0;
392 if (!tc->getMemProxy().tryReadString(path, p->getSyscallArg(tc, index)))
393 return (TheISA::IntReg)-EFAULT;
393 return -EFAULT;
394
395 // Adjust path for current working directory
396 path = p->fullPath(path);
397
398 int result = unlink(path.c_str());
399 return (result == -1) ? -errno : result;
400}
401
402
403SyscallReturn
404mkdirFunc(SyscallDesc *desc, int num, LiveProcess *p, ThreadContext *tc)
405{
406 string path;
407
408 int index = 0;
409 if (!tc->getMemProxy().tryReadString(path, p->getSyscallArg(tc, index)))
394
395 // Adjust path for current working directory
396 path = p->fullPath(path);
397
398 int result = unlink(path.c_str());
399 return (result == -1) ? -errno : result;
400}
401
402
403SyscallReturn
404mkdirFunc(SyscallDesc *desc, int num, LiveProcess *p, ThreadContext *tc)
405{
406 string path;
407
408 int index = 0;
409 if (!tc->getMemProxy().tryReadString(path, p->getSyscallArg(tc, index)))
410 return (TheISA::IntReg)-EFAULT;
410 return -EFAULT;
411
412 // Adjust path for current working directory
413 path = p->fullPath(path);
414
415 mode_t mode = p->getSyscallArg(tc, index);
416
417 int result = mkdir(path.c_str(), mode);
418 return (result == -1) ? -errno : result;

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

859}
860
861SyscallReturn
862accessFunc(SyscallDesc *desc, int callnum, LiveProcess *p, ThreadContext *tc,
863 int index)
864{
865 string path;
866 if (!tc->getMemProxy().tryReadString(path, p->getSyscallArg(tc, index)))
411
412 // Adjust path for current working directory
413 path = p->fullPath(path);
414
415 mode_t mode = p->getSyscallArg(tc, index);
416
417 int result = mkdir(path.c_str(), mode);
418 return (result == -1) ? -errno : result;

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

859}
860
861SyscallReturn
862accessFunc(SyscallDesc *desc, int callnum, LiveProcess *p, ThreadContext *tc,
863 int index)
864{
865 string path;
866 if (!tc->getMemProxy().tryReadString(path, p->getSyscallArg(tc, index)))
867 return (TheISA::IntReg)-EFAULT;
867 return -EFAULT;
868
869 // Adjust path for current working directory
870 path = p->fullPath(path);
871
872 mode_t mode = p->getSyscallArg(tc, index);
873
874 int result = access(path.c_str(), mode);
875 return (result == -1) ? -errno : result;
876}
877
878SyscallReturn
879accessFunc(SyscallDesc *desc, int callnum, LiveProcess *p, ThreadContext *tc)
880{
881 return accessFunc(desc, callnum, p, tc, 0);
882}
883
868
869 // Adjust path for current working directory
870 path = p->fullPath(path);
871
872 mode_t mode = p->getSyscallArg(tc, index);
873
874 int result = access(path.c_str(), mode);
875 return (result == -1) ? -errno : result;
876}
877
878SyscallReturn
879accessFunc(SyscallDesc *desc, int callnum, LiveProcess *p, ThreadContext *tc)
880{
881 return accessFunc(desc, callnum, p, tc, 0);
882}
883