procpartition.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /*
  2. * Copyright (C) 2018 The Android Open Source Project
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #ifndef FRAMEWORK_NATIVE_CMDS_LSHAL_PROCPARTITION_H_
  17. #define FRAMEWORK_NATIVE_CMDS_LSHAL_PROCPARTITION_H_
  18. #include <sys/types.h>
  19. #include <string>
  20. #include <iostream>
  21. namespace android {
  22. namespace procpartition {
  23. enum class Partition {
  24. UNKNOWN = 0,
  25. SYSTEM,
  26. VENDOR,
  27. ODM
  28. };
  29. std::ostream& operator<<(std::ostream& os, Partition p);
  30. Partition parsePartition(const std::string& s);
  31. // Return the path that /proc/<pid>/exe points to.
  32. std::string getExe(pid_t pid);
  33. // Return the content of /proc/<pid>/cmdline.
  34. std::string getCmdline(pid_t pid);
  35. // Infer the partition of a process from /proc/<pid>/exe and /proc/<pid>/cmdline.
  36. Partition getPartition(pid_t pid);
  37. } // namespace procpartition
  38. } // namespace android
  39. #endif // FRAMEWORK_NATIVE_CMDS_LSHAL_PROCPARTITION_H_