Blame src/udev.h

Packit 7e09eb
/*
Packit 7e09eb
 * Intel(R) Enclosure LED Utilities
Packit 7e09eb
 * Copyright (C) 2017-2019 Intel Corporation.
Packit 7e09eb
 *
Packit 7e09eb
 * This program is free software; you can redistribute it and/or modify it
Packit 7e09eb
 * under the terms and conditions of the GNU General Public License,
Packit 7e09eb
 * version 2, as published by the Free Software Foundation.
Packit 7e09eb
 *
Packit 7e09eb
 * This program is distributed in the hope it will be useful, but WITHOUT
Packit 7e09eb
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
Packit 7e09eb
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
Packit 7e09eb
 * more details.
Packit 7e09eb
 *
Packit 7e09eb
 * You should have received a copy of the GNU General Public License along with
Packit 7e09eb
 * this program; if not, write to the Free Software Foundation, Inc.,
Packit 7e09eb
 * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
Packit 7e09eb
 *
Packit 7e09eb
 */
Packit 7e09eb
Packit 7e09eb
#ifndef _UDEV_H_INCLUDED_
Packit 7e09eb
#define _UDEV_H_INCLUDED_
Packit 7e09eb
Packit 7e09eb
#include "list.h"
Packit 7e09eb
Packit 7e09eb
/**
Packit 7e09eb
 */
Packit 7e09eb
enum udev_action {
Packit 7e09eb
	UDEV_ACTION_UNKNOWN = 0,
Packit 7e09eb
	UDEV_ACTION_ADD,
Packit 7e09eb
	UDEV_ACTION_REMOVE
Packit 7e09eb
};
Packit 7e09eb
Packit 7e09eb
/**
Packit 7e09eb
 * @brief Deletes udev context and udev monitor.
Packit 7e09eb
 *
Packit 7e09eb
 * @return The function does not return a value..
Packit 7e09eb
 */
Packit 7e09eb
void stop_udev_monitor(void);
Packit 7e09eb
Packit 7e09eb
/**
Packit 7e09eb
 * @brief Returns udev monitor file descriptor or creates udev context and
Packit 7e09eb
 *        udev monitor if monitor does not exist.
Packit 7e09eb
 *
Packit 7e09eb
 * @return Udev monitor file descriptor if successful, otherwise the
Packit 7e09eb
 *         function returns -1 on libudev error and libudev sets errno.
Packit 7e09eb
 */
Packit 7e09eb
int get_udev_monitor(void);
Packit 7e09eb
Packit 7e09eb
/**
Packit 7e09eb
 * @brief Handles udev event.
Packit 7e09eb
 *
Packit 7e09eb
 *        This function checks event type and if it is 'add' or remove
Packit 7e09eb
 *        function sets custom IBPI pattern to block device which is affected
Packit 7e09eb
 *        by this event.
Packit 7e09eb
 *
Packit 7e09eb
 * @param[in]    ledmon_block_list    list containing block devices, it is
Packit 7e09eb
 *                                    used to match device from udev event.
Packit 7e09eb
 *
Packit 7e09eb
 * @return 0 if 'add' or 'remove' event handled successfully;
Packit 7e09eb
 *         1 if registered event is not 'add' or 'remove';
Packit 7e09eb
 *         -1 on libudev error.
Packit 7e09eb
 */
Packit 7e09eb
int handle_udev_event(struct list *ledmon_block_list);
Packit 7e09eb
Packit 7e09eb
#endif                         /* _UDEV_H_INCLUDED_ */