Blame usr/sysfs.h

Packit eace71
/*
Packit eace71
 * This is from udev-121 udev.h
Packit eace71
 *
Packit eace71
 * Copyright (C) 2003 Greg Kroah-Hartman <greg@kroah.com>
Packit eace71
 * Copyright (C) 2003-2006 Kay Sievers <kay.sievers@vrfy.org>
Packit eace71
 *
Packit eace71
 *	This program is free software; you can redistribute it and/or modify it
Packit eace71
 *	under the terms of the GNU General Public License as published by the
Packit eace71
 *	Free Software Foundation version 2 of the License.
Packit eace71
 *
Packit eace71
 *	This program is distributed in the hope that it will be useful, but
Packit eace71
 *	WITHOUT ANY WARRANTY; without even the implied warranty of
Packit eace71
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit eace71
 *	General Public License for more details.
Packit eace71
 *
Packit eace71
 *	You should have received a copy of the GNU General Public License along
Packit eace71
 *	with this program; if not, write to the Free Software Foundation, Inc.,
Packit eace71
 *	51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
Packit eace71
 *
Packit eace71
 */
Packit eace71
Packit eace71
#ifndef _SYSFS_
Packit eace71
#define _SYSFS_
Packit eace71
Packit eace71
#include <stdint.h>
Packit eace71
#include "list.h"
Packit eace71
#include "string.h"
Packit eace71
Packit eace71
#define PATH_SIZE				512
Packit eace71
#define NAME_SIZE				256
Packit eace71
Packit eace71
struct sysfs_device {
Packit eace71
	struct list_head node;			/* for device cache */
Packit eace71
	struct sysfs_device *parent;		/* already cached parent*/
Packit eace71
	char devpath[PATH_SIZE];
Packit eace71
	char subsystem[NAME_SIZE];		/* $class, $bus, drivers, module */
Packit eace71
	char kernel[NAME_SIZE];			/* device instance name */
Packit eace71
	char kernel_number[NAME_SIZE];
Packit eace71
	char driver[NAME_SIZE];			/* device driver name */
Packit eace71
};
Packit eace71
Packit eace71
extern char sysfs_path[PATH_SIZE];
Packit eace71
extern int sysfs_init(void);
Packit eace71
extern void sysfs_cleanup(void);
Packit eace71
extern void sysfs_device_set_values(struct sysfs_device *dev, const char *devpath,
Packit eace71
				    const char *subsystem, const char *driver);
Packit eace71
extern struct sysfs_device *sysfs_device_get(const char *devpath);
Packit eace71
extern struct sysfs_device *sysfs_device_get_parent(struct sysfs_device *dev);
Packit eace71
extern struct sysfs_device *sysfs_device_get_parent_with_subsystem(struct sysfs_device *dev, const char *subsystem);
Packit eace71
extern char *sysfs_attr_get_value(const char *devpath, const char *attr_name);
Packit eace71
extern int sysfs_resolve_link(char *path, size_t size);
Packit eace71
extern int sysfs_lookup_devpath_by_subsys_id(char *devpath, size_t len, const char *subsystem, const char *id);
Packit eace71
Packit eace71
extern char *sysfs_get_value(const char *id, char *subsys, char *param);
Packit eace71
extern int sysfs_get_uint(char *id, char *subsys, char *param,
Packit eace71
			  unsigned int *value);
Packit eace71
extern int sysfs_get_int(const char *id, char *subsys, char *param, int *value);
Packit eace71
extern int sysfs_get_str(char *id, char *subsys, char *param, char *value,
Packit eace71
			 int value_size);
Packit eace71
extern int sysfs_get_uint64(char *id, char *subsys, char *param,
Packit eace71
			    uint64_t *value);
Packit eace71
extern int sysfs_get_uint8(char *id, char *subsys, char *param,
Packit eace71
			   uint8_t *value);
Packit eace71
extern int sysfs_get_uint16(char *id, char *subsys, char *param,
Packit eace71
			    uint16_t *value);
Packit eace71
extern int sysfs_set_param(char *id, char *subsys, char *attr_name,
Packit eace71
			   char *write_buf, ssize_t buf_size);
Packit eace71
Packit eace71
extern char *sysfs_get_uevent_field(const char *path, const char *field);
Packit eace71
extern char *sysfs_get_uevent_devtype(const char *path);
Packit eace71
extern char *sysfs_get_uevent_devname(const char *path);
Packit eace71
Packit eace71
#endif