firmware: create directory hierarchy for sysfs fw_cfg entries
authorGabriel Somlo <somlo@cmu.edu>
Thu, 28 Jan 2016 14:23:13 +0000 (09:23 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 10 Feb 2016 01:37:39 +0000 (17:37 -0800)
commit246c46ebaeaef17814dc5a8830d16e7f1b01116b
tree0a55991f6e99de4f2895b7921569a55a3b8d5837
parent75f3e8e47f381074801d0034874d20c638d9e3d9
firmware: create directory hierarchy for sysfs fw_cfg entries

Each fw_cfg entry of type "file" has an associated 56-char,
nul-terminated ASCII string which represents its name. While
the fw_cfg device doesn't itself impose any specific naming
convention, QEMU developers have traditionally used path name
semantics (i.e. "etc/acpi/rsdp") to descriptively name the
various fw_cfg "blobs" passed into the guest.

This patch attempts, on a best effort basis, to create a
directory hierarchy representing the content of fw_cfg file
names, under /sys/firmware/qemu_fw_cfg/by_name.

Upon successful creation of all directories representing the
"dirname" portion of a fw_cfg file, a symlink will be created
to represent the "basename", pointing at the appropriate
/sys/firmware/qemu_fw_cfg/by_key entry. If a file name is not
suitable for this procedure (e.g., if its basename or dirname
components collide with an already existing dirname component
or basename, respectively) the corresponding fw_cfg blob is
skipped and will remain available in sysfs only by its selector
key value.

Signed-off-by: Gabriel Somlo <somlo@cmu.edu>
Cc: Andy Lutomirski <luto@amacapital.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Documentation/ABI/testing/sysfs-firmware-qemu_fw_cfg
drivers/firmware/qemu_fw_cfg.c