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 17 #ifndef INCLUDE_PERFETTO_TRACED_DATA_SOURCE_TYPES_H_ 18 #define INCLUDE_PERFETTO_TRACED_DATA_SOURCE_TYPES_H_ 19 20 #include <sys/stat.h> 21 #include <sys/types.h> 22 #include <unistd.h> 23 #include <set> 24 #include <string> 25 26 #include "perfetto/trace/filesystem/inode_file_map.pbzero.h" 27 28 namespace perfetto { 29 30 // On ARM, st_ino is not ino_t but unsigned long long. 31 using Inode = decltype(stat::st_ino); 32 33 // On ARM, st_dev is not dev_t but unsigned long long. 34 using BlockDeviceID = decltype(stat::st_dev); 35 36 class InodeMapValue { 37 public: 38 InodeMapValue(protos::pbzero::InodeFileMap_Entry_Type entry_type, 39 std::set<std::string> paths) 40 : entry_type_(entry_type), paths_(std::move(paths)) {} 41 42 InodeMapValue() {} 43 44 protos::pbzero::InodeFileMap_Entry_Type type() const { return entry_type_; } 45 const std::set<std::string>& paths() const { return paths_; } 46 void SetType(protos::pbzero::InodeFileMap_Entry_Type entry_type) { 47 entry_type_ = entry_type; 48 } 49 void SetPaths(std::set<std::string> paths) { paths_ = std::move(paths); } 50 void AddPath(std::string path) { paths_.emplace(std::move(path)); } 51 52 bool operator==(const perfetto::InodeMapValue& rhs) const { 53 return type() == rhs.type() && paths() == rhs.paths(); 54 } 55 56 private: 57 protos::pbzero::InodeFileMap_Entry_Type entry_type_; 58 std::set<std::string> paths_; 59 }; 60 61 } // namespace perfetto 62 63 #endif // INCLUDE_PERFETTO_TRACED_DATA_SOURCE_TYPES_H_ 64