efivars update
Subsystems (3)
PATCH 1/1 efivars update
Hi,
A while back I posted a patch that moved the EFI variable services driver (efivars) to a new drivers/efi directory. As EFI driver are typically platform/architecturally independent, it seems like a good idea to collect them in a common place. Pat suggested the efivars driver should be converted to use sysfs rather than proc....so here you go. As such, this patch does several things:
+ Adds a new driver directory drivers/efi.
+ Adds a new generic config option for EFI drivers - CONFIG_EFI
+ Moves efivars from arch/ia64/kernel to drivers/efi
+ Allows EFI variables to be read/created/deleted/modified via sysfs
+ Bumps the driver revision level up to 0.07 to reflect these changes
Within the sysfs hierarchy, I've created an efi subsystem under which future
EFI related information might be exported. I've also created another subsystem vars that manages/exports EFI variable information.
Note, this patch relies upon the kobject_set_name() call recently introduced by Pat Mochel in order to export the long gvariable name-guid combinations needed to accurately identify variables of the same name.
The patch is against 2.6.0-test4. Please apply.
thanks,
matt
arch/ia64/defconfig +1 -0
@@ -76,6 +76,7 @@ CONFIG_COMPAT=y CONFIG_PERFMON=y CONFIG_IA64_PALINFO=y +CONFIG_EFI=y CONFIG_EFI_VARS=y CONFIG_NR_CPUS=16 CONFIG_BINFMT_ELF=y
arch/ia64/Kconfig +1 -9
@@ -433,15 +433,7 @@ To use this option, you have to ensure that the "/proc file system support" (CONFIG_PROC_FS) is enabled, too. -config EFI_VARS - tristate "/proc/efi/vars support" - help - If you say Y here, you are able to get EFI (Extensible Firmware - Interface) variable information in /proc/efi/vars. You may read, - write, create, and destroy EFI variables through this interface. - - To use this option, you have to check that the "/proc file system - support" (CONFIG_PROC_FS) is enabled, too. +source "drivers/efi/Kconfig" config NR_CPUS int "Maximum number of CPUs (2-64)"
arch/ia64/kernel/efivars.c +0 -508
508 lines not on this page · raw message
arch/ia64/kernel/Makefile +0 -1
@@ -8,7 +8,6 @@ irq_lsapic.o ivt.o machvec.o pal.o patch.o process.o perfmon.o ptrace.o sal.o \ semaphore.o setup.o signal.o sys_ia64.o time.o traps.o unaligned.o unwind.o -obj-$(CONFIG_EFI_VARS) += efivars.o obj-$(CONFIG_IA64_BRL_EMU) += brl_emu.o obj-$(CONFIG_IA64_GENERIC) += acpi-ext.o obj-$(CONFIG_IA64_HP_ZX1) += acpi-ext.o
drivers/efi/efivars.c +692 -0
692 lines not on this page · raw message
drivers/efi/Kconfig +23 -0
@@ -0,0 +1,23 @@ +# +# EFI Configuration +# + +menu "EFI Support" + +config EFI + bool "EFI Driver Support" + ---help--- + EFI (Extensible Firmware Interface) support for Linux enables + the use of drivers that provide architecturally independent + functionality. This support is applicable to architectures + that support EFI. + +config EFI_VARS + tristate "EFI Variable Support via sysfs" + ---help--- + If you say Y here, you are able to get EFI (Extensible Firmware + Interface) variable information via sysfs. You may read, + write, create, and destroy EFI variables through this interface. + + +endmenu
drivers/efi/Makefile +4 -0
@@ -0,0 +1,4 @@ +# EFI Variable Access + +obj-$(CONFIG_EFI_VARS) += efivars.o +
drivers/Makefile +1 -0
@@ -49,3 +49,4 @@ obj-$(CONFIG_MCA) += mca/ obj-$(CONFIG_EISA) += eisa/ obj-$(CONFIG_CPU_FREQ) += cpufreq/ +obj-$(CONFIG_EFI) += efi/
include/linux/efi.h +1 -0
@@ -16,6 +16,7 @@#include <linux/time.h> #include <linux/types.h> #include <linux/proc_fs.h> +#include <linux/kobject.h> #include <linux/rtc.h> #include <linux/ioport.h>
Quoted 11 lines
A while back I posted a patch that moved the EFI variable services driver (efivars) to a new
drivers/efidirectory. As EFI driver are typically platform/architecturally independent, it seems like a good idea to collect them in a common place. Pat suggested the efivars driver should be converted to use sysfs rather than proc....so here you go. As such, this patch does several things:+ Adds a new driver directory
drivers/efi.
+ Adds a new generic config option for EFI drivers -CONFIG_EFI
+ Moves efivars fromarch/ia64/kerneltodrivers/efi
+ Allows EFI variables to be read/created/deleted/modified via sysfs
+ Bumps the driver revision level up to 0.07 to reflect these changesWithin the sysfs hierarchy, I've created an efi subsystem under which future
EFI related information might be exported. I've also created another subsystem vars that manages/exports EFI variable information.
Hey, neat. :)
Would you mind posting the output of tree(1) of the sysfs hierarchy of one of the sytems?
Quoted 1 line
Note, this patch relies upon the
kobject_set_name()call recently introduced by Pat Mochel in order to export the long gvariable name-guid combinations needed to accurately identify variables of the same name.
That patch is below. I'll be sending it to Linus once he gets back from vacation, unless anyone has any serious objections to it. Note that it completely removes any limitation on the length of a kobject (and sysfs directory) name.
Pat
# This is a BitKeeper generated patch for the following project:
# Project Name: Linux kernel tree
# This patch format is intended for GNU patch command version 2.5 or higher. # This patch includes the following deltas:
# ChangeSet 1.1163 -> 1.1166
# include/linux/kobject.h 1.23 -> 1.24
# fs/sysfs/dir.c 1.10 -> 1.11
# lib/kobject.c 1.27 -> 1.28
#
# The following is the BitKeeper ChangeSet Log
# --------------------------------------------
# 03/08/29 [email protected] 1.1164
# [kobject] Support unlimited name lengths.
#
# Add ->k_name pointer which points to the name for a kobject. By default, this
# points to ->name (the static name array). # # Users of kobjects may use the helper function kobject_set_name() (and are # encouraged to do so in all cases). This function will determined whether or # not the name is short enough to fit in ->name. If so, great. # # Otherwise, a dyanamic string is allocated and the name is stored there. # ->k_name will point to that, and will be freed when the kobject is released. # # kobject_set_name() may take a format string, like: # # kobject_set_name(kobj,"%s%d",base_name,id); # # and will behave as expected (will put in ->name, unless it's too long, in # which case a new string will be allocated and it will be stored in there). # -------------------------------------------- # 03/08/29 [email protected] 1.1166 # [sysfs] Use kobject_name() when creating directories for kobjects. # -------------------------------------------- # diff -Nru a/fs/sysfs/dir.c b/fs/sysfs/dir.c --- a/fs/sysfs/dir.c Fri Aug 29 14:56:56 2003 +++ b/fs/sysfs/dir.c Fri Aug 29 14:56:56 2003 @@ -71,7 +71,7 @@ else return -EFAULT;
- dentry = create_dir(kobj,parent,kobj->name);
+ dentry = create_dir(kobj,parent,kobject_name(kobj));
if (!IS_ERR(dentry))
kobj->dentry = dentry;
else
@@ -158,7 +158,7 @@
{
struct dentry * new_dentry, * parent;
- if (!strcmp(kobj->name, new_name))
+ if (!strcmp(kobject_name(kobj), new_name))
return;
if (!kobj->parent)
@@ -170,9 +170,7 @@
new_dentry = sysfs_get_dentry(parent, new_name); d_move(kobj->dentry, new_dentry);
-
- strlcpy(kobj->name, new_name, KOBJ_NAME_LEN);
-
+ kobject_set_name(kobj,new_name);
up(&parent->d_inode->i_sem);
}
include/linux/kobject.h +9 -0
@@ -24,6 +24,7 @@#define KOBJ_NAME_LEN 20struct kobject { +char * k_name;char name[KOBJ_NAME_LEN ];atomic_t refcount;struct list_head entry;
@@ -32,6 +33,14 @@struct kobj_type * ktype;struct dentry * dentry; }; + +extern int kobject_set_name (struct kobject *,const char *, ...) + __attribute__((format (printf,2 ,3 ))); + +static inline char *kobject_name (struct kobject * kobj) +{ +return kobj->k_name; +}extern void kobject_init (struct kobject *);extern void kobject_cleanup (struct kobject *);
lib/kobject.c +65 -10
138 lines not on this page · raw message
Quoted 4 lines · Patrick Mochel
That patch is below. I'll be sending it to Linus once he gets back from vacation, unless anyone has any serious objections to it. Note that it completely removes any limitation on the length of a kobject (and sysfs directory) name.
Why keep another copy of the name? Why not use kobj->dentry->qstr->name? I thoroughly approve of kobject_name() though -- hide the implementation.
Signature · 3 lines
"It's not Hollywood. War is real, war is primarily not about defeat or victory, it is about death. I've seen thousands and thousands of dead bodies. Do you think I want to have an academic debate on this subject?" -- Robert Fisk
Quoted 7 lines
Quoted 5 lines
That patch is below. I'll be sending it to Linus once he gets back from vacation, unless anyone has any serious objections to it. Note that it completely removes any limitation on the length of a kobject (and sysfs directory) name.
Why keep another copy of the name? Why not use
kobj->dentry->qstr->name?
The problem is defining it. The dentry is not allocated until the kobject is registered, and we call through to sysfs. That's not so much a problem, but we'd have to pass the name along with the object down to sysfs in order to create the dentry, which would be a bit messy, IMO.
Pat
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Quoted 6 lines
Quoted 4 lines
That patch is below. I'll be sending it to Linus once he gets back from vacation, unless anyone has any serious objections to it. Note that it completely removes any limitation on the length of a kobject (and sysfs directory) name.
Why keep another copy of the name? Why not use
kobj->dentry->qstr->name?
The problem is defining it. The dentry is not allocated until the kobject is registered, and we call through to sysfs. That's not so much a problem, but we'd have to pass the name along with the object down to sysfs in order to create the dentry, which would be a bit messy, IMO.
Pat
Quoted 1 line
The patch is against 2.6.0-test4. Please apply.
Thanks for your work on this! One bug, 3 nits...
Quoted 2 lines
drivers/efi/efivars.c +2
-0+static ssize_t +efivar_edit (struct efivar_entry *entry,const char *buf,size_t count)
...
Quoted 5 lines
+
spin_lock(&efivars_lock);
+ status = efi.set_variable(new_var->VariableName, +&new_var->VendorGuid, +new_var->Attributes, +new_var->DataSize,
Quoted 8 lines
+
new_var->Data);
+
+ if (status !=EFI_SUCCESS) {
+ printk(KERN_WARNING "set_variable()failed: status=%lx\n", + status);
+ return-EIO;
+ }
+spin_unlock(&efivars_lock);
Move the unlock up above the status test, else you return while holding the lock on failure.
Quoted 2 lines
(quoted diff) +2
-0+static ssize_t +efivar_create(struct subsystem *sub, const char *buf, size_t count)
...
Quoted 2 lines
+ if (found) {
+printk("EFI variable already exists!\n");
level on printk please.
Quoted 1 line
+efivar_delete(struct subsystem *sub, const char *buf,
size_tcount)
...
Quoted 5 lines
+ status = efi.set_variable(del_var->VariableName, +
&del_var->VendorGuid, +del_var->Attributes, +del_var->DataSize, +del_var->Data);
Might as well just force the deletion by setting Attributes=0 or DataSize=0 or both. Less chance for userspace error.
Quoted 1 line
+ * Overrides for Emacs so that we follow Linus's tabbing style.
Please kill this chunk. I shouldn't have had it there in the first place. :-)
Looks great to me! Thanks again.
Signature · 4 lines
Matt Domsch Sr. Software Engineer, Lead Engineer Dell Linux Solutions www.dell.com/linux Linux on Dell mailing lists @ http://lists.us.dell.com