static void fcopy_send_data(struct work_struct *dummy) { struct hv_start_fcopy *smsg_out = NULL; int operation = fcopy_transaction.fcopy_msg->operation; struct hv_start_fcopy *smsg_in; void *out_src; int rc, out_len; /* * The strings sent from the host are encoded in * in utf16; convert it to utf8 strings. * The host assures us that the utf16 strings will not exceed * the max lengths specified. We will however, reserve room * for the string terminating character - in the utf16s_utf8s() * function we limit the size of the buffer where the converted * string is placed to W_MAX_PATH -1 to guarantee * that the strings can be properly terminated! */ switch (operation) { case START_FILE_COPY: out_len = sizeof(struct hv_start_fcopy); smsg_out = kzalloc(sizeof(*smsg_out), GFP_KERNEL); if (!smsg_out) return; smsg_out->hdr.operation = operation; smsg_in = (struct hv_start_fcopy *)fcopy_transaction.fcopy_msg; utf16s_to_utf8s((wchar_t *)smsg_in->file_name, W_MAX_PATH, UTF16_LITTLE_ENDIAN, (__u8 *)&smsg_out->file_name, W_MAX_PATH - 1); utf16s_to_utf8s((wchar_t *)smsg_in->path_name, W_MAX_PATH, UTF16_LITTLE_ENDIAN, (__u8 *)&smsg_out->path_name, W_MAX_PATH - 1); smsg_out->copy_flags = smsg_in->copy_flags; smsg_out->file_size = smsg_in->file_size; out_src = smsg_out; break; default: out_src = fcopy_transaction.fcopy_msg; out_len = fcopy_transaction.recv_len; break; } fcopy_transaction.state = HVUTIL_USERSPACE_REQ; rc = hvutil_transport_send(hvt, out_src, out_len, NULL); if (rc) { pr_debug("FCP: failed to communicate to the daemon: %d\n", rc); if (cancel_delayed_work_sync(&fcopy_timeout_work)) { fcopy_respond_to_host(HV_E_FAIL); fcopy_transaction.state = HVUTIL_READY; } } kfree(smsg_out); }
static void process_ib_ipinfo(void *in_msg, void *out_msg, int op) { struct hv_kvp_ip_msg *in = in_msg; struct hv_kvp_msg *out = out_msg; switch (op) { case KVP_OP_SET_IP_INFO: /* * Transform all parameters into utf8 encoding. */ utf16s_to_utf8s((wchar_t *)in->kvp_ip_val.ip_addr, MAX_IP_ADDR_SIZE, UTF16_LITTLE_ENDIAN, (__u8 *)out->body.kvp_ip_val.ip_addr, MAX_IP_ADDR_SIZE); utf16s_to_utf8s((wchar_t *)in->kvp_ip_val.sub_net, MAX_IP_ADDR_SIZE, UTF16_LITTLE_ENDIAN, (__u8 *)out->body.kvp_ip_val.sub_net, MAX_IP_ADDR_SIZE); utf16s_to_utf8s((wchar_t *)in->kvp_ip_val.gate_way, MAX_GATEWAY_SIZE, UTF16_LITTLE_ENDIAN, (__u8 *)out->body.kvp_ip_val.gate_way, MAX_GATEWAY_SIZE); utf16s_to_utf8s((wchar_t *)in->kvp_ip_val.dns_addr, MAX_IP_ADDR_SIZE, UTF16_LITTLE_ENDIAN, (__u8 *)out->body.kvp_ip_val.dns_addr, MAX_IP_ADDR_SIZE); out->body.kvp_ip_val.dhcp_enabled = in->kvp_ip_val.dhcp_enabled; /* fallthrough */ case KVP_OP_GET_IP_INFO: utf16s_to_utf8s((wchar_t *)in->kvp_ip_val.adapter_id, MAX_ADAPTER_ID_SIZE, UTF16_LITTLE_ENDIAN, (__u8 *)out->body.kvp_ip_val.adapter_id, MAX_ADAPTER_ID_SIZE); out->body.kvp_ip_val.addr_family = in->kvp_ip_val.addr_family; } }
static bool is_extended_socket_device(struct acpi_device *device) { struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL}; char str_buf[sizeof(FJES_ACPI_SYMBOL) + 1]; union acpi_object *str; acpi_status status; int result; status = acpi_evaluate_object(device->handle, "_STR", NULL, &buffer); if (ACPI_FAILURE(status)) return false; str = buffer.pointer; result = utf16s_to_utf8s((wchar_t *)str->string.pointer, str->string.length, UTF16_LITTLE_ENDIAN, str_buf, sizeof(str_buf) - 1); str_buf[result] = 0; if (strncmp(FJES_ACPI_SYMBOL, str_buf, strlen(FJES_ACPI_SYMBOL)) != 0) { kfree(buffer.pointer); return false; } kfree(buffer.pointer); return true; }
void nls_uniname_to_cstring(struct super_block *sb, u8 *p_cstring, UNI_NAME_T *p_uniname) { int i, j, len; u8 buf[MAX_CHARSET_SIZE]; u16 *uniname = p_uniname->name; struct nls_table *nls = EXFAT_SB(sb)->nls_io; if (nls == NULL) { len = utf16s_to_utf8s(uniname, MAX_NAME_LENGTH, UTF16_HOST_ENDIAN, p_cstring, MAX_NAME_LENGTH); p_cstring[len] = 0; return; } i = 0; while (i < (MAX_NAME_LENGTH-1)) { if (*uniname == (u16) '\0') break; len = convert_uni_to_ch(nls, buf, *uniname, NULL); if (len > 1) { for (j = 0; j < len; j++) *p_cstring++ = (char) *(buf+j); } else { /* len == 1 */ *p_cstring++ = (char) *buf; } uniname++; i++; } *p_cstring = '\0'; } /* end of nls_uniname_to_cstring */
static void dsm_label_utf16s_to_utf8s(union acpi_object *obj, char *buf) { int len; len = utf16s_to_utf8s((const wchar_t *)obj->buffer.pointer, obj->buffer.length, UTF16_LITTLE_ENDIAN, buf, PAGE_SIZE); buf[len] = '\n'; }
void asusnls_c2u(char *name) { #ifdef CONFIG_NLS char *codepage; char *xfrstr; struct nls_table *nls; int ret; strcpy(codebuf, name); codepage=codebuf+strlen(NLS_NVRAM_C2U); if((xfrstr=strchr(codepage, '_'))) { *xfrstr=NULL; xfrstr++; strcpy(name, ""); nls=load_nls(codepage); if(!nls) { printk("NLS table is null!!\n"); } else { int charlen; int i; int len = strlen(xfrstr); for (i = 0; len && *xfrstr; i++, xfrstr += charlen, len -= charlen) { /* string to unicode */ charlen = nls->char2uni(xfrstr, len, &unibuf[i]); if (charlen < 1) { strcpy(name ,""); unload_nls(nls); return; } } unibuf[i] = 0; //ret=utf8_wcstombs(name, unibuf, 1024); /* unicode to utf-8, 1024 is size of array unibuf */ ret=utf16s_to_utf8s(unibuf, i, UTF16_HOST_ENDIAN, name, 1024); /* unicode to utf-8, 1024 is size of array unibuf */ name[ret]=0; unload_nls(nls); if(!ret) { printk("can not xfr from %s to utf8\n", codepage); strcpy(name, ""); } } } else { strcpy(name, ""); } #endif }
/** * efi_partition(struct parsed_partitions *state) * @state * * Description: called from check.c, if the disk contains GPT * partitions, sets up partition entries in the kernel. * * If the first block on the disk is a legacy MBR, * it will get handled by msdos_partition(). * If it's a Protective MBR, we'll handle it here. * * We do not create a Linux partition for GPT, but * only for the actual data partitions. * Returns: * -1 if unable to read the partition table * 0 if this isn't our partition table * 1 if successful * */ int efi_partition(struct parsed_partitions *state) { gpt_header *gpt = NULL; gpt_entry *ptes = NULL; u32 i; unsigned ssz = bdev_logical_block_size(state->bdev) / 512; if (!find_valid_gpt(state, &gpt, &ptes) || !gpt || !ptes) { kfree(gpt); kfree(ptes); return 0; } pr_debug("GUID Partition Table is valid! Yea!\n"); for (i = 0; i < le32_to_cpu(gpt->num_partition_entries) && i < state->limit-1; i++) { u64 start = le64_to_cpu(ptes[i].starting_lba); u64 size = le64_to_cpu(ptes[i].ending_lba) - le64_to_cpu(ptes[i].starting_lba) + 1ULL; u8 name[sizeof(ptes->partition_name) / sizeof(efi_char16_t)]; int len; if (!is_pte_valid(&ptes[i], last_lba(state->bdev))) continue; len = utf16s_to_utf8s(ptes[i].partition_name, sizeof(ptes[i].partition_name) / sizeof(efi_char16_t), UTF16_LITTLE_ENDIAN, name, sizeof(name)); put_named_partition(state, i+1, start * ssz, size * ssz, name, len); /* If this is a RAID volume, tell md */ if (!efi_guidcmp(ptes[i].partition_type_guid, PARTITION_LINUX_RAID_GUID)) state->parts[i + 1].flags = ADDPART_FLAG_RAID; } kfree(ptes); kfree(gpt); strlcat(state->pp_buf, "\n", PAGE_SIZE); return 1; }
static int fjes_acpi_add(struct acpi_device *device) { struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL}; char str_buf[sizeof(FJES_ACPI_SYMBOL) + 1]; struct platform_device *plat_dev; union acpi_object *str; acpi_status status; int result; status = acpi_evaluate_object(device->handle, "_STR", NULL, &buffer); if (ACPI_FAILURE(status)) return -ENODEV; str = buffer.pointer; result = utf16s_to_utf8s((wchar_t *)str->string.pointer, str->string.length, UTF16_LITTLE_ENDIAN, str_buf, sizeof(str_buf) - 1); str_buf[result] = 0; if (strncmp(FJES_ACPI_SYMBOL, str_buf, strlen(FJES_ACPI_SYMBOL)) != 0) { kfree(buffer.pointer); return -ENODEV; } kfree(buffer.pointer); status = acpi_walk_resources(device->handle, METHOD_NAME__CRS, fjes_get_acpi_resource, fjes_resource); if (ACPI_FAILURE(status)) return -ENODEV; /* create platform_device */ plat_dev = platform_device_register_simple(DRV_NAME, 0, fjes_resource, ARRAY_SIZE(fjes_resource)); device->driver_data = plat_dev; return 0; }
/* * cifs_mapchar - convert a host-endian char to proper char in codepage * @target - where converted character should be copied * @src_char - 2 byte host-endian source character * @cp - codepage to which character should be converted * @map_type - How should the 7 NTFS/SMB reserved characters be mapped to UCS2? * * This function handles the conversion of a single character. It is the * responsibility of the caller to ensure that the target buffer is large * enough to hold the result of the conversion (at least NLS_MAX_CHARSET_SIZE). */ static int cifs_mapchar(char *target, const __u16 *from, const struct nls_table *cp, int maptype) { int len = 1; __u16 src_char; src_char = *from; if ((maptype == SFM_MAP_UNI_RSVD) && convert_sfm_char(src_char, target)) return len; else if ((maptype == SFU_MAP_UNI_RSVD) && convert_sfu_char(src_char, target)) return len; /* if character not one of seven in special remap set */ len = cp->uni2char(src_char, target, NLS_MAX_CHARSET_SIZE); if (len <= 0) goto surrogate_pair; return len; surrogate_pair: /* convert SURROGATE_PAIR and IVS */ if (strcmp(cp->charset, "utf8")) goto unknown; len = utf16s_to_utf8s(from, 3, UTF16_LITTLE_ENDIAN, target, 6); if (len <= 0) goto unknown; return len; unknown: *target = '?'; len = 1; return len; }
static void kvp_send_key(struct work_struct *dummy) { struct cn_msg *msg; struct hv_kvp_msg *message; struct hv_kvp_msg *in_msg; __u8 operation = kvp_transaction.kvp_msg->kvp_hdr.operation; __u8 pool = kvp_transaction.kvp_msg->kvp_hdr.pool; __u32 val32; __u64 val64; msg = kzalloc(sizeof(*msg) + sizeof(struct hv_kvp_msg) , GFP_ATOMIC); if (!msg) return; msg->id.idx = CN_KVP_IDX; msg->id.val = CN_KVP_VAL; message = (struct hv_kvp_msg *)msg->data; message->kvp_hdr.operation = operation; message->kvp_hdr.pool = pool; in_msg = kvp_transaction.kvp_msg; /* * The key/value strings sent from the host are encoded in * in utf16; convert it to utf8 strings. * The host assures us that the utf16 strings will not exceed * the max lengths specified. We will however, reserve room * for the string terminating character - in the utf16s_utf8s() * function we limit the size of the buffer where the converted * string is placed to HV_KVP_EXCHANGE_MAX_*_SIZE -1 to gaurantee * that the strings can be properly terminated! */ switch (message->kvp_hdr.operation) { case KVP_OP_SET_IP_INFO: process_ib_ipinfo(in_msg, message, KVP_OP_SET_IP_INFO); break; case KVP_OP_GET_IP_INFO: process_ib_ipinfo(in_msg, message, KVP_OP_GET_IP_INFO); break; case KVP_OP_SET: switch (in_msg->body.kvp_set.data.value_type) { case REG_SZ: /* * The value is a string - utf16 encoding. */ message->body.kvp_set.data.value_size = utf16s_to_utf8s( (wchar_t *)in_msg->body.kvp_set.data.value, in_msg->body.kvp_set.data.value_size, UTF16_LITTLE_ENDIAN, message->body.kvp_set.data.value, HV_KVP_EXCHANGE_MAX_VALUE_SIZE - 1) + 1; break; case REG_U32: /* * The value is a 32 bit scalar. * We save this as a utf8 string. */ val32 = in_msg->body.kvp_set.data.value_u32; message->body.kvp_set.data.value_size = sprintf(message->body.kvp_set.data.value, "%d", val32) + 1; break; case REG_U64: /* * The value is a 64 bit scalar. * We save this as a utf8 string. */ val64 = in_msg->body.kvp_set.data.value_u64; message->body.kvp_set.data.value_size = sprintf(message->body.kvp_set.data.value, "%llu", val64) + 1; break; } case KVP_OP_GET: message->body.kvp_set.data.key_size = utf16s_to_utf8s( (wchar_t *)in_msg->body.kvp_set.data.key, in_msg->body.kvp_set.data.key_size, UTF16_LITTLE_ENDIAN, message->body.kvp_set.data.key, HV_KVP_EXCHANGE_MAX_KEY_SIZE - 1) + 1; break; case KVP_OP_DELETE: message->body.kvp_delete.key_size = utf16s_to_utf8s( (wchar_t *)in_msg->body.kvp_delete.key, in_msg->body.kvp_delete.key_size, UTF16_LITTLE_ENDIAN, message->body.kvp_delete.key, HV_KVP_EXCHANGE_MAX_KEY_SIZE - 1) + 1; break; case KVP_OP_ENUMERATE: message->body.kvp_enum_data.index = in_msg->body.kvp_enum_data.index; break; } msg->len = sizeof(struct hv_kvp_msg); cn_netlink_send(msg, 0, GFP_ATOMIC); kfree(msg); return; }
static void kvp_send_key(struct work_struct *dummy) { struct hv_kvp_msg *message; struct hv_kvp_msg *in_msg; __u8 operation = kvp_transaction.kvp_msg->kvp_hdr.operation; __u8 pool = kvp_transaction.kvp_msg->kvp_hdr.pool; __u32 val32; __u64 val64; int rc; /* The transaction state is wrong. */ if (kvp_transaction.state != HVUTIL_HOSTMSG_RECEIVED) return; message = kzalloc(sizeof(*message), GFP_KERNEL); if (!message) return; message->kvp_hdr.operation = operation; message->kvp_hdr.pool = pool; in_msg = kvp_transaction.kvp_msg; /* * The key/value strings sent from the host are encoded in * in utf16; convert it to utf8 strings. * The host assures us that the utf16 strings will not exceed * the max lengths specified. We will however, reserve room * for the string terminating character - in the utf16s_utf8s() * function we limit the size of the buffer where the converted * string is placed to HV_KVP_EXCHANGE_MAX_*_SIZE -1 to gaurantee * that the strings can be properly terminated! */ switch (message->kvp_hdr.operation) { case KVP_OP_SET_IP_INFO: process_ib_ipinfo(in_msg, message, KVP_OP_SET_IP_INFO); break; case KVP_OP_GET_IP_INFO: process_ib_ipinfo(in_msg, message, KVP_OP_GET_IP_INFO); break; case KVP_OP_SET: switch (in_msg->body.kvp_set.data.value_type) { case REG_SZ: /* * The value is a string - utf16 encoding. */ message->body.kvp_set.data.value_size = utf16s_to_utf8s( (wchar_t *)in_msg->body.kvp_set.data.value, in_msg->body.kvp_set.data.value_size, UTF16_LITTLE_ENDIAN, message->body.kvp_set.data.value, HV_KVP_EXCHANGE_MAX_VALUE_SIZE - 1) + 1; break; case REG_U32: /* * The value is a 32 bit scalar. * We save this as a utf8 string. */ val32 = in_msg->body.kvp_set.data.value_u32; message->body.kvp_set.data.value_size = sprintf(message->body.kvp_set.data.value, "%d", val32) + 1; break; case REG_U64: /* * The value is a 64 bit scalar. * We save this as a utf8 string. */ val64 = in_msg->body.kvp_set.data.value_u64; message->body.kvp_set.data.value_size = sprintf(message->body.kvp_set.data.value, "%llu", val64) + 1; break; } case KVP_OP_GET: message->body.kvp_set.data.key_size = utf16s_to_utf8s( (wchar_t *)in_msg->body.kvp_set.data.key, in_msg->body.kvp_set.data.key_size, UTF16_LITTLE_ENDIAN, message->body.kvp_set.data.key, HV_KVP_EXCHANGE_MAX_KEY_SIZE - 1) + 1; break; case KVP_OP_DELETE: message->body.kvp_delete.key_size = utf16s_to_utf8s( (wchar_t *)in_msg->body.kvp_delete.key, in_msg->body.kvp_delete.key_size, UTF16_LITTLE_ENDIAN, message->body.kvp_delete.key, HV_KVP_EXCHANGE_MAX_KEY_SIZE - 1) + 1; break; case KVP_OP_ENUMERATE: message->body.kvp_enum_data.index = in_msg->body.kvp_enum_data.index; break; } kvp_transaction.state = HVUTIL_USERSPACE_REQ; rc = hvutil_transport_send(hvt, message, sizeof(*message)); if (rc) { pr_debug("KVP: failed to communicate to the daemon: %d\n", rc); if (cancel_delayed_work_sync(&kvp_timeout_work)) { kvp_respond_to_host(message, HV_E_FAIL); kvp_transaction.state = HVUTIL_READY; } } kfree(message); return; }
/** * efi_partition(struct parsed_partitions *state) * @state * * Description: called from check.c, if the disk contains GPT * partitions, sets up partition entries in the kernel. * * If the first block on the disk is a legacy MBR, * it will get handled by msdos_partition(). * If it's a Protective MBR, we'll handle it here. * * We do not create a Linux partition for GPT, but * only for the actual data partitions. * Returns: * -1 if unable to read the partition table * 0 if this isn't our partition table * 1 if successful * */ int efi_partition(struct parsed_partitions *state) { char* partition_name = NULL; gpt_header *gpt = NULL; gpt_entry *ptes = NULL; u32 i; unsigned ssz = bdev_logical_block_size(state->bdev) / 512; partition_name = kzalloc(sizeof(ptes->partition_name), GFP_KERNEL); if (!partition_name) return 0; if (!find_valid_gpt(state, &gpt, &ptes) || !gpt || !ptes) { kfree(gpt); kfree(ptes); kfree(partition_name); return 0; } pr_debug("GUID Partition Table is valid! Yea!\n"); proc_create("emmc", 0666, NULL, &emmc_partition_fops); gpt_info.num_of_partitions = le32_to_cpu(gpt->num_partition_entries); gpt_info.erase_size = bdev_erase_size(state->bdev) * ssz; /* * Not certain if there is a chance this function is called again with * a different GPT. In case there is, free previously allocated memory */ kfree(gpt_info.partitions); gpt_info.partitions = kzalloc(gpt_info.num_of_partitions * sizeof(*gpt_info.partitions), GFP_KERNEL); for (i = 0; i < le32_to_cpu(gpt->num_partition_entries) && i < state->limit-1; i++) { int partition_name_len; struct partition_meta_info *info; unsigned label_count = 0; unsigned label_max; u64 start = le64_to_cpu(ptes[i].starting_lba); u64 size = le64_to_cpu(ptes[i].ending_lba) - le64_to_cpu(ptes[i].starting_lba) + 1ULL; gpt_info.partitions[i].size = size * ssz; if (!is_pte_valid(&ptes[i], last_lba(state->bdev))) continue; partition_name_len = utf16s_to_utf8s(ptes[i].partition_name, sizeof(ptes[i].partition_name), UTF16_LITTLE_ENDIAN, partition_name, sizeof(ptes[i].partition_name)); #ifdef CONFIG_APANIC_ON_MMC if(strncmp(partition_name,CONFIG_APANIC_PLABEL,partition_name_len) == 0) { apanic_partition_start = start * ssz; apanic_partition_size = size * ssz; pr_debug("apanic partition found starts at %lu \r\n", apanic_partition_start); pr_debug("apanic partition size = %lu\n", apanic_partition_size); } #endif put_partition(state, i+1, start * ssz, size * ssz); /* If this is a RAID volume, tell md */ if (!efi_guidcmp(ptes[i].partition_type_guid, PARTITION_LINUX_RAID_GUID)) state->parts[i + 1].flags = ADDPART_FLAG_RAID; info = &state->parts[i + 1].info; efi_guid_unparse(&ptes[i].unique_partition_guid, info->uuid); /* Naively convert UTF16-LE to 7 bits. */ label_max = min(sizeof(info->volname) - 1, sizeof(ptes[i].partition_name)); info->volname[label_max] = 0; while (label_count < label_max) { u8 c = ptes[i].partition_name[label_count] & 0xff; if (c && !isprint(c)) c = '!'; info->volname[label_count] = c; if (label_count <= partition_name_len) gpt_info.partitions[i].volname[label_count] = c; label_count++; } state->parts[i + 1].has_info = true; #ifdef CONFIG_APANIC_ON_MMC if(strncmp(info->volname,CONFIG_APANIC_PLABEL,label_count) == 0) { apanic_partition_start = start * ssz; pr_debug("apanic partition found starts at %lu \r\n", apanic_partition_start); } #endif } kfree(ptes); kfree(gpt); kfree(partition_name); strlcat(state->pp_buf, "\n", PAGE_SIZE); return 1; }
/** * efi_partition(struct parsed_partitions *state) * @state * * Description: called from check.c, if the disk contains GPT * partitions, sets up partition entries in the kernel. * * If the first block on the disk is a legacy MBR, * it will get handled by msdos_partition(). * If it's a Protective MBR, we'll handle it here. * * We do not create a Linux partition for GPT, but * only for the actual data partitions. * Returns: * -1 if unable to read the partition table * 0 if this isn't our partition table * 1 if successful * */ int efi_partition(struct parsed_partitions *state) { char* partition_name = NULL; gpt_header *gpt = NULL; gpt_entry *ptes = NULL; u32 i; unsigned ssz = bdev_logical_block_size(state->bdev) / 512; u8 unparsed_guid[37]; partition_name = kzalloc(sizeof(ptes->partition_name), GFP_KERNEL); if (!partition_name) return 0; if (!find_valid_gpt(state, &gpt, &ptes) || !gpt || !ptes) { kfree(gpt); kfree(ptes); kfree(partition_name); return 0; } pr_debug("GUID Partition Table is valid! Yea!\n"); for (i = 0; i < le32_to_cpu(gpt->num_partition_entries) && i < state->limit-1; i++) { int partition_name_len; struct partition_meta_info *info; unsigned label_count = 0; unsigned label_max; u64 start = le64_to_cpu(ptes[i].starting_lba); u64 size = le64_to_cpu(ptes[i].ending_lba) - le64_to_cpu(ptes[i].starting_lba) + 1ULL; if (!is_pte_valid(&ptes[i], last_lba(state->bdev))) continue; partition_name_len = utf16s_to_utf8s(ptes[i].partition_name, sizeof(ptes[i].partition_name), UTF16_LITTLE_ENDIAN, partition_name, sizeof(ptes[i].partition_name)); #ifdef CONFIG_APANIC_ON_MMC if(strncmp(partition_name,CONFIG_APANIC_PLABEL,partition_name_len) == 0) { apanic_partition_start = start * ssz; apanic_partition_size = size * ssz; pr_debug("apanic partition found starts at %lu \r\n", apanic_partition_start); pr_debug("apanic partition size = %lu\n", apanic_partition_size); } #endif put_partition(state, i+1, start * ssz, size * ssz); /* If this is a RAID volume, tell md */ if (!efi_guidcmp(ptes[i].partition_type_guid, PARTITION_LINUX_RAID_GUID)) state->parts[i + 1].flags = ADDPART_FLAG_RAID; info = &state->parts[i + 1].info; /* Instead of doing a manual swap to big endian, reuse the * common ASCII hex format as the interim. */ efi_guid_unparse(&ptes[i].unique_partition_guid, unparsed_guid); part_pack_uuid(unparsed_guid, info->uuid); /* Naively convert UTF16-LE to 7 bits. */ label_max = min(sizeof(info->volname) - 1, sizeof(ptes[i].partition_name)); info->volname[label_max] = 0; while (label_count < label_max) { u8 c = ptes[i].partition_name[label_count] & 0xff; if (c && !isprint(c)) c = '!'; info->volname[label_count] = c; label_count++; } state->parts[i + 1].has_info = true; #ifdef CONFIG_APANIC_ON_MMC if(strncmp(info->volname,CONFIG_APANIC_PLABEL,label_count) == 0) { apanic_partition_start = start * ssz; pr_debug("apanic partition found starts at %lu \r\n", apanic_partition_start); } #endif } kfree(ptes); kfree(gpt); kfree(partition_name); strlcat(state->pp_buf, "\n", PAGE_SIZE); return 1; }