Lines Matching refs:uevent
80 INIT_LOGE("[uevent] Failed to create dir \" %s \", err = %d", linkDir, errno);
117 INIT_LOGE("[uevent] Failed to memcpy path %s", path);
126 INIT_LOGE("[uevent] Failed to Restorecon \" %s \"", path);
148 static int CreateDeviceNode(const struct Uevent *uevent, const char *deviceNode, char **symLinks, bool isBlock)
151 int major = uevent->major;
152 int minor = uevent->minor;
153 uid_t uid = uevent->ug.uid;
154 gid_t gid = uevent->ug.gid;
300 static char **GetBlockDeviceSymbolLinks(const struct Uevent *uevent)
302 if (uevent == NULL || uevent->subsystem == NULL || STRINGEQUAL(uevent->subsystem, "block") == 0) {
307 // Only if current uevent is for real device.
308 if (!STARTSWITH(uevent->syspath, "/devices")) {
315 if (snprintf_s(sysPath, SYSPATH_SIZE, SYSPATH_SIZE - 1, "/sys%s", uevent->syspath) == -1) {
316 INIT_LOGE("Failed to build sys path for device %s", uevent->syspath);
331 INIT_LOGE("Failed to build subsystem path for device \" %s \"", uevent->syspath);
346 linkNum = BuildDeviceSymbolLinks(links, linkNum, parent, uevent->partitionName, uevent->deviceName);
358 static void HandleDeviceNode(const struct Uevent *uevent, const char *deviceNode, bool isBlock)
360 ACTION action = uevent->action;
367 symLinks = GetBlockDeviceSymbolLinks(uevent);
371 if (CreateDeviceNode(uevent, deviceNode, symLinks, isBlock) < 0) {
391 INIT_LOGV("Device %s changed", uevent->syspath);
453 void HandleBlockDeviceEvent(const struct Uevent *uevent)
456 if (uevent == NULL || uevent->subsystem == NULL) {
457 INIT_LOGE("Invalid uevent message received");
461 if (strcmp(uevent->subsystem, "block") != 0) {
462 INIT_LOGE("Unexpected uevent subsystem \" %s \" received in block device handler", uevent->subsystem);
466 if (uevent->major < 0 || uevent->minor < 0) {
472 const char *devPath = GetDeviceBasePath(uevent->subsystem);
476 if (uevent->syspath == NULL) {
479 if (strncpy_s(sysPath, SYSPATH_SIZE - 1, uevent->syspath, strlen(uevent->syspath) != EOK)) {
483 const char *devName = GetDeviceName(sysPath, uevent->deviceName);
490 INIT_LOGE("Make device file for device [%d : %d]", uevent->major, uevent->minor);
493 HandleDeviceNode(uevent, deviceNode, isBlock);
496 void HandleOtherDeviceEvent(const struct Uevent *uevent)
498 if (uevent == NULL || uevent->subsystem == NULL || uevent->syspath == NULL) {
499 INIT_LOGE("Invalid uevent received");
503 if (uevent->major < 0 || uevent->minor < 0) {
509 if (strncpy_s(sysPath, SYSPATH_SIZE - 1, uevent->syspath, strlen(uevent->syspath)) != EOK) {
513 const char *devName = GetDeviceName(sysPath, uevent->deviceName);
514 const char *devPath = GetDeviceBasePath(uevent->subsystem);
525 if (STRINGEQUAL(uevent->subsystem, "usb")) {
526 if (uevent->deviceName != NULL) {
527 if (snprintf_s(deviceNode, DEVICE_FILE_SIZE, DEVICE_FILE_SIZE - 1, "/dev/%s", uevent->deviceName) == -1) {
528 INIT_LOGE("Make device file for device [%d : %d]", uevent->major, uevent->minor);
532 if (uevent->busNum < 0 || uevent->devNum < 0) {
538 "/dev/bus/usb/%03d/%03d", uevent->busNum, uevent->devNum) == -1) {
539 INIT_LOGE("Make usb device node for device [%d : %d]", uevent->busNum, uevent->devNum);
542 } else if (STARTSWITH(uevent->subsystem, "usb")) {
546 if (strcmp(uevent->deviceName, "mapper/control") == 0) {
550 INIT_LOGE("Make device file for device [%d : %d]", uevent->major, uevent->minor);
554 HandleDeviceNode(uevent, deviceNode, false);