Lines Matching refs:path

61 static bool FindPciDevicePrefix(const std::string& path, std::string* result) {  in FindPciDevicePrefix()  argument
64 if (!StartsWith(path, "/devices/pci")) return false; in FindPciDevicePrefix()
71 auto end = path.find('/', start); in FindPciDevicePrefix()
74 end = path.find('/', end + 1); in FindPciDevicePrefix()
84 *result = path.substr(start, length); in FindPciDevicePrefix()
92 static bool FindVbdDevicePrefix(const std::string& path, std::string* result) { in FindVbdDevicePrefix() argument
95 if (!StartsWith(path, "/devices/vbd-")) return false; in FindVbdDevicePrefix()
102 auto end = path.find('/', start); in FindVbdDevicePrefix()
108 *result = path.substr(start, length); in FindVbdDevicePrefix()
117 if (!StartsWith(uevent.path, "/devices/virtual/block/dm-")) return false; in FindDmDevice()
156 bool Permissions::Match(const std::string& path) const { in Match()
157 if (prefix_) return StartsWith(path, name_); in Match()
159 return fnmatch(name_.c_str(), path.c_str(), no_fnm_pathname_ ? 0 : FNM_PATHNAME) == 0; in Match()
160 return path == name_; in Match()
163 bool SysfsPermissions::MatchWithSubsystem(const std::string& path, in MatchWithSubsystem() argument
165 std::string path_basename = Basename(path); in MatchWithSubsystem()
170 return Match(path); in MatchWithSubsystem()
173 void SysfsPermissions::SetPermissions(const std::string& path) const { in SetPermissions()
174 std::string attribute_file = path + "/" + attribute_; in SetPermissions()
222 bool DeviceHandler::FindPlatformDevice(std::string path, std::string* platform_device_path) const { in FindPlatformDevice() argument
226 path.insert(0, sysfs_mount_point_); in FindPlatformDevice()
228 std::string directory = Dirname(path); in FindPlatformDevice()
241 auto last_slash = path.rfind('/'); in FindPlatformDevice()
244 path.erase(last_slash); in FindPlatformDevice()
245 directory = Dirname(path); in FindPlatformDevice()
255 std::string path = "/sys" + upath; in FixupSysPermissions() local
258 if (s.MatchWithSubsystem(path, subsystem)) s.SetPermissions(path); in FixupSysPermissions()
261 if (!skip_restorecon_ && access(path.c_str(), F_OK) == 0) { in FixupSysPermissions()
262 LOG(VERBOSE) << "restorecon_recursive: " << path; in FixupSysPermissions()
263 if (selinux_android_restorecon(path.c_str(), SELINUX_ANDROID_RESTORECON_RECURSE) != 0) { in FixupSysPermissions()
264 PLOG(ERROR) << "selinux_android_restorecon(" << path << ") failed"; in FixupSysPermissions()
270 const std::string& path, const std::vector<std::string>& links) const { in GetDevicePermissions() argument
273 if (it->Match(path) || std::any_of(links.cbegin(), links.cend(), in GetDevicePermissions()
282 void DeviceHandler::MakeDevice(const std::string& path, bool block, int major, int minor, in MakeDevice() argument
284 auto[mode, uid, gid] = GetDevicePermissions(path, links); in MakeDevice()
288 if (!SelabelLookupFileContextBestMatch(path, links, mode, &secontext)) { in MakeDevice()
289 PLOG(ERROR) << "Device '" << path << "' not created; cannot find SELinux label"; in MakeDevice()
305 PLOG(ERROR) << "setegid(" << gid << ") for " << path << " device failed"; in MakeDevice()
310 if (mknod(path.c_str(), mode, dev) && (errno == EEXIST) && !secontext.empty()) { in MakeDevice()
312 int rc = lgetfilecon(path.c_str(), &fcon); in MakeDevice()
314 PLOG(ERROR) << "Cannot get SELinux label on '" << path << "' device"; in MakeDevice()
321 if (different && lsetfilecon(path.c_str(), secontext.c_str())) { in MakeDevice()
322 PLOG(ERROR) << "Cannot set '" << secontext << "' SELinux label on '" << path in MakeDevice()
327 if (stat(path.c_str(), &s) == 0) { in MakeDevice()
332 if (chmod(path.c_str(), mode) != 0) { in MakeDevice()
333 PLOG(ERROR) << "Cannot chmod " << path << " to " << mode; in MakeDevice()
337 PLOG(ERROR) << "Cannot stat " << path; in MakeDevice()
342 if (chown(path.c_str(), uid, new_group) < 0) { in MakeDevice()
343 PLOG(ERROR) << "Cannot chown " << path << " " << uid << " " << new_group; in MakeDevice()
377 if (FindPlatformDevice(uevent.path, &device)) { in GetBlockDeviceSymlinks()
389 } else if (FindPciDevicePrefix(uevent.path, &device)) { in GetBlockDeviceSymlinks()
391 } else if (FindVbdDevicePrefix(uevent.path, &device)) { in GetBlockDeviceSymlinks()
438 auto last_slash = uevent.path.rfind('/'); in GetBlockDeviceSymlinks()
439 links.emplace_back(link_path + "/" + uevent.path.substr(last_slash + 1)); in GetBlockDeviceSymlinks()
463 auto path = dir + "/" + dp->d_name; in RemoveDeviceMapperLinks() local
464 if (Readlink(path, &link_path) && link_path == devpath) { in RemoveDeviceMapperLinks()
465 unlink(path.c_str()); in RemoveDeviceMapperLinks()
526 dup_ashmem_uevent.path += boot_id; in HandleAshmemUevent()
534 FixupSysPermissions(uevent.path, uevent.subsystem); in HandleUevent()
546 devpath = "/dev/block/" + Basename(uevent.path); in HandleUevent()
548 if (StartsWith(uevent.path, "/devices")) { in HandleUevent()
572 devpath = "/dev/" + Basename(uevent.path); in HandleUevent()