zdev: Add support for handling auto-configuration data

Auto-configuration is the name of a new configuration target that is
supported by chzdev and lszdev besides the existing active and
persistent configuration targets. Directives created in this new
configuration are stored as udev rules in the /run/udev/rules.d
directory.

Auto-configuration directives are only in effect if there are no
directives for the same device in the user-provided persistent
configuration. This allows users to override auto-configuration
directives if necessary.

Due to the volatile nature of the /run directory, auto-configuration
directives are cleared on reboot. Therefore mechanisms that generate
auto-configuration directives must recreate them on every boot.

The lszdev tool displays auto-configuration data both in list view
as well as in detail view. Users can specify the new option --auto-conf
to only show data from this configuration target.

Mechanisms that generate automated configuration directives can use
chzdev together with the --auto-conf option to create the corresponding
udev rules.

Note: This change does not include a mechanism that generates
      auto-configuration directives.

Signed-off-by: Peter Oberparleiter <oberpar@linux.vnet.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
This commit is contained in:
Peter Oberparleiter
2017-09-01 11:05:55 +02:00
committed by Jan Höppner
parent a86fb8b091
commit fe68ec513d
32 changed files with 911 additions and 286 deletions

View File

@@ -1107,14 +1107,18 @@ char *misc_readlink(const char *path)
}
/* Determine configuration set. */
config_t get_config(int active, int persistent)
config_t get_config(int active, int persistent, int autoconf)
{
if ((!active && !persistent) || (active && persistent))
return config_all;
else if (active)
return config_active;
else
return config_persistent;
config_t config = 0;
if (active)
config |= config_active;
if (persistent)
config |= config_persistent;
if (autoconf)
config |= config_autoconf;
return config;
}
/* Determine if program is running under z/VM. */
@@ -1248,11 +1252,12 @@ const char *config_to_str(config_t config)
return "active";
case config_persistent:
return "persistent";
case config_autoconf:
return "autoconf";
case config_all:
return "all";
}
/* Should not happen. */
return "";
return "multiple";
}
/* Convert textual config representation to config_t. */
@@ -1262,6 +1267,8 @@ bool str_to_config(const char *str, config_t *config_ptr)
*config_ptr = config_active;
else if (strcasecmp(str, "persistent") == 0)
*config_ptr = config_persistent;
else if (strcasecmp(str, "autoconf") == 0)
*config_ptr = config_autoconf;
else if (strcasecmp(str, "all") == 0)
*config_ptr = config_all;
else