| Matt Spinler | 97f7abc | 2019-11-06 09:40:23 -0600 | [diff] [blame] | 1 | /** | 
 | 2 |  * Copyright © 2019 IBM Corporation | 
 | 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 |  */ | 
| Matt Spinler | df13bdb | 2019-07-10 16:54:13 -0500 | [diff] [blame] | 16 | #include "extensions/openpower-pels/paths.hpp" | 
 | 17 |  | 
 | 18 | #include <filesystem> | 
 | 19 |  | 
 | 20 | namespace openpower | 
 | 21 | { | 
 | 22 | namespace pels | 
 | 23 | { | 
 | 24 |  | 
 | 25 | // Use paths that work in unit tests. | 
 | 26 |  | 
 | 27 | std::filesystem::path getPELIDFile() | 
 | 28 | { | 
 | 29 |     static std::string idFile; | 
 | 30 |  | 
 | 31 |     if (idFile.empty()) | 
 | 32 |     { | 
 | 33 |         char templ[] = "/tmp/logidtestXXXXXX"; | 
 | 34 |         std::filesystem::path dir = mkdtemp(templ); | 
 | 35 |         idFile = dir / "logid"; | 
 | 36 |     } | 
 | 37 |     return idFile; | 
 | 38 | } | 
 | 39 |  | 
| Matt Spinler | 89fa082 | 2019-07-17 13:54:30 -0500 | [diff] [blame] | 40 | std::filesystem::path getPELRepoPath() | 
 | 41 | { | 
 | 42 |     static std::string repoPath; | 
 | 43 |  | 
 | 44 |     if (repoPath.empty()) | 
 | 45 |     { | 
 | 46 |         char templ[] = "/tmp/repopathtestXXXXXX"; | 
 | 47 |         std::filesystem::path dir = mkdtemp(templ); | 
 | 48 |         repoPath = dir; | 
 | 49 |     } | 
 | 50 |     return repoPath; | 
 | 51 | } | 
 | 52 |  | 
| Matt Spinler | 0d804ef | 2020-05-12 16:16:26 -0500 | [diff] [blame] | 53 | std::filesystem::path getPELReadOnlyDataPath() | 
| Matt Spinler | 367144c | 2019-09-19 15:33:52 -0500 | [diff] [blame] | 54 | { | 
| Matt Spinler | 0d804ef | 2020-05-12 16:16:26 -0500 | [diff] [blame] | 55 |     static std::string dataPath; | 
| Matt Spinler | 367144c | 2019-09-19 15:33:52 -0500 | [diff] [blame] | 56 |  | 
| Matt Spinler | 0d804ef | 2020-05-12 16:16:26 -0500 | [diff] [blame] | 57 |     if (dataPath.empty()) | 
| Matt Spinler | 367144c | 2019-09-19 15:33:52 -0500 | [diff] [blame] | 58 |     { | 
| Matt Spinler | 0d804ef | 2020-05-12 16:16:26 -0500 | [diff] [blame] | 59 |         char templ[] = "/tmp/pelrodatatestXXXXXX"; | 
 | 60 |         dataPath = mkdtemp(templ); | 
| Matt Spinler | 367144c | 2019-09-19 15:33:52 -0500 | [diff] [blame] | 61 |     } | 
 | 62 |  | 
| Matt Spinler | 0d804ef | 2020-05-12 16:16:26 -0500 | [diff] [blame] | 63 |     return dataPath; | 
| Matt Spinler | 367144c | 2019-09-19 15:33:52 -0500 | [diff] [blame] | 64 | } | 
 | 65 |  | 
| Matt Spinler | 8d5f3a2 | 2020-07-07 10:30:33 -0500 | [diff] [blame] | 66 | size_t getPELRepoSize() | 
 | 67 | { | 
 | 68 |     // 100KB | 
 | 69 |     return 100 * 1024; | 
 | 70 | } | 
 | 71 |  | 
 | 72 | size_t getMaxNumPELs() | 
 | 73 | { | 
 | 74 |     return 100; | 
 | 75 | } | 
 | 76 |  | 
| Matt Spinler | df13bdb | 2019-07-10 16:54:13 -0500 | [diff] [blame] | 77 | } // namespace pels | 
 | 78 | } // namespace openpower |