San Mehat | 586536c | 2010-02-16 17:12:00 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2008 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 | |
| 17 | #ifndef _PROCESS_H |
| 18 | #define _PROCESS_H |
| 19 | |
jessica_yu | 3f14fe4 | 2014-09-22 15:57:40 +0800 | [diff] [blame] | 20 | #ifdef __cplusplus |
| 21 | |
San Mehat | 586536c | 2010-02-16 17:12:00 -0800 | [diff] [blame] | 22 | class Process { |
| 23 | public: |
Jeff Sharkey | 89f74fb | 2015-10-21 12:16:12 -0700 | [diff] [blame] | 24 | static int killProcessesWithOpenFiles(const char *path, int signal); |
San Mehat | 586536c | 2010-02-16 17:12:00 -0800 | [diff] [blame] | 25 | static int getPid(const char *s); |
| 26 | static int checkSymLink(int pid, const char *path, const char *name); |
| 27 | static int checkFileMaps(int pid, const char *path); |
| 28 | static int checkFileMaps(int pid, const char *path, char *openFilename, size_t max); |
| 29 | static int checkFileDescriptorSymLinks(int pid, const char *mountPoint); |
| 30 | static int checkFileDescriptorSymLinks(int pid, const char *mountPoint, char *openFilename, size_t max); |
Jeff Sharkey | 32ebb73 | 2017-03-27 16:18:50 -0600 | [diff] [blame] | 31 | static void getProcessName(int pid, std::string& out_name); |
San Mehat | 586536c | 2010-02-16 17:12:00 -0800 | [diff] [blame] | 32 | private: |
| 33 | static int readSymLink(const char *path, char *link, size_t max); |
| 34 | static int pathMatchesMountPoint(const char *path, const char *mountPoint); |
| 35 | }; |
| 36 | |
jessica_yu | 3f14fe4 | 2014-09-22 15:57:40 +0800 | [diff] [blame] | 37 | extern "C" { |
| 38 | #endif /* __cplusplus */ |
Jeff Sharkey | 36801cc | 2015-03-13 16:09:20 -0700 | [diff] [blame] | 39 | void vold_killProcessesWithOpenFiles(const char *path, int signal); |
jessica_yu | 3f14fe4 | 2014-09-22 15:57:40 +0800 | [diff] [blame] | 40 | #ifdef __cplusplus |
| 41 | } |
| 42 | #endif |
| 43 | |
San Mehat | 586536c | 2010-02-16 17:12:00 -0800 | [diff] [blame] | 44 | #endif |