automotive-dlt
dlt-logstorage-udev.c File Reference
#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"
Include dependency graph for dlt-logstorage-udev.c:

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...
 

Detailed Description

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.

Author
Christoph Lipka clipk.nosp@m.a@jp.nosp@m..adit.nosp@m.-jv..nosp@m.com ADIT 2015
Frederic Berat fbera.nosp@m.t@de.nosp@m..adit.nosp@m.-jv..nosp@m.com ADIT 2015

For further information see http://www.genivi.org/. end@

Definition in file dlt-logstorage-udev.c.

Macro Definition Documentation

#define pr_fmt (   fmt)    "Udev control: "fmt

Definition at line 55 of file dlt-logstorage-udev.c.

Function Documentation

static int check_mountpoint_from_partition ( int  event,
struct udev_device *  part 
)
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

Returns
0 on success, -1 if an error occured.

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 int dlt_logstorage_udev_check_mounted ( struct udev *  udev)
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

Returns
0 on success, -1 otherwise.

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.

Returns
0 on success, -1 otherwise.

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 char* dlt_logstorage_udev_get_mount_point ( char *  dev_node)
static

Get mount point of a device node.

This function search for the mount point in /proc/mounts based on the device node.

Parameters
dev_nodeDevice node as string
Returns
mount path or NULL on error

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  )
static int logstorage_udev_udevd_callback ( void  )
static

Handles the udev events.

On event, it finds the corresponding action, and calls check_mountpoint_from_partition with the corresponding event.

Returns
0 on success, -1 on error.

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().