[AC_DEFINE([HAVE_INOTIFY], 1, [inotify available])],
[AC_MSG_WARN([inotify support disabled])])
-AC_CHECK_LIB(c, strlcpy,
- [AC_DEFINE([HAVE_STRLCPY], 1, [strlcpy available])],
- [])
-
AC_ARG_WITH(udev-prefix,
AS_HELP_STRING([--with-udev-prefix=DIR], [add prefix to internal udev path names]),
[], [with_udev_prefix='${exec_prefix}'])
/* lookup signature in sysfs to determine the name */
for (dent = readdir(dir); dent != NULL; dent = readdir(dir)) {
- char file[PATH_SIZE];
+ char file[UTIL_PATH_SIZE];
char sysfs_id_buf[256];
uint32_t sysfs_id;
ssize_t size;
**/
const char *udev_device_get_subsystem(struct udev_device *udev_device)
{
- char subsystem[UTIL_PATH_SIZE];
+ char subsystem[UTIL_NAME_SIZE];
if (udev_device == NULL)
return NULL;
if (udev_device == NULL)
return -1;
list_for_each_entry(name_loop, &udev_device->env_list, node) {
- char name[UTIL_PATH_SIZE];
+ char name[UTIL_NAME_SIZE];
char *val;
strncpy(name, name_loop->name, sizeof(name));
const char *udev_device_get_driver(struct udev_device *udev_device)
{
- char driver[UTIL_PATH_SIZE];
+ char driver[UTIL_NAME_SIZE];
if (udev_device == NULL)
return NULL;
/* libudev-utils */
#define UTIL_PATH_SIZE 1024
-#define UTIL_LINE_SIZE 1024
+#define UTIL_LINE_SIZE 2048
+#define UTIL_NAME_SIZE 512
struct util_name_entry {
struct list_head node;
char *name;
#include "lib/libudev-private.h"
#include "lib/list.h"
-#define COMMENT_CHARACTER '#'
-#define LINE_SIZE 512
-#define PATH_SIZE 512
-#define NAME_SIZE 256
-#define VALUE_SIZE 128
-
#define ALLOWED_CHARS "#+-.:=@_"
#define ALLOWED_CHARS_FILE ALLOWED_CHARS "/"
#define ALLOWED_CHARS_INPUT ALLOWED_CHARS_FILE " $%?,"
struct sysfs_device {
struct list_head node; /* for device cache */
struct sysfs_device *parent; /* already cached parent*/
- char devpath[PATH_SIZE];
- char subsystem[NAME_SIZE]; /* $class, $bus, drivers, module */
- char kernel[NAME_SIZE]; /* device instance name */
- char kernel_number[NAME_SIZE];
- char driver[NAME_SIZE]; /* device driver name */
+ char devpath[UTIL_PATH_SIZE];
+ char subsystem[UTIL_NAME_SIZE];
+ char kernel[UTIL_NAME_SIZE]; /* device instance name */
+ char kernel_number[UTIL_NAME_SIZE];
+ char driver[UTIL_NAME_SIZE];
};
struct udevice {
struct sysfs_device *dev; /* points to dev_local by default */
struct sysfs_device dev_local;
struct sysfs_device *dev_parent; /* current parent device used for matching */
- char action[NAME_SIZE];
+ char action[UTIL_NAME_SIZE];
char *devpath_old;
/* node */
- char name[PATH_SIZE];
+ char name[UTIL_PATH_SIZE];
struct list_head symlink_list;
int symlink_final;
- char owner[NAME_SIZE];
+ char owner[UTIL_NAME_SIZE];
int owner_final;
- char group[NAME_SIZE];
+ char group[UTIL_NAME_SIZE];
int group_final;
mode_t mode;
int mode_final;
struct list_head run_list;
int run_final;
struct list_head env_list;
- char tmp_node[PATH_SIZE];
+ char tmp_node[UTIL_PATH_SIZE];
int partitions;
int ignore_device;
int ignore_remove;
- char program_result[PATH_SIZE];
+ char program_result[UTIL_PATH_SIZE];
int link_priority;
int event_timeout;
int test_run;
extern struct sysfs_device *sysfs_device_get_parent(struct udev *udev, struct sysfs_device *dev);
extern struct sysfs_device *sysfs_device_get_parent_with_subsystem(struct udev *udev, struct sysfs_device *dev, const char *subsystem);
extern char *sysfs_attr_get_value(struct udev *udev, const char *devpath, const char *attr_name);
-extern int sysfs_resolve_link(struct udev *udev, char *path, size_t size);
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 */
/* udev_utils.c */
struct name_entry {
struct list_head node;
- char name[PATH_SIZE];
+ char name[UTIL_PATH_SIZE];
unsigned int ignore_error:1;
};
-
-extern int log_priority(const char *priority);
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 name_list_key_remove(struct udev *udev, struct list_head *name_list, const char *key);
/* reverse mapping from the device file name to the devpath */
static int name_index(struct udev *udev, const char *devpath, const char *name, int add)
{
- char device[PATH_SIZE];
- char filename[PATH_SIZE * 2];
+ char device[UTIL_PATH_SIZE];
+ char filename[UTIL_PATH_SIZE * 2];
size_t start;
int fd;
info(udev, "found index directory '%s'\n", dirname);
while (1) {
struct dirent *ent;
- char device[PATH_SIZE];
+ char device[UTIL_PATH_SIZE];
ent = readdir(dir);
if (ent == NULL || ent->d_name[0] == '\0')
int udev_db_rename(struct udev *udev, const char *devpath_old, const char *devpath)
{
- char filename[PATH_SIZE];
- char filename_old[PATH_SIZE];
+ char filename[UTIL_PATH_SIZE];
+ char filename_old[UTIL_PATH_SIZE];
devpath_to_db_path(udev, devpath_old, filename_old, sizeof(filename_old));
devpath_to_db_path(udev, devpath, filename, sizeof(filename));
int udev_db_add_device(struct udevice *udevice)
{
- char filename[PATH_SIZE];
+ char filename[UTIL_PATH_SIZE];
if (udevice->test_run)
return 0;
int udev_db_get_device(struct udevice *udevice, const char *devpath)
{
struct stat stats;
- char filename[PATH_SIZE];
- char line[PATH_SIZE];
+ char filename[UTIL_PATH_SIZE];
+ char line[UTIL_PATH_SIZE];
unsigned int maj, min;
char *bufline;
char *buf;
return -1;
}
if ((stats.st_mode & S_IFMT) == S_IFLNK) {
- char target[NAME_SIZE];
+ char target[UTIL_NAME_SIZE];
int target_len;
info(udevice->udev, "found a symlink as db file\n");
int udev_db_delete_device(struct udevice *udevice)
{
- char filename[PATH_SIZE];
+ char filename[UTIL_PATH_SIZE];
struct name_entry *name_loop;
if (udevice->test_run)
while (1) {
struct dirent *ent;
- char device[PATH_SIZE];
+ char device[UTIL_PATH_SIZE];
ent = readdir(dir);
if (ent == NULL || ent->d_name[0] == '\0')
int udev_node_mknod(struct udevice *udevice, const char *file, dev_t devt, mode_t mode, uid_t uid, gid_t gid)
{
- char file_tmp[PATH_SIZE + sizeof(TMP_FILE_EXT)];
+ char file_tmp[UTIL_PATH_SIZE + sizeof(TMP_FILE_EXT)];
struct stat stats;
int preserve = 0;
int err = 0;
static int node_symlink(struct udevice *udevice, const char *node, const char *slink)
{
struct stat stats;
- char target[PATH_SIZE] = "";
- char slink_tmp[PATH_SIZE + sizeof(TMP_FILE_EXT)];
+ char target[UTIL_PATH_SIZE] = "";
+ char slink_tmp[UTIL_PATH_SIZE + sizeof(TMP_FILE_EXT)];
int i = 0;
int tail = 0;
int len;
}
}
} else if (S_ISLNK(stats.st_mode)) {
- char buf[PATH_SIZE];
+ char buf[UTIL_PATH_SIZE];
info(udevice->udev, "found existing symlink '%s'\n", slink);
len = readlink(slink, buf, sizeof(buf));
static int update_link(struct udevice *udevice, const char *name)
{
LIST_HEAD(name_list);
- char slink[PATH_SIZE];
- char node[PATH_SIZE];
+ char slink[UTIL_PATH_SIZE];
+ char node[UTIL_PATH_SIZE];
struct udevice *udevice_db;
struct name_entry *device;
- char target[PATH_MAX] = "";
+ char target[UTIL_PATH_SIZE] = "";
int count;
int priority = 0;
int rc = 0;
void udev_node_update_symlinks(struct udevice *udevice, struct udevice *udevice_old)
{
struct name_entry *name_loop;
- char symlinks[PATH_SIZE] = "";
+ char symlinks[UTIL_PATH_SIZE] = "";
list_for_each_entry(name_loop, &udevice->symlink_list, node) {
info(udevice->udev, "update symlink '%s' of '%s'\n", name_loop->name, udevice->dev->devpath);
int udev_node_add(struct udevice *udevice)
{
- char filename[PATH_SIZE];
+ char filename[UTIL_PATH_SIZE];
uid_t uid;
gid_t gid;
int i;
/* create all_partitions if requested */
if (udevice->partitions) {
- char partitionname[PATH_SIZE];
+ char partitionname[UTIL_PATH_SIZE];
char *attr;
int range;
int udev_node_remove(struct udevice *udevice)
{
- char filename[PATH_SIZE];
- char partitionname[PATH_SIZE];
+ char filename[UTIL_PATH_SIZE];
+ char partitionname[UTIL_PATH_SIZE];
struct stat stats;
int retval = 0;
int num;
int outpipe[2] = {-1, -1};
int errpipe[2] = {-1, -1};
pid_t pid;
- char arg[PATH_SIZE];
- char program[PATH_SIZE];
+ char arg[UTIL_PATH_SIZE];
+ char program[UTIL_PATH_SIZE];
char *argv[(sizeof(arg) / 2) + 1];
int devnull;
int i;
static int import_keys_into_env(struct udevice *udevice, const char *buf, size_t bufsize)
{
- char line[LINE_SIZE];
+ char line[UTIL_LINE_SIZE];
const char *bufline;
char *linepos;
char *variable;
continue;
/* see if this is a comment */
- if (bufline[0] == COMMENT_CHARACTER)
+ if (bufline[0] == '#')
continue;
if (count >= sizeof(line)) {
if (udev_db_get_device(udev_parent, dev_parent->devpath) == 0) {
dbg(udevice->udev, "import stored parent env '%s'\n", udev_parent->name);
list_for_each_entry(name_loop, &udev_parent->env_list, node) {
- char name[NAME_SIZE];
+ char name[UTIL_NAME_SIZE];
char *pos;
util_strlcpy(name, name_loop->name, sizeof(name));
if (strncmp(name_loop->name, "socket:", strlen("socket:")) == 0) {
pass_env_to_socket(udevice->udev, &name_loop->name[strlen("socket:")], udevice->dev->devpath, udevice->action);
} else {
- char program[PATH_SIZE];
+ char program[UTIL_PATH_SIZE];
util_strlcpy(program, name_loop->name, sizeof(program));
udev_rules_apply_format(udevice, program, sizeof(program));
#define WAIT_LOOP_PER_SECOND 50
static int wait_for_file(struct udevice *udevice, const char *file, int timeout)
{
- char filepath[PATH_SIZE];
- char devicepath[PATH_SIZE] = "";
+ char filepath[UTIL_PATH_SIZE];
+ char devicepath[UTIL_PATH_SIZE] = "";
struct stat stats;
int loop = timeout * WAIT_LOOP_PER_SECOND;
/* handle "[$SUBSYSTEM/$KERNEL]<attribute>" lookup */
static int attr_get_by_subsys_id(struct udev *udev, const char *attrstr, char *devpath, size_t len, char **attr)
{
- char subsys[NAME_SIZE];
+ char subsys[UTIL_NAME_SIZE];
char *pos;
char *id;
char *attrib;
pos = strstr(attr, "/*/");
if (pos != NULL) {
- char str[PATH_SIZE];
+ char str[UTIL_PATH_SIZE];
DIR *dir;
pos[1] = '\0';
void udev_rules_apply_format(struct udevice *udevice, char *string, size_t maxsize)
{
- char temp[PATH_SIZE];
- char temp2[PATH_SIZE];
+ char temp[UTIL_PATH_SIZE];
+ char temp2[UTIL_PATH_SIZE];
char *head, *tail, *pos, *cpos, *attr, *rest;
int len;
int i;
if (attr == NULL)
err(udevice->udev, "missing file parameter for attr\n");
else {
- char devpath[PATH_SIZE];
+ char devpath[UTIL_PATH_SIZE];
char *attrib;
const char *value = NULL;
size_t size;
case SUBST_LINKS:
if (!list_empty(&udevice->symlink_list)) {
struct name_entry *name_loop;
- char symlinks[PATH_SIZE] = "";
+ char symlinks[UTIL_PATH_SIZE] = "";
list_for_each_entry(name_loop, &udevice->symlink_list, node) {
util_strlcat(symlinks, name_loop->name, sizeof(symlinks));
static int match_key(struct udev *udev, const char *key_name, struct udev_rule *rule, struct key *key, const char *val)
{
- char value[PATH_SIZE];
+ char value[UTIL_PATH_SIZE];
char *key_value;
char *pos;
int match = 0;
if (rule->test.operation == KEY_OP_MATCH ||
rule->test.operation == KEY_OP_NOMATCH) {
- char filename[PATH_SIZE];
- char devpath[PATH_SIZE];
+ char filename[UTIL_PATH_SIZE];
+ char devpath[UTIL_PATH_SIZE];
char *attr;
struct stat statbuf;
int match;
util_strlcat(filename, attr, sizeof(filename));
}
} else if (filename[0] != '/') {
- char tmp[PATH_SIZE];
+ char tmp[UTIL_PATH_SIZE];
util_strlcpy(tmp, udev_get_sys_path(udevice->udev), sizeof(tmp));
util_strlcat(tmp, udevice->dev->devpath, sizeof(tmp));
}
if (rule->wait_for.operation != KEY_OP_UNSET) {
- char filename[PATH_SIZE];
+ char filename[UTIL_PATH_SIZE];
int found;
util_strlcpy(filename, key_val(rule, &rule->wait_for), sizeof(filename));
pair->key.operation == KEY_OP_NOMATCH) {
const char *key_name = key_pair_name(rule, pair);
const char *key_value = key_val(rule, &pair->key);
- char devpath[PATH_SIZE];
+ char devpath[UTIL_PATH_SIZE];
char *attrib;
const char *value = NULL;
- char val[VALUE_SIZE];
+ char val[UTIL_NAME_SIZE];
size_t len;
if (attr_get_by_subsys_id(udevice->udev, key_name, devpath, sizeof(devpath), &attrib)) {
const char *key_name = key_pair_name(rule, pair);
const char *key_value = key_val(rule, &pair->key);
const char *value;
- char val[VALUE_SIZE];
+ char val[UTIL_NAME_SIZE];
size_t len;
value = sysfs_attr_get_value(udevice->udev, udevice->dev_parent->devpath, key_name);
/* execute external program */
if (rule->program.operation != KEY_OP_UNSET) {
- char program[PATH_SIZE];
- char result[PATH_SIZE];
+ char program[UTIL_PATH_SIZE];
+ char result[UTIL_PATH_SIZE];
util_strlcpy(program, key_val(rule, &rule->program), sizeof(program));
udev_rules_apply_format(udevice, program, sizeof(program));
/* import variables returned from program or or file into environment */
if (rule->import.operation != KEY_OP_UNSET) {
- char import[PATH_SIZE];
+ char import[UTIL_PATH_SIZE];
int rc = -1;
util_strlcpy(import, key_val(rule, &rule->import), sizeof(import));
struct key_pair *pair = &rule->env.keys[i];
if (pair->key.operation == KEY_OP_ASSIGN) {
- char temp_value[NAME_SIZE];
+ char temp_value[UTIL_NAME_SIZE];
const char *key_name = key_pair_name(rule, pair);
const char *value = key_val(rule, &pair->key);
/* make sure we don't write to the same string we possibly read from */
util_strlcpy(temp_value, value, sizeof(temp_value));
- udev_rules_apply_format(udevice, temp_value, NAME_SIZE);
+ udev_rules_apply_format(udevice, temp_value, sizeof(temp_value));
if (temp_value[0] == '\0') {
name_list_key_remove(udevice->udev, &udevice->env_list, key_name);
if (pair->key.operation == KEY_OP_ASSIGN) {
const char *key_name = key_pair_name(rule, pair);
- char devpath[PATH_SIZE];
+ char devpath[UTIL_PATH_SIZE];
char *attrib;
- char attr[PATH_SIZE] = "";
- char value[NAME_SIZE];
+ char attr[UTIL_PATH_SIZE] = "";
+ char value[UTIL_NAME_SIZE];
FILE *f;
if (attr_get_by_subsys_id(udevice->udev, key_name, devpath, sizeof(devpath), &attrib)) {
(rule->symlink.operation == KEY_OP_ASSIGN ||
rule->symlink.operation == KEY_OP_ASSIGN_FINAL ||
rule->symlink.operation == KEY_OP_ADD)) {
- char temp[PATH_SIZE];
+ char temp[UTIL_PATH_SIZE];
char *pos, *next;
int count;
static int add_rule_key(struct udev_rule *rule, struct key *key,
enum key_operation operation, const char *value)
{
- size_t val_len = strnlen(value, PATH_SIZE);
+ size_t val_len = strnlen(value, UTIL_PATH_SIZE);
key->operation = operation;
static int add_rule_key_pair(struct udev_rules *rules, struct udev_rule *rule, struct key_pairs *pairs,
enum key_operation operation, const char *key, const char *value)
{
- size_t key_len = strnlen(key, PATH_SIZE);
+ size_t key_len = strnlen(key, UTIL_PATH_SIZE);
if (pairs->count >= PAIRS_MAX) {
err(rules->udev, "skip, too many keys of the same type in a single rule\n");
static int add_to_rules(struct udev_rules *rules, char *line, const char *filename, unsigned int lineno)
{
- char buf[sizeof(struct udev_rule) + LINE_SIZE];
+ char buf[sizeof(struct udev_rule) + UTIL_LINE_SIZE];
struct udev_rule *rule;
size_t rule_size;
int valid;
rule->import_type = IMPORT_PARENT;
} else {
/* figure it out if it is executable */
- char file[PATH_SIZE];
+ char file[UTIL_PATH_SIZE];
char *pos;
struct stat statbuf;
static int parse_file(struct udev_rules *rules, const char *filename)
{
- char line[LINE_SIZE];
+ char line[UTIL_LINE_SIZE];
char *bufline;
unsigned int lineno;
char *buf;
continue;
/* see if this is a comment */
- if (bufline[0] == COMMENT_CHARACTER)
+ if (bufline[0] == '#')
continue;
if (count >= sizeof(line)) {
struct sysfs_attr {
struct list_head node;
- char path[PATH_SIZE];
+ char path[UTIL_PATH_SIZE];
char *value; /* points to value_local if value is cached */
- char value_local[NAME_SIZE];
+ char value_local[UTIL_NAME_SIZE];
};
int sysfs_init(void)
dbg(udev, "kernel_number='%s'\n", dev->kernel_number);
}
-int sysfs_resolve_link(struct udev *udev, char *devpath, size_t size)
-{
- char link_path[PATH_SIZE];
- char link_target[PATH_SIZE];
- int len;
- int i;
- int back;
-
- util_strlcpy(link_path, udev_get_sys_path(udev), sizeof(link_path));
- util_strlcat(link_path, devpath, sizeof(link_path));
- len = readlink(link_path, link_target, sizeof(link_target));
- if (len <= 0)
- return -1;
- link_target[len] = '\0';
- dbg(udev, "path link '%s' points to '%s'\n", devpath, link_target);
-
- for (back = 0; strncmp(&link_target[back * 3], "../", 3) == 0; back++)
- ;
- dbg(udev, "base '%s', tail '%s', back %i\n", devpath, &link_target[back * 3], back);
- for (i = 0; i <= back; i++) {
- char *pos = strrchr(devpath, '/');
-
- if (pos == NULL)
- return -1;
- pos[0] = '\0';
- }
- dbg(udev, "after moving back '%s'\n", devpath);
- util_strlcat(devpath, "/", size);
- util_strlcat(devpath, &link_target[back * 3], size);
- return 0;
-}
-
struct sysfs_device *sysfs_device_get(struct udev *udev, const char *devpath)
{
- char path[PATH_SIZE];
- char devpath_real[PATH_SIZE];
+ char path[UTIL_PATH_SIZE];
+ char devpath_real[UTIL_PATH_SIZE];
struct sysfs_device *dev;
struct sysfs_device *dev_loop;
struct stat statbuf;
- char link_path[PATH_SIZE];
- char link_target[PATH_SIZE];
+ char link_path[UTIL_PATH_SIZE];
+ char link_target[UTIL_PATH_SIZE];
int len;
char *pos;
return NULL;
}
if (S_ISLNK(statbuf.st_mode)) {
- if (sysfs_resolve_link(udev, devpath_real, sizeof(devpath_real)) != 0)
+ if (util_resolve_sys_link(udev, devpath_real, sizeof(devpath_real)) != 0)
return NULL;
/* now look for device in cache after path translation */
struct sysfs_device *sysfs_device_get_parent(struct udev *udev, struct sysfs_device *dev)
{
- char parent_devpath[PATH_SIZE];
+ char parent_devpath[UTIL_PATH_SIZE];
char *pos;
dbg(udev, "open '%s'\n", dev->devpath);
device_link:
util_strlcpy(parent_devpath, dev->devpath, sizeof(parent_devpath));
util_strlcat(parent_devpath, "/device", sizeof(parent_devpath));
- if (sysfs_resolve_link(udev, parent_devpath, sizeof(parent_devpath)) != 0)
+ if (util_resolve_sys_link(udev, parent_devpath, sizeof(parent_devpath)) != 0)
return NULL;
/* get parent and remember it */
char *sysfs_attr_get_value(struct udev *udev, const char *devpath, const char *attr_name)
{
- char path_full[PATH_SIZE];
+ char path_full[UTIL_PATH_SIZE];
const char *path;
- char value[NAME_SIZE];
+ char value[UTIL_NAME_SIZE];
struct sysfs_attr *attr_loop;
struct sysfs_attr *attr;
struct stat statbuf;
if (S_ISLNK(statbuf.st_mode)) {
/* links return the last element of the target path */
- char link_target[PATH_SIZE];
+ char link_target[UTIL_PATH_SIZE];
int len;
const char *pos;
int sysfs_lookup_devpath_by_subsys_id(struct udev *udev, char *devpath_full, size_t len, const char *subsystem, const char *id)
{
size_t sysfs_len;
- char path_full[PATH_SIZE];
+ char path_full[UTIL_PATH_SIZE];
char *path;
struct stat statbuf;
}
if (strcmp(subsystem, "drivers") == 0) {
- char subsys[NAME_SIZE];
+ char subsys[UTIL_NAME_SIZE];
char *driver;
util_strlcpy(subsys, id, sizeof(subsys));
return 0;
found:
if (S_ISLNK(statbuf.st_mode))
- sysfs_resolve_link(udev, path, sizeof(path_full) - sysfs_len);
+ util_resolve_sys_link(udev, path, sizeof(path_full) - sysfs_len);
util_strlcpy(devpath_full, path, len);
return 1;
}
{
struct dirent *ent;
DIR *dir;
- char filename[PATH_SIZE];
+ char filename[UTIL_PATH_SIZE];
dbg(udev, "open directory '%s'\n", dirname);
dir = opendir(dirname);
if (ent == NULL || ent->d_name[0] == '\0')
break;
- if ((ent->d_name[0] == '.') || (ent->d_name[0] == COMMENT_CHARACTER))
+ if ((ent->d_name[0] == '.') || (ent->d_name[0] == '#'))
continue;
/* look for file matching with specified suffix */
int create_path(struct udev *udev, const char *path)
{
- char p[PATH_SIZE];
+ char p[UTIL_PATH_SIZE];
char *pos;
struct stat stats;
int ret;
int delete_path(struct udev *udev, const char *path)
{
- char p[PATH_SIZE];
+ char p[UTIL_PATH_SIZE];
char *pos;
int retval;
static void print_all_attributes(struct udev *udev, const char *devpath, const char *key)
{
- char path[PATH_SIZE];
+ char path[UTIL_PATH_SIZE];
DIR *dir;
struct dirent *dent;
if (dir != NULL) {
for (dent = readdir(dir); dent != NULL; dent = readdir(dir)) {
struct stat statbuf;
- char filename[PATH_SIZE];
+ char filename[UTIL_PATH_SIZE];
char *attr_value;
- char value[NAME_SIZE];
+ char value[UTIL_NAME_SIZE];
size_t len;
if (dent->d_name[0] == '.')
/* select the device that seems to match */
list_for_each_entry(device, &name_list, node) {
struct udevice *udevice_loop;
- char filename[PATH_SIZE];
+ char filename[UTIL_PATH_SIZE];
struct stat statbuf;
udevice_loop = udev_device_init(udev);
QUERY_ALL,
} query = QUERY_NONE;
- char path[PATH_SIZE] = "";
- char name[PATH_SIZE] = "";
+ char path[UTIL_PATH_SIZE] = "";
+ char name[UTIL_PATH_SIZE] = "";
struct name_entry *name_loop;
int rc = 0;
util_remove_trailing_chars(path, '/');
/* possibly resolve to real devpath */
- if (sysfs_resolve_link(udev, path, sizeof(path)) != 0) {
- char temp[PATH_SIZE];
+ if (util_resolve_sys_link(udev, path, sizeof(path)) != 0) {
+ char temp[UTIL_PATH_SIZE];
char *pos;
/* also check if the parent is a link */
util_strlcpy(temp, path, sizeof(temp));
pos = strrchr(temp, '/');
if (pos != 0) {
- char tail[PATH_SIZE];
+ char tail[UTIL_PATH_SIZE];
util_strlcpy(tail, pos, sizeof(tail));
pos[0] = '\0';
- if (sysfs_resolve_link(udev, temp, sizeof(temp)) == 0) {
+ if (util_resolve_sys_link(udev, temp, sizeof(temp)) == 0) {
util_strlcpy(path, temp, sizeof(path));
util_strlcat(path, tail, sizeof(path));
}
printf("\n\nAfter the udevadm settle timeout, the events queue contains:\n\n");
list_for_each_entry(item, &files, node) {
- char target[NAME_SIZE];
+ char target[UTIL_NAME_SIZE];
size_t len;
const char *filename = strrchr(item->name, '/');
int udevadm_settle(struct udev *udev, int argc, char *argv[])
{
- char queuename[PATH_SIZE];
- char filename[PATH_SIZE];
+ char queuename[UTIL_PATH_SIZE];
+ char filename[UTIL_PATH_SIZE];
unsigned long long seq_kernel;
unsigned long long seq_udev;
char seqnum[32];
static int import_uevent_var(struct udev *udev, const char *devpath)
{
- char path[PATH_SIZE];
+ char path[UTIL_PATH_SIZE];
static char value[4096]; /* must stay, used with putenv */
ssize_t size;
int fd;
struct name_entry *name_loop;
list_for_each_entry(name_loop, &udevice->run_list, node) {
- char program[PATH_SIZE];
+ char program[UTIL_PATH_SIZE];
util_strlcpy(program, name_loop->name, sizeof(program));
udev_rules_apply_format(udevice, program, sizeof(program));
static int device_list_insert(struct udev *udev, const char *path)
{
- char filename[PATH_SIZE];
- char devpath[PATH_SIZE];
+ char filename[UTIL_PATH_SIZE];
+ char devpath[UTIL_PATH_SIZE];
struct stat statbuf;
dbg(udev, "add '%s'\n" , path);
if (lstat(path, &statbuf) < 0)
return -1;
if (S_ISLNK(statbuf.st_mode))
- if (sysfs_resolve_link(udev, devpath, sizeof(devpath)) != 0)
+ if (util_resolve_sys_link(udev, devpath, sizeof(devpath)) != 0)
return -1;
name_list_add(udev, &device_list, devpath, 1);
static void trigger_uevent(struct udev *udev, const char *devpath, const char *action)
{
- char filename[PATH_SIZE];
+ char filename[UTIL_PATH_SIZE];
int fd;
util_strlcpy(filename, udev_get_sys_path(udev), sizeof(filename));
char buf[4096];
size_t bufpos = 0;
ssize_t count;
- char path[PATH_SIZE];
+ char path[UTIL_PATH_SIZE];
int fd;
- char link_target[PATH_SIZE];
+ char link_target[UTIL_PATH_SIZE];
int len;
int err = 0;
static int attr_match(const char *path, const char *attr_value)
{
- char attr[NAME_SIZE];
- char file[PATH_SIZE];
+ char attr[UTIL_NAME_SIZE];
+ char file[UTIL_PATH_SIZE];
char *match_value;
util_strlcpy(attr, attr_value, sizeof(attr));
if (match_value != NULL) {
/* match file content */
- char value[NAME_SIZE];
+ char value[UTIL_NAME_SIZE];
int fd;
ssize_t size;
static void scan_subsystem(struct udev *udev, const char *subsys, enum scan_type scan)
{
- char base[PATH_SIZE];
+ char base[UTIL_PATH_SIZE];
DIR *dir;
struct dirent *dent;
const char *subdir;
dir = opendir(base);
if (dir != NULL) {
for (dent = readdir(dir); dent != NULL; dent = readdir(dir)) {
- char dirname[PATH_SIZE];
+ char dirname[UTIL_PATH_SIZE];
DIR *dir2;
struct dirent *dent2;
dir2 = opendir(dirname);
if (dir2 != NULL) {
for (dent2 = readdir(dir2); dent2 != NULL; dent2 = readdir(dir2)) {
- char dirname2[PATH_SIZE];
+ char dirname2[UTIL_PATH_SIZE];
if (dent2->d_name[0] == '.')
continue;
static void scan_block(struct udev *udev)
{
- char base[PATH_SIZE];
+ char base[UTIL_PATH_SIZE];
DIR *dir;
struct dirent *dent;
dir = opendir(base);
if (dir != NULL) {
for (dent = readdir(dir); dent != NULL; dent = readdir(dir)) {
- char dirname[PATH_SIZE];
+ char dirname[UTIL_PATH_SIZE];
DIR *dir2;
struct dirent *dent2;
dir2 = opendir(dirname);
if (dir2 != NULL) {
for (dent2 = readdir(dir2); dent2 != NULL; dent2 = readdir(dir2)) {
- char dirname2[PATH_SIZE];
+ char dirname2[UTIL_PATH_SIZE];
if (dent2->d_name[0] == '.')
continue;
static void scan_class(struct udev *udev)
{
- char base[PATH_SIZE];
+ char base[UTIL_PATH_SIZE];
DIR *dir;
struct dirent *dent;
dir = opendir(base);
if (dir != NULL) {
for (dent = readdir(dir); dent != NULL; dent = readdir(dir)) {
- char dirname[PATH_SIZE];
+ char dirname[UTIL_PATH_SIZE];
DIR *dir2;
struct dirent *dent2;
dir2 = opendir(dirname);
if (dir2 != NULL) {
for (dent2 = readdir(dir2); dent2 != NULL; dent2 = readdir(dir2)) {
- char dirname2[PATH_SIZE];
+ char dirname2[UTIL_PATH_SIZE];
if (dent2->d_name[0] == '.')
continue;
static void scan_failed(struct udev *udev)
{
- char base[PATH_SIZE];
+ char base[UTIL_PATH_SIZE];
DIR *dir;
struct dirent *dent;
dir = opendir(base);
if (dir != NULL) {
for (dent = readdir(dir); dent != NULL; dent = readdir(dir)) {
- char device[PATH_SIZE];
+ char device[UTIL_PATH_SIZE];
size_t start;
if (dent->d_name[0] == '.')
scan_failed(udev);
exec_list(udev, action, env);
} else {
- char base[PATH_SIZE];
+ char base[UTIL_PATH_SIZE];
struct stat statbuf;
/* if we have /sys/subsystem, forget all the old stuff */
static void export_event_state(struct udevd_uevent_msg *msg, enum event_state state)
{
- char filename[PATH_SIZE];
- char filename_failed[PATH_SIZE];
+ char filename[UTIL_PATH_SIZE];
+ char filename_failed[UTIL_PATH_SIZE];
size_t start;
/* location of queue file */
case EVENT_FINISHED:
if (msg->devpath_old != NULL) {
/* "move" event - rename failed file to current name, do not delete failed */
- char filename_failed_old[PATH_SIZE];
+ char filename_failed_old[UTIL_PATH_SIZE];
util_strlcpy(filename_failed_old, udev_get_dev_path(msg->udev), sizeof(filename_failed_old));
util_strlcat(filename_failed_old, "/", sizeof(filename_failed_old));
static void msg_queue_insert(struct udevd_uevent_msg *msg)
{
- char filename[PATH_SIZE];
+ char filename[UTIL_PATH_SIZE];
int fd;
msg->queue_time = time(NULL);
{
int i;
- for (i = 0; i < PATH_SIZE; i++) {
+ for (i = 0; i < UTIL_PATH_SIZE; i++) {
/* identical device event found */
if (running[i] == '\0' && waiting[i] == '\0')
return 1;
static void export_initial_seqnum(struct udev *udev)
{
- char filename[PATH_SIZE];
+ char filename[UTIL_PATH_SIZE];
int fd;
char seqnum[32];
ssize_t len = 0;