zdev: Implement internal device attributes

This change adds base infrastructure for implementing internal device
attributes. In the context of the zdev tools, an internal device
attribute is a new type of device attribute with the following
characteristics:

  - Can be set and removed like normal device attributes
  - Affects zdev-internal handling only
  - Does not correspond to an actual device attribute, that is
    it has no representation in SysFS
  - Can not be set in the active configuration
  - Name starts with "zdev:" to prevent conflicts with actual
    device attributes

Values for internal device attributes are stored in udev rules alongside
the normal persistent configuration of a device. They are encoded as
udev environment variables. Note that they have no further effect on
udev processing.

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:58 +02:00
committed by Jan Höppner
parent 3c5644ccfd
commit c0392efa39
12 changed files with 220 additions and 8 deletions

25
zdev/src/internal.c Normal file
View File

@@ -0,0 +1,25 @@
/*
* zdev - Modify and display the persistent configuration of devices
*
* Copyright IBM Corp. 2017
*
* s390-tools is free software; you can redistribute it and/or modify
* it under the terms of the MIT license. See LICENSE for details.
*/
#include <stdbool.h>
#include "internal.h"
#include "misc.h"
/* Return identifier of internal attribute with specified @name. */
const char *internal_get_name(const char *name)
{
return name + sizeof(INTERNAL_ATTR_PREFIX) - 1;
}
/* Check if attribute is internal by name. */
bool internal_by_name(const char *name)
{
return starts_with(name, INTERNAL_ATTR_PREFIX);
}