1/* 2 * Copyright (c) 2009 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; --- 29 unchanged lines hidden (view full) --- 38int 39Linux::openSpecialFile(std::string path, LiveProcess *process, ThreadContext *tc) 40{ 41 DPRINTF(SyscallVerbose, "Opening special file: %s\n", path.c_str()); 42 if (path.compare(0, 13, "/proc/meminfo") == 0) { 43 std::string data = Linux::procMeminfo(process, tc); 44 FILE *f = tmpfile(); 45 int fd = fileno(f); |
46 size_t ret M5_VAR_USED = fwrite(data.c_str(), 1, data.size(), f); |
47 assert(ret == data.size()); 48 rewind(f); 49 return fd; 50 } 51 52 warn("Attempting to open special file: %s. Ignorning. Simulation may" 53 " take un-expected code path or be non-deterministic until proper" 54 " handling is implemented.\n", path.c_str()); 55 return -1; 56} 57 58std::string 59Linux::procMeminfo(LiveProcess *process, ThreadContext *tc) 60{ 61 return csprintf("MemTotal:%12d kB\nMemFree: %12d kB\n", 62 process->system->memSize() >> 10, 63 process->system->freeMemSize() >> 10); 64} 65 |