udev.h revision 17fcfb5972977b6a3aedca6ad2aa8d1fbfbc761d
/*
* Copyright (C) 2003 Greg Kroah-Hartman <greg@kroah.com>
* Copyright (C) 2003-2008 Kay Sievers <kay.sievers@vrfy.org>
*
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _UDEV_H_
#define _UDEV_H_
#include "config.h"
#include "udev_sysdeps.h"
#include "lib/libudev-private.h"
#define ALLOWED_CHARS "#+-.:=@_"
#define DEFAULT_PARTITIONS_COUNT 15
#define UDEV_EVENT_TIMEOUT 180
#define UEVENT_BUFFER_SIZE 2048
#define UEVENT_NUM_ENVP 32
#define UDEV_MAX(a,b) ((a) > (b) ? (a) : (b))
/* pipes */
#define READ_END 0
#define WRITE_END 1
struct udev_rules;
struct sysfs_device {
char devpath[UTIL_PATH_SIZE];
char subsystem[UTIL_NAME_SIZE];
char kernel_number[UTIL_NAME_SIZE];
char driver[UTIL_NAME_SIZE];
};
struct udevice {
/* device event */
struct sysfs_device dev_local;
char action[UTIL_NAME_SIZE];
char *devpath_old;
/* node */
char name[UTIL_PATH_SIZE];
struct list_head symlink_list;
int symlink_final;
char owner[UTIL_NAME_SIZE];
int owner_final;
char group[UTIL_NAME_SIZE];
int group_final;
int mode_final;
/* event processing */
int run_final;
char tmp_node[UTIL_PATH_SIZE];
int partitions;
int ignore_device;
int ignore_remove;
char program_result[UTIL_PATH_SIZE];
int link_priority;
int event_timeout;
int test_run;
};
static inline void logging_init(const char *program_name)
{
}
{
}
static inline void logging_close(void)
{
closelog();
}
/* udev_device.c */
/* udev_device_event.c */
/* udev_sysfs.c */
extern int sysfs_init(void);
extern void sysfs_cleanup(void);
extern struct sysfs_device *sysfs_device_get_parent_with_subsystem(struct udev *udev, struct sysfs_device *dev, const char *subsystem);
extern int sysfs_lookup_devpath_by_subsys_id(struct udev *udev, char *devpath, size_t len, const char *subsystem, const char *id);
/* udev_node.c */
extern int udev_node_mknod(struct udevice *udevice, const char *file, dev_t devt, mode_t mode, uid_t uid, gid_t gid);
/* udev_db.c */
extern int udev_db_get_devices_by_name(struct udev *udev, const char *name, struct list_head *name_list);
/* udev_utils.c */
struct name_entry {
char name[UTIL_PATH_SIZE];
unsigned int ignore_error:1;
};
extern struct name_entry *name_list_add(struct udev *udev, struct list_head *name_list, const char *name, int sort);
extern struct name_entry *name_list_key_add(struct udev *udev, struct list_head *name_list, const char *key, const char *value);
extern int add_matching_files(struct udev *udev, struct list_head *name_list, const char *dirname, const char *suffix);
/* udev_utils_file.c */
/* udevadm commands */
#endif