Example #1
0
bool FileSys::Upward()
{
    if( callStack.size() - 1 < 1 )
        return false;
    else
    {
       callStack.pop_back();
       OpenDIR();
       return true;
    }
}
Example #2
0
File: ProcFS.cpp Project: cosql/ds2
bool ProcFS::EnumerateThreads(pid_t pid, std::function<void(pid_t)> const &cb) {
  DIR *dir = OpenDIR(pid, "task");
  if (dir == nullptr)
    return false;

  while (struct dirent *dp = readdir(dir)) {
    pid_t pid = strtol(dp->d_name, nullptr, 0);
    if (pid == 0)
      continue;

    cb(pid);
  }
  closedir(dir);

  return true;
}
Example #3
0
File: ProcFS.cpp Project: cosql/ds2
bool ProcFS::EnumerateProcesses(bool allUsers, uid_t uid,
                                std::function<void(pid_t, uid_t)> const &cb) {
  DIR *dir = OpenDIR("");
  if (dir == nullptr)
    return false;

  while (struct dirent *dp = readdir(dir)) {
    pid_t pid = strtol(dp->d_name, nullptr, 0);
    if (pid == 0)
      continue;

    //
    // Get the uid.
    //
    struct stat stbuf;
    char path[PATH_MAX + 1];
    MakePath(path, PATH_MAX, pid, "");
    if (stat(path, &stbuf) < 0)
      continue;

    //
    // Compare if necessary.
    //
    if (!allUsers && stbuf.st_uid != uid)
      continue;

    //
    // We don't want kernel threads, so exclude them from the list,
    // we know they are kernel threads because "exe" points to nothing.
    //
    if (GetProcessExecutablePath(pid).empty())
      continue;

    cb(pid, stbuf.st_uid);
  }
  closedir(dir);

  return true;
}
Example #4
0
File: ProcFS.cpp Project: cosql/ds2
DIR *ProcFS::OpenDIR(pid_t pid, char const *what) {
  return OpenDIR(pid, pid, what);
}
Example #5
0
void FileSys::SetDefaultDir()
{
    callStack.clear();
    callStack.push_back( "/home/user" );
    OpenDIR();
}