Lines Matching refs:path

58 static bool FindPciDevicePrefix(const std::string& path, std::string* result) {  in FindPciDevicePrefix()  argument
61 if (!StartsWith(path, "/devices/pci")) return false; in FindPciDevicePrefix()
68 auto end = path.find('/', start); in FindPciDevicePrefix()
71 end = path.find('/', end + 1); in FindPciDevicePrefix()
81 *result = path.substr(start, length); in FindPciDevicePrefix()
89 static bool FindVbdDevicePrefix(const std::string& path, std::string* result) { in FindVbdDevicePrefix() argument
92 if (!StartsWith(path, "/devices/vbd-")) return false; in FindVbdDevicePrefix()
99 auto end = path.find('/', start); in FindVbdDevicePrefix()
105 *result = path.substr(start, length); in FindVbdDevicePrefix()
113 static bool FindDmDevice(const std::string& path, std::string* name, std::string* uuid) { in FindDmDevice() argument
114 if (!StartsWith(path, "/devices/virtual/block/dm-")) return false; in FindDmDevice()
116 if (!ReadFileToString("/sys" + path + "/dm/name", name)) { in FindDmDevice()
119 ReadFileToString("/sys" + path + "/dm/uuid", uuid); in FindDmDevice()
150 bool Permissions::Match(const std::string& path) const { in Match()
151 if (prefix_) return StartsWith(path, name_); in Match()
152 if (wildcard_) return fnmatch(name_.c_str(), path.c_str(), FNM_PATHNAME) == 0; in Match()
153 return path == name_; in Match()
156 bool SysfsPermissions::MatchWithSubsystem(const std::string& path, in MatchWithSubsystem() argument
158 std::string path_basename = Basename(path); in MatchWithSubsystem()
163 return Match(path); in MatchWithSubsystem()
166 void SysfsPermissions::SetPermissions(const std::string& path) const { in SetPermissions()
167 std::string attribute_file = path + "/" + attribute_; in SetPermissions()
185 bool DeviceHandler::FindPlatformDevice(std::string path, std::string* platform_device_path) const { in FindPlatformDevice() argument
189 path.insert(0, sysfs_mount_point_); in FindPlatformDevice()
191 std::string directory = Dirname(path); in FindPlatformDevice()
204 auto last_slash = path.rfind('/'); in FindPlatformDevice()
207 path.erase(last_slash); in FindPlatformDevice()
208 directory = Dirname(path); in FindPlatformDevice()
218 std::string path = "/sys" + upath; in FixupSysPermissions() local
221 if (s.MatchWithSubsystem(path, subsystem)) s.SetPermissions(path); in FixupSysPermissions()
224 if (!skip_restorecon_ && access(path.c_str(), F_OK) == 0) { in FixupSysPermissions()
225 LOG(VERBOSE) << "restorecon_recursive: " << path; in FixupSysPermissions()
226 if (selinux_android_restorecon(path.c_str(), SELINUX_ANDROID_RESTORECON_RECURSE) != 0) { in FixupSysPermissions()
227 PLOG(ERROR) << "selinux_android_restorecon(" << path << ") failed"; in FixupSysPermissions()
233 const std::string& path, const std::vector<std::string>& links) const { in GetDevicePermissions() argument
236 if (it->Match(path) || std::any_of(links.cbegin(), links.cend(), in GetDevicePermissions()
245 void DeviceHandler::MakeDevice(const std::string& path, bool block, int major, int minor, in MakeDevice() argument
247 auto[mode, uid, gid] = GetDevicePermissions(path, links); in MakeDevice()
251 if (!SelabelLookupFileContextBestMatch(path, links, mode, &secontext)) { in MakeDevice()
252 PLOG(ERROR) << "Device '" << path << "' not created; cannot find SELinux label"; in MakeDevice()
266 PLOG(ERROR) << "setegid(" << gid << ") for " << path << " device failed"; in MakeDevice()
271 if (mknod(path.c_str(), mode, dev) && (errno == EEXIST) && !secontext.empty()) { in MakeDevice()
273 int rc = lgetfilecon(path.c_str(), &fcon); in MakeDevice()
275 PLOG(ERROR) << "Cannot get SELinux label on '" << path << "' device"; in MakeDevice()
282 if (different && lsetfilecon(path.c_str(), secontext.c_str())) { in MakeDevice()
283 PLOG(ERROR) << "Cannot set '" << secontext << "' SELinux label on '" << path in MakeDevice()
289 chown(path.c_str(), uid, -1); in MakeDevice()
322 if (FindPlatformDevice(uevent.path, &device)) { in GetBlockDeviceSymlinks()
334 } else if (FindPciDevicePrefix(uevent.path, &device)) { in GetBlockDeviceSymlinks()
336 } else if (FindVbdDevicePrefix(uevent.path, &device)) { in GetBlockDeviceSymlinks()
338 } else if (FindDmDevice(uevent.path, &partition, &uuid)) { in GetBlockDeviceSymlinks()
373 auto last_slash = uevent.path.rfind('/'); in GetBlockDeviceSymlinks()
374 links.emplace_back(link_path + "/" + uevent.path.substr(last_slash + 1)); in GetBlockDeviceSymlinks()
398 auto path = dir + "/" + dp->d_name; in RemoveDeviceMapperLinks() local
399 if (Readlink(path, &link_path) && link_path == devpath) { in RemoveDeviceMapperLinks()
400 unlink(path.c_str()); in RemoveDeviceMapperLinks()
457 dup_ashmem_uevent.path += boot_id; in HandleAshmemUevent()
464 FixupSysPermissions(uevent.path, uevent.subsystem); in HandleUevent()
476 devpath = "/dev/block/" + Basename(uevent.path); in HandleUevent()
478 if (StartsWith(uevent.path, "/devices")) { in HandleUevent()
500 devpath = "/dev/" + Basename(uevent.path); in HandleUevent()