Deleted Added
sdiff udiff text old ( 10955:9abf6a7c14ab ) new ( 11140:cf07f8bf58db )
full compact
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;

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

402 size_t bufsiz = p->getSyscallArg(tc, index);
403
404 BufferArg buf(bufPtr, bufsiz);
405
406 int result = -1;
407 if (path != "/proc/self/exe") {
408 result = readlink(path.c_str(), (char *)buf.bufferPtr(), bufsiz);
409 } else {
410 // readlink() will return the path of the binary given
411 // with the -c option, however it is possible that this
412 // will still result in incorrect behavior if one binary
413 // runs another, e.g., -c time -o "my_binary" where
414 // my_binary calls readlink(). this is a very unlikely case,
415 // so we issue a warning.
416 warn_once("readlink may yield unexpected results if multiple "
417 "binaries are used\n");
418 if (strlen(p->progName()) > bufsiz) {
419 // readlink will truncate the contents of the
420 // path to ensure it is no more than bufsiz
421 strncpy((char*)buf.bufferPtr(), p->progName(), bufsiz);
422 result = bufsiz;
423 } else {
424 // return the program's working path rather
425 // than the one for the gem5 binary itself.
426 strcpy((char*)buf.bufferPtr(), p->progName());
427 result = strlen((char*)buf.bufferPtr());
428 }
429 }
430
431 buf.copyOut(tc->getMemProxy());
432
433 return (result == -1) ? -errno : result;
434}
435
436SyscallReturn

--- 509 unchanged lines hidden ---