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; --- 200 unchanged lines hidden (view full) --- 209SyscallReturn 210unlinkFunc(SyscallDesc *desc, int num, LiveProcess *p, ThreadContext *tc) 211{ 212 string path; 213 214 if (!tc->getMemPort()->tryReadString(path, tc->getSyscallArg(0))) 215 return (TheISA::IntReg)-EFAULT; 216 |
217 // Adjust path for current working directory 218 path = p->fullPath(path); 219 |
220 int result = unlink(path.c_str()); 221 return (result == -1) ? -errno : result; 222} 223 224SyscallReturn 225renameFunc(SyscallDesc *desc, int num, LiveProcess *p, ThreadContext *tc) 226{ 227 string old_name; 228 229 if (!tc->getMemPort()->tryReadString(old_name, tc->getSyscallArg(0))) 230 return -EFAULT; 231 232 string new_name; 233 234 if (!tc->getMemPort()->tryReadString(new_name, tc->getSyscallArg(1))) 235 return -EFAULT; 236 |
237 // Adjust path for current working directory 238 old_name = p->fullPath(old_name); 239 new_name = p->fullPath(new_name); 240 |
241 int64_t result = rename(old_name.c_str(), new_name.c_str()); 242 return (result == -1) ? -errno : result; 243} 244 245SyscallReturn 246truncateFunc(SyscallDesc *desc, int num, LiveProcess *p, ThreadContext *tc) 247{ 248 string path; 249 250 if (!tc->getMemPort()->tryReadString(path, tc->getSyscallArg(0))) 251 return -EFAULT; 252 253 off_t length = tc->getSyscallArg(1); 254 |
255 // Adjust path for current working directory 256 path = p->fullPath(path); 257 |
258 int result = truncate(path.c_str(), length); 259 return (result == -1) ? -errno : result; 260} 261 262SyscallReturn 263ftruncateFunc(SyscallDesc *desc, int num, LiveProcess *process, ThreadContext *tc) 264{ 265 int fd = process->sim_fd(tc->getSyscallArg(0)); --- 16 unchanged lines hidden (view full) --- 282 return -EFAULT; 283 284 /* XXX endianess */ 285 uint32_t owner = tc->getSyscallArg(1); 286 uid_t hostOwner = owner; 287 uint32_t group = tc->getSyscallArg(2); 288 gid_t hostGroup = group; 289 |
290 // Adjust path for current working directory 291 path = p->fullPath(path); 292 |
293 int result = chown(path.c_str(), hostOwner, hostGroup); 294 return (result == -1) ? -errno : result; 295} 296 297SyscallReturn 298fchownFunc(SyscallDesc *desc, int num, LiveProcess *process, ThreadContext *tc) 299{ 300 int fd = process->sim_fd(tc->getSyscallArg(0)); --- 214 unchanged lines hidden --- |