automotive-dlt
|
#include <libudev.h>
#include <errno.h>
#include <mntent.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/mount.h>
#include "dlt-control-common.h"
#include "dlt-logstorage-common.h"
#include "dlt-logstorage-list.h"
#include "dlt-logstorage-udev.h"
Go to the source code of this file.
Data Structures | |
struct | LogstorageCtrlUdev |
Macros | |
#define | pr_fmt(fmt) "Udev control: "fmt |
Functions | |
static char * | dlt_logstorage_udev_get_mount_point (char *dev_node) |
Get mount point of a device node. More... | |
static int | check_mountpoint_from_partition (int event, struct udev_device *part) |
Check if the daemon needs to be notified by the event. More... | |
static int | logstorage_udev_udevd_callback (void) |
Handles the udev events. More... | |
static int | dlt_logstorage_udev_check_mounted (struct udev *udev) |
Check all partitions on the system to find configuration file. More... | |
int | dlt_logstorage_udev_deinit (void) |
Clean-up the udev data. More... | |
int | dlt_logstorage_udev_init (void) |
Initialize the private data. More... | |
app begin@ Copyright (C) 2013 - 2015 Advanced Driver Information Technology. This code is developed by Advanced Driver Information Technology. Copyright of Advanced Driver Information Technology, Bosch and DENSO.
This file is part of GENIVI Project Dlt - Diagnostic Log and Trace console apps.
For further information see http://www.genivi.org/. end@
Definition in file dlt-logstorage-udev.c.
#define pr_fmt | ( | fmt | ) | "Udev control: "fmt |
Definition at line 55 of file dlt-logstorage-udev.c.
|
static |
Check if the daemon needs to be notified by the event.
On mount event: If the device mount point contains the DLT configuration file, the function will then send a message to the daemon. On Unmounting event: Check if the device was on the list, remove it and send the message to the daemon.
The kind of event happening The device partition to be checked
Definition at line 143 of file dlt-logstorage-udev.c.
References LogstorageDeviceInfo::dev_node, dlt_logstorage_check_config_file(), dlt_logstorage_send_event(), dlt_logstorage_udev_get_mount_point(), EVENT_MOUNTED, logstorage_delete_dev_info(), logstorage_store_dev_info(), LogstorageDeviceInfo::mnt_point, NULL, pr_error, and pr_verbose.
Referenced by dlt_logstorage_udev_check_mounted(), and logstorage_udev_udevd_callback().
|
static |
Check all partitions on the system to find configuration file.
The function looks for block devices that are of "partition" type. Then, it gets the node, and call check_mountpoint_from_partition with it.
The udev device used to find all the nodes
Definition at line 283 of file dlt-logstorage-udev.c.
References check_mountpoint_from_partition(), EVENT_MOUNTED, NULL, pr_error, and pr_verbose.
Referenced by dlt_logstorage_udev_init().
int dlt_logstorage_udev_deinit | ( | void | ) |
Clean-up the udev data.
That will destroy all the private data.
Definition at line 340 of file dlt-logstorage-udev.c.
References get_logstorage_control(), lctrl, LogstorageCtrlUdev::mon, NULL, DltLogstorageCtrl::prvt, and LogstorageCtrlUdev::udev.
Referenced by dlt_logstorage_deinit_handler(), and dlt_logstorage_udev_init().
|
static |
Get mount point of a device node.
This function search for the mount point in /proc/mounts based on the device node.
dev_node | Device node as string |
Definition at line 86 of file dlt-logstorage-udev.c.
References LogstorageDeviceInfo::mnt_point, NULL, and pr_error.
Referenced by check_mountpoint_from_partition().
int dlt_logstorage_udev_init | ( | void | ) |
Initialize the private data.
That function will create the udev device and monitor.
Definition at line 374 of file dlt-logstorage-udev.c.
References DltLogstorageCtrl::callback, dlt_logstorage_udev_check_mounted(), dlt_logstorage_udev_deinit(), DltLogstorageCtrl::fd, get_logstorage_control(), lctrl, logstorage_udev_udevd_callback(), LogstorageCtrlUdev::mon, NULL, pr_error, pr_verbose, DltLogstorageCtrl::prvt, and LogstorageCtrlUdev::udev.
Referenced by dlt_logstorage_init_handler().
|
static |
Handles the udev events.
On event, it finds the corresponding action, and calls check_mountpoint_from_partition with the corresponding event.
Definition at line 209 of file dlt-logstorage-udev.c.
References check_mountpoint_from_partition(), EVENT_MOUNTED, EVENT_UNMOUNTING, get_logstorage_control(), lctrl, LogstorageCtrlUdev::mon, NULL, pr_error, pr_verbose, and DltLogstorageCtrl::prvt.
Referenced by dlt_logstorage_udev_init().