• [^] # Re: la règle est bonne, mais...

    Posté par . En réponse au message Problème avec des règles udev. Évalué à 1.

    https://www.kernel.org/doc/Documentation/filesystems/sysfs.txt

    En particulier :

    Attributes
    ~~~~~~~~~~

    Attributes can be exported for kobjects in the form of regular files in
    the filesystem. Sysfs forwards file I/O operations to methods defined
    for the attributes, providing a means to read and write kernel
    attributes.

    Attributes should be ASCII text files, preferably with only one value
    per file. It is noted that it may not be efficient to contain only one
    value per file, so it is socially acceptable to express an array of
    values of the same type.

    Mixing types, expressing multiple lines of data, and doing fancy
    formatting of data is heavily frowned upon. Doing these things may get
    you publicly humiliated and your code rewritten without notice.

    An attribute definition is simply:

    struct attribute {
    char * name;
    struct module *owner;
    umode_t mode;
    };

    int sysfs_create_file(struct kobject * kobj, const struct attribute * attr);
    void sysfs_remove_file(struct kobject * kobj, const struct attribute * attr);

    A bare attribute contains no means to read or write the value of the
    attribute. Subsystems are encouraged to define their own attribute
    structure and wrapper functions for adding and removing attributes for
    a specific object type.

    For example, the driver model defines struct device_attribute like:

    struct device_attribute {
    struct attribute attr;
    ssize_t (*show)(struct device *dev, struct device_attribute *attr,
    char *buf);
    ssize_t (*store)(struct device *dev, struct device_attribute *attr,
    const char *buf, size_t count);
    };

    int device_create_file(struct device *, const struct device_attribute *);
    void device_remove_file(struct device *, const struct device_attribute *);

    It also defines this helper for defining device attributes:

    #define DEVICE_ATTR(name, mode, _show, _store) \
    struct device
    attribute dev
    attr_##_name = __ATTR(_name, _mode, _show, _store)

    For example, declaring

    static DEVICE_ATTR(foo, S_IWUSR | S_IRUGO, show_foo, store_foo);

    is equivalent to doing:

    static struct device_attribute dev_attr_foo = {
    .attr = {
    .name = "foo",
    .mode = S_IWUSR | S_IRUGO,
    },
    .show = show_foo,
    .store = store_foo,
    };

    C’est donc bien le noyau qui exporte les données. Ceci dit il est possible qu’il y ait aussi une ou des bases de données pour renseigner les info (c’est le cas des lspci&co), mais de ce que j’ai compris ça n’est pas lié à udev.