Пример #1
0
static ssize_t
efivar_show_raw(struct efivar_entry *entry, char *buf)
{
    struct efi_variable *var = &entry->var;
    struct compat_efi_variable *compat;
    size_t size;

    if (!entry || !buf)
        return 0;

    var->DataSize = 1024;
    if (efivar_entry_get(entry, &entry->var.Attributes,
                         &entry->var.DataSize, entry->var.Data))
        return -EIO;

    if (is_compat()) {
        compat = (struct compat_efi_variable *)buf;

        size = sizeof(*compat);
        memcpy(compat->VariableName, var->VariableName,
               EFI_VAR_NAME_LEN);
        memcpy(compat->Data, var->Data, sizeof(compat->Data));

        compat->VendorGuid = var->VendorGuid;
        compat->DataSize = var->DataSize;
        compat->Attributes = var->Attributes;
    } else {
        size = sizeof(*var);
        memcpy(buf, var, size);
    }

    return size;
}
Пример #2
0
static ssize_t
efivar_attr_read(struct efivar_entry *entry, char *buf)
{
    struct efi_variable *var = &entry->var;
    char *str = buf;

    if (!entry || !buf)
        return -EINVAL;

    var->DataSize = 1024;
    if (efivar_entry_get(entry, &var->Attributes, &var->DataSize, var->Data))
        return -EIO;

    if (var->Attributes & EFI_VARIABLE_NON_VOLATILE)
        str += sprintf(str, "EFI_VARIABLE_NON_VOLATILE\n");
    if (var->Attributes & EFI_VARIABLE_BOOTSERVICE_ACCESS)
        str += sprintf(str, "EFI_VARIABLE_BOOTSERVICE_ACCESS\n");
    if (var->Attributes & EFI_VARIABLE_RUNTIME_ACCESS)
        str += sprintf(str, "EFI_VARIABLE_RUNTIME_ACCESS\n");
    if (var->Attributes & EFI_VARIABLE_HARDWARE_ERROR_RECORD)
        str += sprintf(str, "EFI_VARIABLE_HARDWARE_ERROR_RECORD\n");
    if (var->Attributes & EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS)
        str += sprintf(str,
                       "EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS\n");
    if (var->Attributes &
            EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS)
        str += sprintf(str,
                       "EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS\n");
    if (var->Attributes & EFI_VARIABLE_APPEND_WRITE)
        str += sprintf(str, "EFI_VARIABLE_APPEND_WRITE\n");
    return str - buf;
}
Пример #3
0
static ssize_t
efivar_data_read(struct efivar_entry *entry, char *buf)
{
    struct efi_variable *var = &entry->var;

    if (!entry || !buf)
        return -EINVAL;

    var->DataSize = 1024;
    if (efivar_entry_get(entry, &var->Attributes, &var->DataSize, var->Data))
        return -EIO;

    memcpy(buf, var->Data, var->DataSize);
    return var->DataSize;
}
Пример #4
0
static ssize_t
efivar_size_read(struct efivar_entry *entry, char *buf)
{
    struct efi_variable *var = &entry->var;
    char *str = buf;

    if (!entry || !buf)
        return -EINVAL;

    var->DataSize = 1024;
    if (efivar_entry_get(entry, &var->Attributes, &var->DataSize, var->Data))
        return -EIO;

    str += sprintf(str, "0x%lx\n", var->DataSize);
    return str - buf;
}
Пример #5
0
static ssize_t
efivar_show_raw(struct efivar_entry *entry, char *buf)
{
	struct efi_variable *var = &entry->var;

	if (!entry || !buf)
		return 0;

	var->DataSize = 1024;
	if (efivar_entry_get(entry, &entry->var.Attributes,
			     &entry->var.DataSize, entry->var.Data))
		return -EIO;

	memcpy(buf, var, sizeof(*var));

	return sizeof(*var);
}
Пример #6
0
static ssize_t efivarfs_file_read(struct file *file, char __user *userbuf,
		size_t count, loff_t *ppos)
{
	struct efivar_entry *var = file->private_data;
	unsigned long datasize = 0;
	u32 attributes;
	void *data;
	ssize_t size = 0;
	int err;

	while (!__ratelimit(&file->f_cred->user->ratelimit)) {
		if (!msleep_interruptible(50))
			return -EINTR;
	}

	err = efivar_entry_size(var, &datasize);

	/*
	 * efivarfs represents uncommitted variables with
	 * zero-length files. Reading them should return EOF.
	 */
	if (err == -ENOENT)
		return 0;
	else if (err)
		return err;

	data = kmalloc(datasize + sizeof(attributes), GFP_KERNEL);

	if (!data)
		return -ENOMEM;

	size = efivar_entry_get(var, &attributes, &datasize,
				data + sizeof(attributes));
	if (size)
		goto out_free;

	memcpy(data, &attributes, sizeof(attributes));
	size = simple_read_from_buffer(userbuf, count, ppos,
				       data, datasize + sizeof(attributes));
out_free:
	kfree(data);

	return size;
}