1
0
mirror of https://github.com/systemd/systemd.git synced 2025-01-27 18:04:05 +03:00

use size definitions from libudev

This commit is contained in:
Kay Sievers 2008-09-10 21:50:21 +02:00
parent 31c1f53745
commit 17fcfb5972
17 changed files with 139 additions and 183 deletions

View File

@ -31,10 +31,6 @@ AC_CHECK_LIB(c, inotify_init,
[AC_DEFINE([HAVE_INOTIFY], 1, [inotify available])], [AC_DEFINE([HAVE_INOTIFY], 1, [inotify available])],
[AC_MSG_WARN([inotify support disabled])]) [AC_MSG_WARN([inotify support disabled])])
AC_CHECK_LIB(c, strlcpy,
[AC_DEFINE([HAVE_STRLCPY], 1, [strlcpy available])],
[])
AC_ARG_WITH(udev-prefix, AC_ARG_WITH(udev-prefix,
AS_HELP_STRING([--with-udev-prefix=DIR], [add prefix to internal udev path names]), AS_HELP_STRING([--with-udev-prefix=DIR], [add prefix to internal udev path names]),
[], [with_udev_prefix='${exec_prefix}']) [], [with_udev_prefix='${exec_prefix}'])

View File

@ -125,7 +125,7 @@ int main(int argc, char *argv[])
/* lookup signature in sysfs to determine the name */ /* lookup signature in sysfs to determine the name */
for (dent = readdir(dir); dent != NULL; dent = readdir(dir)) { for (dent = readdir(dir); dent != NULL; dent = readdir(dir)) {
char file[PATH_SIZE]; char file[UTIL_PATH_SIZE];
char sysfs_id_buf[256]; char sysfs_id_buf[256];
uint32_t sysfs_id; uint32_t sysfs_id;
ssize_t size; ssize_t size;

View File

@ -332,7 +332,7 @@ const char *udev_device_get_devname(struct udev_device *udev_device)
**/ **/
const char *udev_device_get_subsystem(struct udev_device *udev_device) 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) if (udev_device == NULL)
return NULL; return NULL;
@ -398,7 +398,7 @@ int udev_device_get_properties(struct udev_device *udev_device,
if (udev_device == NULL) if (udev_device == NULL)
return -1; return -1;
list_for_each_entry(name_loop, &udev_device->env_list, node) { list_for_each_entry(name_loop, &udev_device->env_list, node) {
char name[UTIL_PATH_SIZE]; char name[UTIL_NAME_SIZE];
char *val; char *val;
strncpy(name, name_loop->name, sizeof(name)); strncpy(name, name_loop->name, sizeof(name));
@ -416,7 +416,7 @@ int udev_device_get_properties(struct udev_device *udev_device,
const char *udev_device_get_driver(struct udev_device *udev_device) 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) if (udev_device == NULL)
return NULL; return NULL;

View File

@ -105,7 +105,8 @@ extern int udev_ctrl_get_set_max_childs(struct udev_ctrl_msg *ctrl_msg);
/* libudev-utils */ /* libudev-utils */
#define UTIL_PATH_SIZE 1024 #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 util_name_entry {
struct list_head node; struct list_head node;
char *name; char *name;

View File

@ -30,12 +30,6 @@
#include "lib/libudev-private.h" #include "lib/libudev-private.h"
#include "lib/list.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 "#+-.:=@_"
#define ALLOWED_CHARS_FILE ALLOWED_CHARS "/" #define ALLOWED_CHARS_FILE ALLOWED_CHARS "/"
#define ALLOWED_CHARS_INPUT ALLOWED_CHARS_FILE " $%?," #define ALLOWED_CHARS_INPUT ALLOWED_CHARS_FILE " $%?,"
@ -60,11 +54,11 @@ struct udev_rules;
struct sysfs_device { struct sysfs_device {
struct list_head node; /* for device cache */ struct list_head node; /* for device cache */
struct sysfs_device *parent; /* already cached parent*/ struct sysfs_device *parent; /* already cached parent*/
char devpath[PATH_SIZE]; char devpath[UTIL_PATH_SIZE];
char subsystem[NAME_SIZE]; /* $class, $bus, drivers, module */ char subsystem[UTIL_NAME_SIZE];
char kernel[NAME_SIZE]; /* device instance name */ char kernel[UTIL_NAME_SIZE]; /* device instance name */
char kernel_number[NAME_SIZE]; char kernel_number[UTIL_NAME_SIZE];
char driver[NAME_SIZE]; /* device driver name */ char driver[UTIL_NAME_SIZE];
}; };
struct udevice { struct udevice {
@ -74,16 +68,16 @@ struct udevice {
struct sysfs_device *dev; /* points to dev_local by default */ struct sysfs_device *dev; /* points to dev_local by default */
struct sysfs_device dev_local; struct sysfs_device dev_local;
struct sysfs_device *dev_parent; /* current parent device used for matching */ struct sysfs_device *dev_parent; /* current parent device used for matching */
char action[NAME_SIZE]; char action[UTIL_NAME_SIZE];
char *devpath_old; char *devpath_old;
/* node */ /* node */
char name[PATH_SIZE]; char name[UTIL_PATH_SIZE];
struct list_head symlink_list; struct list_head symlink_list;
int symlink_final; int symlink_final;
char owner[NAME_SIZE]; char owner[UTIL_NAME_SIZE];
int owner_final; int owner_final;
char group[NAME_SIZE]; char group[UTIL_NAME_SIZE];
int group_final; int group_final;
mode_t mode; mode_t mode;
int mode_final; int mode_final;
@ -93,11 +87,11 @@ struct udevice {
struct list_head run_list; struct list_head run_list;
int run_final; int run_final;
struct list_head env_list; struct list_head env_list;
char tmp_node[PATH_SIZE]; char tmp_node[UTIL_PATH_SIZE];
int partitions; int partitions;
int ignore_device; int ignore_device;
int ignore_remove; int ignore_remove;
char program_result[PATH_SIZE]; char program_result[UTIL_PATH_SIZE];
int link_priority; int link_priority;
int event_timeout; int event_timeout;
int test_run; int test_run;
@ -138,7 +132,6 @@ extern struct sysfs_device *sysfs_device_get(struct udev *udev, const char *devp
extern struct sysfs_device *sysfs_device_get_parent(struct udev *udev, struct sysfs_device *dev); 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 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 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); 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_node.c */
@ -158,11 +151,9 @@ extern int udev_db_get_all_entries(struct udev *udevconst, struct list_head *nam
/* udev_utils.c */ /* udev_utils.c */
struct name_entry { struct name_entry {
struct list_head node; struct list_head node;
char name[PATH_SIZE]; char name[UTIL_PATH_SIZE];
unsigned int ignore_error:1; 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_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 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); extern int name_list_key_remove(struct udev *udev, struct list_head *name_list, const char *key);

View File

@ -44,8 +44,8 @@ static size_t devpath_to_db_path(struct udev *udev, const char *devpath, char *f
/* reverse mapping from the device file name to the devpath */ /* 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) static int name_index(struct udev *udev, const char *devpath, const char *name, int add)
{ {
char device[PATH_SIZE]; char device[UTIL_PATH_SIZE];
char filename[PATH_SIZE * 2]; char filename[UTIL_PATH_SIZE * 2];
size_t start; size_t start;
int fd; int fd;
@ -96,7 +96,7 @@ int udev_db_get_devices_by_name(struct udev *udev, const char *name, struct list
info(udev, "found index directory '%s'\n", dirname); info(udev, "found index directory '%s'\n", dirname);
while (1) { while (1) {
struct dirent *ent; struct dirent *ent;
char device[PATH_SIZE]; char device[UTIL_PATH_SIZE];
ent = readdir(dir); ent = readdir(dir);
if (ent == NULL || ent->d_name[0] == '\0') if (ent == NULL || ent->d_name[0] == '\0')
@ -116,8 +116,8 @@ out:
int udev_db_rename(struct udev *udev, const char *devpath_old, const char *devpath) int udev_db_rename(struct udev *udev, const char *devpath_old, const char *devpath)
{ {
char filename[PATH_SIZE]; char filename[UTIL_PATH_SIZE];
char filename_old[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_old, filename_old, sizeof(filename_old));
devpath_to_db_path(udev, devpath, filename, sizeof(filename)); devpath_to_db_path(udev, devpath, filename, sizeof(filename));
@ -126,7 +126,7 @@ int udev_db_rename(struct udev *udev, const char *devpath_old, const char *devpa
int udev_db_add_device(struct udevice *udevice) int udev_db_add_device(struct udevice *udevice)
{ {
char filename[PATH_SIZE]; char filename[UTIL_PATH_SIZE];
if (udevice->test_run) if (udevice->test_run)
return 0; return 0;
@ -190,8 +190,8 @@ int udev_db_add_device(struct udevice *udevice)
int udev_db_get_device(struct udevice *udevice, const char *devpath) int udev_db_get_device(struct udevice *udevice, const char *devpath)
{ {
struct stat stats; struct stat stats;
char filename[PATH_SIZE]; char filename[UTIL_PATH_SIZE];
char line[PATH_SIZE]; char line[UTIL_PATH_SIZE];
unsigned int maj, min; unsigned int maj, min;
char *bufline; char *bufline;
char *buf; char *buf;
@ -207,7 +207,7 @@ int udev_db_get_device(struct udevice *udevice, const char *devpath)
return -1; return -1;
} }
if ((stats.st_mode & S_IFMT) == S_IFLNK) { if ((stats.st_mode & S_IFMT) == S_IFLNK) {
char target[NAME_SIZE]; char target[UTIL_NAME_SIZE];
int target_len; int target_len;
info(udevice->udev, "found a symlink as db file\n"); info(udevice->udev, "found a symlink as db file\n");
@ -277,7 +277,7 @@ int udev_db_get_device(struct udevice *udevice, const char *devpath)
int udev_db_delete_device(struct udevice *udevice) int udev_db_delete_device(struct udevice *udevice)
{ {
char filename[PATH_SIZE]; char filename[UTIL_PATH_SIZE];
struct name_entry *name_loop; struct name_entry *name_loop;
if (udevice->test_run) if (udevice->test_run)
@ -308,7 +308,7 @@ int udev_db_get_all_entries(struct udev *udev, struct list_head *name_list)
while (1) { while (1) {
struct dirent *ent; struct dirent *ent;
char device[PATH_SIZE]; char device[UTIL_PATH_SIZE];
ent = readdir(dir); ent = readdir(dir);
if (ent == NULL || ent->d_name[0] == '\0') if (ent == NULL || ent->d_name[0] == '\0')

View File

@ -34,7 +34,7 @@
int udev_node_mknod(struct udevice *udevice, const char *file, dev_t devt, mode_t mode, uid_t uid, gid_t gid) 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; struct stat stats;
int preserve = 0; int preserve = 0;
int err = 0; int err = 0;
@ -104,8 +104,8 @@ exit:
static int node_symlink(struct udevice *udevice, const char *node, const char *slink) static int node_symlink(struct udevice *udevice, const char *node, const char *slink)
{ {
struct stat stats; struct stat stats;
char target[PATH_SIZE] = ""; char target[UTIL_PATH_SIZE] = "";
char slink_tmp[PATH_SIZE + sizeof(TMP_FILE_EXT)]; char slink_tmp[UTIL_PATH_SIZE + sizeof(TMP_FILE_EXT)];
int i = 0; int i = 0;
int tail = 0; int tail = 0;
int len; int len;
@ -140,7 +140,7 @@ static int node_symlink(struct udevice *udevice, const char *node, const char *s
} }
} }
} else if (S_ISLNK(stats.st_mode)) { } 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); info(udevice->udev, "found existing symlink '%s'\n", slink);
len = readlink(slink, buf, sizeof(buf)); len = readlink(slink, buf, sizeof(buf));
@ -186,11 +186,11 @@ exit:
static int update_link(struct udevice *udevice, const char *name) static int update_link(struct udevice *udevice, const char *name)
{ {
LIST_HEAD(name_list); LIST_HEAD(name_list);
char slink[PATH_SIZE]; char slink[UTIL_PATH_SIZE];
char node[PATH_SIZE]; char node[UTIL_PATH_SIZE];
struct udevice *udevice_db; struct udevice *udevice_db;
struct name_entry *device; struct name_entry *device;
char target[PATH_MAX] = ""; char target[UTIL_PATH_SIZE] = "";
int count; int count;
int priority = 0; int priority = 0;
int rc = 0; int rc = 0;
@ -271,7 +271,7 @@ out:
void udev_node_update_symlinks(struct udevice *udevice, struct udevice *udevice_old) void udev_node_update_symlinks(struct udevice *udevice, struct udevice *udevice_old)
{ {
struct name_entry *name_loop; struct name_entry *name_loop;
char symlinks[PATH_SIZE] = ""; char symlinks[UTIL_PATH_SIZE] = "";
list_for_each_entry(name_loop, &udevice->symlink_list, node) { 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); info(udevice->udev, "update symlink '%s' of '%s'\n", name_loop->name, udevice->dev->devpath);
@ -321,7 +321,7 @@ void udev_node_update_symlinks(struct udevice *udevice, struct udevice *udevice_
int udev_node_add(struct udevice *udevice) int udev_node_add(struct udevice *udevice)
{ {
char filename[PATH_SIZE]; char filename[UTIL_PATH_SIZE];
uid_t uid; uid_t uid;
gid_t gid; gid_t gid;
int i; int i;
@ -371,7 +371,7 @@ int udev_node_add(struct udevice *udevice)
/* create all_partitions if requested */ /* create all_partitions if requested */
if (udevice->partitions) { if (udevice->partitions) {
char partitionname[PATH_SIZE]; char partitionname[UTIL_PATH_SIZE];
char *attr; char *attr;
int range; int range;
@ -400,8 +400,8 @@ exit:
int udev_node_remove(struct udevice *udevice) int udev_node_remove(struct udevice *udevice)
{ {
char filename[PATH_SIZE]; char filename[UTIL_PATH_SIZE];
char partitionname[PATH_SIZE]; char partitionname[UTIL_PATH_SIZE];
struct stat stats; struct stat stats;
int retval = 0; int retval = 0;
int num; int num;

View File

@ -123,8 +123,8 @@ static int run_program(struct udev *udev, const char *command, const char *subsy
int outpipe[2] = {-1, -1}; int outpipe[2] = {-1, -1};
int errpipe[2] = {-1, -1}; int errpipe[2] = {-1, -1};
pid_t pid; pid_t pid;
char arg[PATH_SIZE]; char arg[UTIL_PATH_SIZE];
char program[PATH_SIZE]; char program[UTIL_PATH_SIZE];
char *argv[(sizeof(arg) / 2) + 1]; char *argv[(sizeof(arg) / 2) + 1];
int devnull; int devnull;
int i; int i;
@ -331,7 +331,7 @@ static int run_program(struct udev *udev, const char *command, const char *subsy
static int import_keys_into_env(struct udevice *udevice, const char *buf, size_t bufsize) 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; const char *bufline;
char *linepos; char *linepos;
char *variable; char *variable;
@ -358,7 +358,7 @@ static int import_keys_into_env(struct udevice *udevice, const char *buf, size_t
continue; continue;
/* see if this is a comment */ /* see if this is a comment */
if (bufline[0] == COMMENT_CHARACTER) if (bufline[0] == '#')
continue; continue;
if (count >= sizeof(line)) { if (count >= sizeof(line)) {
@ -429,7 +429,7 @@ static int import_parent_into_env(struct udevice *udevice, const char *filter)
if (udev_db_get_device(udev_parent, dev_parent->devpath) == 0) { if (udev_db_get_device(udev_parent, dev_parent->devpath) == 0) {
dbg(udevice->udev, "import stored parent env '%s'\n", udev_parent->name); dbg(udevice->udev, "import stored parent env '%s'\n", udev_parent->name);
list_for_each_entry(name_loop, &udev_parent->env_list, node) { list_for_each_entry(name_loop, &udev_parent->env_list, node) {
char name[NAME_SIZE]; char name[UTIL_NAME_SIZE];
char *pos; char *pos;
util_strlcpy(name, name_loop->name, sizeof(name)); util_strlcpy(name, name_loop->name, sizeof(name));
@ -512,7 +512,7 @@ int udev_rules_run(struct udevice *udevice)
if (strncmp(name_loop->name, "socket:", strlen("socket:")) == 0) { 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); pass_env_to_socket(udevice->udev, &name_loop->name[strlen("socket:")], udevice->dev->devpath, udevice->action);
} else { } else {
char program[PATH_SIZE]; char program[UTIL_PATH_SIZE];
util_strlcpy(program, name_loop->name, sizeof(program)); util_strlcpy(program, name_loop->name, sizeof(program));
udev_rules_apply_format(udevice, program, sizeof(program)); udev_rules_apply_format(udevice, program, sizeof(program));
@ -528,8 +528,8 @@ int udev_rules_run(struct udevice *udevice)
#define WAIT_LOOP_PER_SECOND 50 #define WAIT_LOOP_PER_SECOND 50
static int wait_for_file(struct udevice *udevice, const char *file, int timeout) static int wait_for_file(struct udevice *udevice, const char *file, int timeout)
{ {
char filepath[PATH_SIZE]; char filepath[UTIL_PATH_SIZE];
char devicepath[PATH_SIZE] = ""; char devicepath[UTIL_PATH_SIZE] = "";
struct stat stats; struct stat stats;
int loop = timeout * WAIT_LOOP_PER_SECOND; int loop = timeout * WAIT_LOOP_PER_SECOND;
@ -566,7 +566,7 @@ static int wait_for_file(struct udevice *udevice, const char *file, int timeout)
/* handle "[$SUBSYSTEM/$KERNEL]<attribute>" lookup */ /* 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) 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 *pos;
char *id; char *id;
char *attrib; char *attrib;
@ -610,7 +610,7 @@ static int attr_subst_subdir(char *attr, size_t len)
pos = strstr(attr, "/*/"); pos = strstr(attr, "/*/");
if (pos != NULL) { if (pos != NULL) {
char str[PATH_SIZE]; char str[UTIL_PATH_SIZE];
DIR *dir; DIR *dir;
pos[1] = '\0'; pos[1] = '\0';
@ -643,8 +643,8 @@ static int attr_subst_subdir(char *attr, size_t len)
void udev_rules_apply_format(struct udevice *udevice, char *string, size_t maxsize) void udev_rules_apply_format(struct udevice *udevice, char *string, size_t maxsize)
{ {
char temp[PATH_SIZE]; char temp[UTIL_PATH_SIZE];
char temp2[PATH_SIZE]; char temp2[UTIL_PATH_SIZE];
char *head, *tail, *pos, *cpos, *attr, *rest; char *head, *tail, *pos, *cpos, *attr, *rest;
int len; int len;
int i; int i;
@ -825,7 +825,7 @@ found:
if (attr == NULL) if (attr == NULL)
err(udevice->udev, "missing file parameter for attr\n"); err(udevice->udev, "missing file parameter for attr\n");
else { else {
char devpath[PATH_SIZE]; char devpath[UTIL_PATH_SIZE];
char *attrib; char *attrib;
const char *value = NULL; const char *value = NULL;
size_t size; size_t size;
@ -915,7 +915,7 @@ found:
case SUBST_LINKS: case SUBST_LINKS:
if (!list_empty(&udevice->symlink_list)) { if (!list_empty(&udevice->symlink_list)) {
struct name_entry *name_loop; struct name_entry *name_loop;
char symlinks[PATH_SIZE] = ""; char symlinks[UTIL_PATH_SIZE] = "";
list_for_each_entry(name_loop, &udevice->symlink_list, node) { list_for_each_entry(name_loop, &udevice->symlink_list, node) {
util_strlcat(symlinks, name_loop->name, sizeof(symlinks)); util_strlcat(symlinks, name_loop->name, sizeof(symlinks));
@ -971,7 +971,7 @@ static char *key_pair_name(struct udev_rule *rule, struct key_pair *pair)
static int match_key(struct udev *udev, const char *key_name, struct udev_rule *rule, struct key *key, const char *val) 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 *key_value;
char *pos; char *pos;
int match = 0; int match = 0;
@ -1070,8 +1070,8 @@ static int match_rule(struct udevice *udevice, struct udev_rule *rule)
if (rule->test.operation == KEY_OP_MATCH || if (rule->test.operation == KEY_OP_MATCH ||
rule->test.operation == KEY_OP_NOMATCH) { rule->test.operation == KEY_OP_NOMATCH) {
char filename[PATH_SIZE]; char filename[UTIL_PATH_SIZE];
char devpath[PATH_SIZE]; char devpath[UTIL_PATH_SIZE];
char *attr; char *attr;
struct stat statbuf; struct stat statbuf;
int match; int match;
@ -1087,7 +1087,7 @@ static int match_rule(struct udevice *udevice, struct udev_rule *rule)
util_strlcat(filename, attr, sizeof(filename)); util_strlcat(filename, attr, sizeof(filename));
} }
} else if (filename[0] != '/') { } 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_strlcpy(tmp, udev_get_sys_path(udevice->udev), sizeof(tmp));
util_strlcat(tmp, udevice->dev->devpath, sizeof(tmp)); util_strlcat(tmp, udevice->dev->devpath, sizeof(tmp));
@ -1114,7 +1114,7 @@ static int match_rule(struct udevice *udevice, struct udev_rule *rule)
} }
if (rule->wait_for.operation != KEY_OP_UNSET) { if (rule->wait_for.operation != KEY_OP_UNSET) {
char filename[PATH_SIZE]; char filename[UTIL_PATH_SIZE];
int found; int found;
util_strlcpy(filename, key_val(rule, &rule->wait_for), sizeof(filename)); util_strlcpy(filename, key_val(rule, &rule->wait_for), sizeof(filename));
@ -1132,10 +1132,10 @@ static int match_rule(struct udevice *udevice, struct udev_rule *rule)
pair->key.operation == KEY_OP_NOMATCH) { pair->key.operation == KEY_OP_NOMATCH) {
const char *key_name = key_pair_name(rule, pair); const char *key_name = key_pair_name(rule, pair);
const char *key_value = key_val(rule, &pair->key); const char *key_value = key_val(rule, &pair->key);
char devpath[PATH_SIZE]; char devpath[UTIL_PATH_SIZE];
char *attrib; char *attrib;
const char *value = NULL; const char *value = NULL;
char val[VALUE_SIZE]; char val[UTIL_NAME_SIZE];
size_t len; size_t len;
if (attr_get_by_subsys_id(udevice->udev, key_name, devpath, sizeof(devpath), &attrib)) { if (attr_get_by_subsys_id(udevice->udev, key_name, devpath, sizeof(devpath), &attrib)) {
@ -1188,7 +1188,7 @@ static int match_rule(struct udevice *udevice, struct udev_rule *rule)
const char *key_name = key_pair_name(rule, pair); const char *key_name = key_pair_name(rule, pair);
const char *key_value = key_val(rule, &pair->key); const char *key_value = key_val(rule, &pair->key);
const char *value; const char *value;
char val[VALUE_SIZE]; char val[UTIL_NAME_SIZE];
size_t len; size_t len;
value = sysfs_attr_get_value(udevice->udev, udevice->dev_parent->devpath, key_name); value = sysfs_attr_get_value(udevice->udev, udevice->dev_parent->devpath, key_name);
@ -1226,8 +1226,8 @@ try_parent:
/* execute external program */ /* execute external program */
if (rule->program.operation != KEY_OP_UNSET) { if (rule->program.operation != KEY_OP_UNSET) {
char program[PATH_SIZE]; char program[UTIL_PATH_SIZE];
char result[PATH_SIZE]; char result[UTIL_PATH_SIZE];
util_strlcpy(program, key_val(rule, &rule->program), sizeof(program)); util_strlcpy(program, key_val(rule, &rule->program), sizeof(program));
udev_rules_apply_format(udevice, program, sizeof(program)); udev_rules_apply_format(udevice, program, sizeof(program));
@ -1262,7 +1262,7 @@ try_parent:
/* import variables returned from program or or file into environment */ /* import variables returned from program or or file into environment */
if (rule->import.operation != KEY_OP_UNSET) { if (rule->import.operation != KEY_OP_UNSET) {
char import[PATH_SIZE]; char import[UTIL_PATH_SIZE];
int rc = -1; int rc = -1;
util_strlcpy(import, key_val(rule, &rule->import), sizeof(import)); util_strlcpy(import, key_val(rule, &rule->import), sizeof(import));
@ -1291,13 +1291,13 @@ try_parent:
struct key_pair *pair = &rule->env.keys[i]; struct key_pair *pair = &rule->env.keys[i];
if (pair->key.operation == KEY_OP_ASSIGN) { 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 *key_name = key_pair_name(rule, pair);
const char *value = key_val(rule, &pair->key); const char *value = key_val(rule, &pair->key);
/* make sure we don't write to the same string we possibly read from */ /* make sure we don't write to the same string we possibly read from */
util_strlcpy(temp_value, value, sizeof(temp_value)); 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') { if (temp_value[0] == '\0') {
name_list_key_remove(udevice->udev, &udevice->env_list, key_name); name_list_key_remove(udevice->udev, &udevice->env_list, key_name);
@ -1321,10 +1321,10 @@ try_parent:
if (pair->key.operation == KEY_OP_ASSIGN) { if (pair->key.operation == KEY_OP_ASSIGN) {
const char *key_name = key_pair_name(rule, pair); const char *key_name = key_pair_name(rule, pair);
char devpath[PATH_SIZE]; char devpath[UTIL_PATH_SIZE];
char *attrib; char *attrib;
char attr[PATH_SIZE] = ""; char attr[UTIL_PATH_SIZE] = "";
char value[NAME_SIZE]; char value[UTIL_NAME_SIZE];
FILE *f; FILE *f;
if (attr_get_by_subsys_id(udevice->udev, key_name, devpath, sizeof(devpath), &attrib)) { if (attr_get_by_subsys_id(udevice->udev, key_name, devpath, sizeof(devpath), &attrib)) {
@ -1445,7 +1445,7 @@ int udev_rules_get_name(struct udev_rules *rules, struct udevice *udevice)
(rule->symlink.operation == KEY_OP_ASSIGN || (rule->symlink.operation == KEY_OP_ASSIGN ||
rule->symlink.operation == KEY_OP_ASSIGN_FINAL || rule->symlink.operation == KEY_OP_ASSIGN_FINAL ||
rule->symlink.operation == KEY_OP_ADD)) { rule->symlink.operation == KEY_OP_ADD)) {
char temp[PATH_SIZE]; char temp[UTIL_PATH_SIZE];
char *pos, *next; char *pos, *next;
int count; int count;

View File

@ -204,7 +204,7 @@ static char *get_key_attribute(struct udev_rules *rules, char *str)
static int add_rule_key(struct udev_rule *rule, struct key *key, static int add_rule_key(struct udev_rule *rule, struct key *key,
enum key_operation operation, const char *value) 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; key->operation = operation;
@ -218,7 +218,7 @@ static int add_rule_key(struct udev_rule *rule, struct key *key,
static int add_rule_key_pair(struct udev_rules *rules, struct udev_rule *rule, struct key_pairs *pairs, 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) 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) { if (pairs->count >= PAIRS_MAX) {
err(rules->udev, "skip, too many keys of the same type in a single rule\n"); err(rules->udev, "skip, too many keys of the same type in a single rule\n");
@ -239,7 +239,7 @@ static int add_rule_key_pair(struct udev_rules *rules, struct udev_rule *rule, s
static int add_to_rules(struct udev_rules *rules, char *line, const char *filename, unsigned int lineno) 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; struct udev_rule *rule;
size_t rule_size; size_t rule_size;
int valid; int valid;
@ -444,7 +444,7 @@ static int add_to_rules(struct udev_rules *rules, char *line, const char *filena
rule->import_type = IMPORT_PARENT; rule->import_type = IMPORT_PARENT;
} else { } else {
/* figure it out if it is executable */ /* figure it out if it is executable */
char file[PATH_SIZE]; char file[UTIL_PATH_SIZE];
char *pos; char *pos;
struct stat statbuf; struct stat statbuf;
@ -668,7 +668,7 @@ invalid:
static int parse_file(struct udev_rules *rules, const char *filename) static int parse_file(struct udev_rules *rules, const char *filename)
{ {
char line[LINE_SIZE]; char line[UTIL_LINE_SIZE];
char *bufline; char *bufline;
unsigned int lineno; unsigned int lineno;
char *buf; char *buf;
@ -703,7 +703,7 @@ static int parse_file(struct udev_rules *rules, const char *filename)
continue; continue;
/* see if this is a comment */ /* see if this is a comment */
if (bufline[0] == COMMENT_CHARACTER) if (bufline[0] == '#')
continue; continue;
if (count >= sizeof(line)) { if (count >= sizeof(line)) {

View File

@ -35,9 +35,9 @@ static LIST_HEAD(attr_list);
struct sysfs_attr { struct sysfs_attr {
struct list_head node; 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; /* points to value_local if value is cached */
char value_local[NAME_SIZE]; char value_local[UTIL_NAME_SIZE];
}; };
int sysfs_init(void) int sysfs_init(void)
@ -100,47 +100,15 @@ void sysfs_device_set_values(struct udev *udev,
dbg(udev, "kernel_number='%s'\n", dev->kernel_number); 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) struct sysfs_device *sysfs_device_get(struct udev *udev, const char *devpath)
{ {
char path[PATH_SIZE]; char path[UTIL_PATH_SIZE];
char devpath_real[PATH_SIZE]; char devpath_real[UTIL_PATH_SIZE];
struct sysfs_device *dev; struct sysfs_device *dev;
struct sysfs_device *dev_loop; struct sysfs_device *dev_loop;
struct stat statbuf; struct stat statbuf;
char link_path[PATH_SIZE]; char link_path[UTIL_PATH_SIZE];
char link_target[PATH_SIZE]; char link_target[UTIL_PATH_SIZE];
int len; int len;
char *pos; char *pos;
@ -176,7 +144,7 @@ struct sysfs_device *sysfs_device_get(struct udev *udev, const char *devpath)
return NULL; return NULL;
} }
if (S_ISLNK(statbuf.st_mode)) { 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; return NULL;
/* now look for device in cache after path translation */ /* now look for device in cache after path translation */
@ -248,7 +216,7 @@ struct sysfs_device *sysfs_device_get(struct udev *udev, const char *devpath)
struct sysfs_device *sysfs_device_get_parent(struct udev *udev, struct sysfs_device *dev) 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; char *pos;
dbg(udev, "open '%s'\n", dev->devpath); dbg(udev, "open '%s'\n", dev->devpath);
@ -290,7 +258,7 @@ struct sysfs_device *sysfs_device_get_parent(struct udev *udev, struct sysfs_dev
device_link: device_link:
util_strlcpy(parent_devpath, dev->devpath, sizeof(parent_devpath)); util_strlcpy(parent_devpath, dev->devpath, sizeof(parent_devpath));
util_strlcat(parent_devpath, "/device", 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; return NULL;
/* get parent and remember it */ /* get parent and remember it */
@ -313,9 +281,9 @@ struct sysfs_device *sysfs_device_get_parent_with_subsystem(struct udev *udev, s
char *sysfs_attr_get_value(struct udev *udev, const char *devpath, const char *attr_name) 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; const char *path;
char value[NAME_SIZE]; char value[UTIL_NAME_SIZE];
struct sysfs_attr *attr_loop; struct sysfs_attr *attr_loop;
struct sysfs_attr *attr; struct sysfs_attr *attr;
struct stat statbuf; struct stat statbuf;
@ -357,7 +325,7 @@ char *sysfs_attr_get_value(struct udev *udev, const char *devpath, const char *a
if (S_ISLNK(statbuf.st_mode)) { if (S_ISLNK(statbuf.st_mode)) {
/* links return the last element of the target path */ /* links return the last element of the target path */
char link_target[PATH_SIZE]; char link_target[UTIL_PATH_SIZE];
int len; int len;
const char *pos; const char *pos;
@ -409,7 +377,7 @@ out:
int sysfs_lookup_devpath_by_subsys_id(struct udev *udev, char *devpath_full, size_t len, const char *subsystem, const char *id) 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; size_t sysfs_len;
char path_full[PATH_SIZE]; char path_full[UTIL_PATH_SIZE];
char *path; char *path;
struct stat statbuf; struct stat statbuf;
@ -443,7 +411,7 @@ int sysfs_lookup_devpath_by_subsys_id(struct udev *udev, char *devpath_full, siz
} }
if (strcmp(subsystem, "drivers") == 0) { if (strcmp(subsystem, "drivers") == 0) {
char subsys[NAME_SIZE]; char subsys[UTIL_NAME_SIZE];
char *driver; char *driver;
util_strlcpy(subsys, id, sizeof(subsys)); util_strlcpy(subsys, id, sizeof(subsys));
@ -492,7 +460,7 @@ out:
return 0; return 0;
found: found:
if (S_ISLNK(statbuf.st_mode)) 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); util_strlcpy(devpath_full, path, len);
return 1; return 1;
} }

View File

@ -127,7 +127,7 @@ int add_matching_files(struct udev *udev, struct list_head *name_list, const cha
{ {
struct dirent *ent; struct dirent *ent;
DIR *dir; DIR *dir;
char filename[PATH_SIZE]; char filename[UTIL_PATH_SIZE];
dbg(udev, "open directory '%s'\n", dirname); dbg(udev, "open directory '%s'\n", dirname);
dir = opendir(dirname); dir = opendir(dirname);
@ -141,7 +141,7 @@ int add_matching_files(struct udev *udev, struct list_head *name_list, const cha
if (ent == NULL || ent->d_name[0] == '\0') if (ent == NULL || ent->d_name[0] == '\0')
break; break;
if ((ent->d_name[0] == '.') || (ent->d_name[0] == COMMENT_CHARACTER)) if ((ent->d_name[0] == '.') || (ent->d_name[0] == '#'))
continue; continue;
/* look for file matching with specified suffix */ /* look for file matching with specified suffix */

View File

@ -31,7 +31,7 @@
int create_path(struct udev *udev, const char *path) int create_path(struct udev *udev, const char *path)
{ {
char p[PATH_SIZE]; char p[UTIL_PATH_SIZE];
char *pos; char *pos;
struct stat stats; struct stat stats;
int ret; int ret;
@ -67,7 +67,7 @@ int create_path(struct udev *udev, const char *path)
int delete_path(struct udev *udev, const char *path) int delete_path(struct udev *udev, const char *path)
{ {
char p[PATH_SIZE]; char p[UTIL_PATH_SIZE];
char *pos; char *pos;
int retval; int retval;

View File

@ -34,7 +34,7 @@
static void print_all_attributes(struct udev *udev, const char *devpath, const char *key) 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; DIR *dir;
struct dirent *dent; struct dirent *dent;
@ -45,9 +45,9 @@ static void print_all_attributes(struct udev *udev, const char *devpath, const c
if (dir != NULL) { if (dir != NULL) {
for (dent = readdir(dir); dent != NULL; dent = readdir(dir)) { for (dent = readdir(dir); dent != NULL; dent = readdir(dir)) {
struct stat statbuf; struct stat statbuf;
char filename[PATH_SIZE]; char filename[UTIL_PATH_SIZE];
char *attr_value; char *attr_value;
char value[NAME_SIZE]; char value[UTIL_NAME_SIZE];
size_t len; size_t len;
if (dent->d_name[0] == '.') if (dent->d_name[0] == '.')
@ -180,7 +180,7 @@ static int lookup_device_by_name(struct udev *udev, struct udevice **udevice, co
/* select the device that seems to match */ /* select the device that seems to match */
list_for_each_entry(device, &name_list, node) { list_for_each_entry(device, &name_list, node) {
struct udevice *udevice_loop; struct udevice *udevice_loop;
char filename[PATH_SIZE]; char filename[UTIL_PATH_SIZE];
struct stat statbuf; struct stat statbuf;
udevice_loop = udev_device_init(udev); udevice_loop = udev_device_init(udev);
@ -269,8 +269,8 @@ int udevadm_info(struct udev *udev, int argc, char *argv[])
QUERY_ALL, QUERY_ALL,
} query = QUERY_NONE; } query = QUERY_NONE;
char path[PATH_SIZE] = ""; char path[UTIL_PATH_SIZE] = "";
char name[PATH_SIZE] = ""; char name[UTIL_PATH_SIZE] = "";
struct name_entry *name_loop; struct name_entry *name_loop;
int rc = 0; int rc = 0;
@ -301,19 +301,19 @@ int udevadm_info(struct udev *udev, int argc, char *argv[])
util_remove_trailing_chars(path, '/'); util_remove_trailing_chars(path, '/');
/* possibly resolve to real devpath */ /* possibly resolve to real devpath */
if (sysfs_resolve_link(udev, path, sizeof(path)) != 0) { if (util_resolve_sys_link(udev, path, sizeof(path)) != 0) {
char temp[PATH_SIZE]; char temp[UTIL_PATH_SIZE];
char *pos; char *pos;
/* also check if the parent is a link */ /* also check if the parent is a link */
util_strlcpy(temp, path, sizeof(temp)); util_strlcpy(temp, path, sizeof(temp));
pos = strrchr(temp, '/'); pos = strrchr(temp, '/');
if (pos != 0) { if (pos != 0) {
char tail[PATH_SIZE]; char tail[UTIL_PATH_SIZE];
util_strlcpy(tail, pos, sizeof(tail)); util_strlcpy(tail, pos, sizeof(tail));
pos[0] = '\0'; 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_strlcpy(path, temp, sizeof(path));
util_strlcat(path, tail, sizeof(path)); util_strlcat(path, tail, sizeof(path));
} }

View File

@ -44,7 +44,7 @@ static void print_queue(struct udev *udev, const char *dir)
printf("\n\nAfter the udevadm settle timeout, the events queue contains:\n\n"); printf("\n\nAfter the udevadm settle timeout, the events queue contains:\n\n");
list_for_each_entry(item, &files, node) { list_for_each_entry(item, &files, node) {
char target[NAME_SIZE]; char target[UTIL_NAME_SIZE];
size_t len; size_t len;
const char *filename = strrchr(item->name, '/'); const char *filename = strrchr(item->name, '/');
@ -67,8 +67,8 @@ static void print_queue(struct udev *udev, const char *dir)
int udevadm_settle(struct udev *udev, int argc, char *argv[]) int udevadm_settle(struct udev *udev, int argc, char *argv[])
{ {
char queuename[PATH_SIZE]; char queuename[UTIL_PATH_SIZE];
char filename[PATH_SIZE]; char filename[UTIL_PATH_SIZE];
unsigned long long seq_kernel; unsigned long long seq_kernel;
unsigned long long seq_udev; unsigned long long seq_udev;
char seqnum[32]; char seqnum[32];

View File

@ -33,7 +33,7 @@
static int import_uevent_var(struct udev *udev, const char *devpath) 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 */ static char value[4096]; /* must stay, used with putenv */
ssize_t size; ssize_t size;
int fd; int fd;
@ -189,7 +189,7 @@ int udevadm_test(struct udev *udev, int argc, char *argv[])
struct name_entry *name_loop; struct name_entry *name_loop;
list_for_each_entry(name_loop, &udevice->run_list, node) { 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)); util_strlcpy(program, name_loop->name, sizeof(program));
udev_rules_apply_format(udevice, program, sizeof(program)); udev_rules_apply_format(udevice, program, sizeof(program));

View File

@ -64,8 +64,8 @@ static int delay_device(const char *devpath)
static int device_list_insert(struct udev *udev, const char *path) static int device_list_insert(struct udev *udev, const char *path)
{ {
char filename[PATH_SIZE]; char filename[UTIL_PATH_SIZE];
char devpath[PATH_SIZE]; char devpath[UTIL_PATH_SIZE];
struct stat statbuf; struct stat statbuf;
dbg(udev, "add '%s'\n" , path); dbg(udev, "add '%s'\n" , path);
@ -84,7 +84,7 @@ static int device_list_insert(struct udev *udev, const char *path)
if (lstat(path, &statbuf) < 0) if (lstat(path, &statbuf) < 0)
return -1; return -1;
if (S_ISLNK(statbuf.st_mode)) 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; return -1;
name_list_add(udev, &device_list, devpath, 1); name_list_add(udev, &device_list, devpath, 1);
@ -93,7 +93,7 @@ static int device_list_insert(struct udev *udev, const char *path)
static void trigger_uevent(struct udev *udev, const char *devpath, const char *action) static void trigger_uevent(struct udev *udev, const char *devpath, const char *action)
{ {
char filename[PATH_SIZE]; char filename[UTIL_PATH_SIZE];
int fd; int fd;
util_strlcpy(filename, udev_get_sys_path(udev), sizeof(filename)); util_strlcpy(filename, udev_get_sys_path(udev), sizeof(filename));
@ -125,9 +125,9 @@ static int pass_to_socket(struct udev *udev, const char *devpath, const char *ac
char buf[4096]; char buf[4096];
size_t bufpos = 0; size_t bufpos = 0;
ssize_t count; ssize_t count;
char path[PATH_SIZE]; char path[UTIL_PATH_SIZE];
int fd; int fd;
char link_target[PATH_SIZE]; char link_target[UTIL_PATH_SIZE];
int len; int len;
int err = 0; int err = 0;
@ -285,8 +285,8 @@ static int subsystem_filtered(const char *subsystem)
static int attr_match(const char *path, const char *attr_value) static int attr_match(const char *path, const char *attr_value)
{ {
char attr[NAME_SIZE]; char attr[UTIL_NAME_SIZE];
char file[PATH_SIZE]; char file[UTIL_PATH_SIZE];
char *match_value; char *match_value;
util_strlcpy(attr, attr_value, sizeof(attr)); util_strlcpy(attr, attr_value, sizeof(attr));
@ -304,7 +304,7 @@ static int attr_match(const char *path, const char *attr_value)
if (match_value != NULL) { if (match_value != NULL) {
/* match file content */ /* match file content */
char value[NAME_SIZE]; char value[UTIL_NAME_SIZE];
int fd; int fd;
ssize_t size; ssize_t size;
@ -357,7 +357,7 @@ enum scan_type {
static void scan_subsystem(struct udev *udev, const char *subsys, enum scan_type scan) 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; DIR *dir;
struct dirent *dent; struct dirent *dent;
const char *subdir; const char *subdir;
@ -376,7 +376,7 @@ static void scan_subsystem(struct udev *udev, const char *subsys, enum scan_type
dir = opendir(base); dir = opendir(base);
if (dir != NULL) { if (dir != NULL) {
for (dent = readdir(dir); dent != NULL; dent = readdir(dir)) { for (dent = readdir(dir); dent != NULL; dent = readdir(dir)) {
char dirname[PATH_SIZE]; char dirname[UTIL_PATH_SIZE];
DIR *dir2; DIR *dir2;
struct dirent *dent2; struct dirent *dent2;
@ -406,7 +406,7 @@ static void scan_subsystem(struct udev *udev, const char *subsys, enum scan_type
dir2 = opendir(dirname); dir2 = opendir(dirname);
if (dir2 != NULL) { if (dir2 != NULL) {
for (dent2 = readdir(dir2); dent2 != NULL; dent2 = readdir(dir2)) { for (dent2 = readdir(dir2); dent2 != NULL; dent2 = readdir(dir2)) {
char dirname2[PATH_SIZE]; char dirname2[UTIL_PATH_SIZE];
if (dent2->d_name[0] == '.') if (dent2->d_name[0] == '.')
continue; continue;
@ -427,7 +427,7 @@ static void scan_subsystem(struct udev *udev, const char *subsys, enum scan_type
static void scan_block(struct udev *udev) static void scan_block(struct udev *udev)
{ {
char base[PATH_SIZE]; char base[UTIL_PATH_SIZE];
DIR *dir; DIR *dir;
struct dirent *dent; struct dirent *dent;
@ -440,7 +440,7 @@ static void scan_block(struct udev *udev)
dir = opendir(base); dir = opendir(base);
if (dir != NULL) { if (dir != NULL) {
for (dent = readdir(dir); dent != NULL; dent = readdir(dir)) { for (dent = readdir(dir); dent != NULL; dent = readdir(dir)) {
char dirname[PATH_SIZE]; char dirname[UTIL_PATH_SIZE];
DIR *dir2; DIR *dir2;
struct dirent *dent2; struct dirent *dent2;
@ -459,7 +459,7 @@ static void scan_block(struct udev *udev)
dir2 = opendir(dirname); dir2 = opendir(dirname);
if (dir2 != NULL) { if (dir2 != NULL) {
for (dent2 = readdir(dir2); dent2 != NULL; dent2 = readdir(dir2)) { for (dent2 = readdir(dir2); dent2 != NULL; dent2 = readdir(dir2)) {
char dirname2[PATH_SIZE]; char dirname2[UTIL_PATH_SIZE];
if (dent2->d_name[0] == '.') if (dent2->d_name[0] == '.')
continue; continue;
@ -483,7 +483,7 @@ static void scan_block(struct udev *udev)
static void scan_class(struct udev *udev) static void scan_class(struct udev *udev)
{ {
char base[PATH_SIZE]; char base[UTIL_PATH_SIZE];
DIR *dir; DIR *dir;
struct dirent *dent; struct dirent *dent;
@ -493,7 +493,7 @@ static void scan_class(struct udev *udev)
dir = opendir(base); dir = opendir(base);
if (dir != NULL) { if (dir != NULL) {
for (dent = readdir(dir); dent != NULL; dent = readdir(dir)) { for (dent = readdir(dir); dent != NULL; dent = readdir(dir)) {
char dirname[PATH_SIZE]; char dirname[UTIL_PATH_SIZE];
DIR *dir2; DIR *dir2;
struct dirent *dent2; struct dirent *dent2;
@ -509,7 +509,7 @@ static void scan_class(struct udev *udev)
dir2 = opendir(dirname); dir2 = opendir(dirname);
if (dir2 != NULL) { if (dir2 != NULL) {
for (dent2 = readdir(dir2); dent2 != NULL; dent2 = readdir(dir2)) { for (dent2 = readdir(dir2); dent2 != NULL; dent2 = readdir(dir2)) {
char dirname2[PATH_SIZE]; char dirname2[UTIL_PATH_SIZE];
if (dent2->d_name[0] == '.') if (dent2->d_name[0] == '.')
continue; continue;
@ -533,7 +533,7 @@ static void scan_class(struct udev *udev)
static void scan_failed(struct udev *udev) static void scan_failed(struct udev *udev)
{ {
char base[PATH_SIZE]; char base[UTIL_PATH_SIZE];
DIR *dir; DIR *dir;
struct dirent *dent; struct dirent *dent;
@ -543,7 +543,7 @@ static void scan_failed(struct udev *udev)
dir = opendir(base); dir = opendir(base);
if (dir != NULL) { if (dir != NULL) {
for (dent = readdir(dir); dent != NULL; dent = readdir(dir)) { for (dent = readdir(dir); dent != NULL; dent = readdir(dir)) {
char device[PATH_SIZE]; char device[UTIL_PATH_SIZE];
size_t start; size_t start;
if (dent->d_name[0] == '.') if (dent->d_name[0] == '.')
@ -671,7 +671,7 @@ int udevadm_trigger(struct udev *udev, int argc, char *argv[])
scan_failed(udev); scan_failed(udev);
exec_list(udev, action, env); exec_list(udev, action, env);
} else { } else {
char base[PATH_SIZE]; char base[UTIL_PATH_SIZE];
struct stat statbuf; struct stat statbuf;
/* if we have /sys/subsystem, forget all the old stuff */ /* if we have /sys/subsystem, forget all the old stuff */

View File

@ -168,8 +168,8 @@ enum event_state {
static void export_event_state(struct udevd_uevent_msg *msg, enum event_state state) static void export_event_state(struct udevd_uevent_msg *msg, enum event_state state)
{ {
char filename[PATH_SIZE]; char filename[UTIL_PATH_SIZE];
char filename_failed[PATH_SIZE]; char filename_failed[UTIL_PATH_SIZE];
size_t start; size_t start;
/* location of queue file */ /* location of queue file */
@ -194,7 +194,7 @@ static void export_event_state(struct udevd_uevent_msg *msg, enum event_state st
case EVENT_FINISHED: case EVENT_FINISHED:
if (msg->devpath_old != NULL) { if (msg->devpath_old != NULL) {
/* "move" event - rename failed file to current name, do not delete failed */ /* "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_strlcpy(filename_failed_old, udev_get_dev_path(msg->udev), sizeof(filename_failed_old));
util_strlcat(filename_failed_old, "/", sizeof(filename_failed_old)); util_strlcat(filename_failed_old, "/", sizeof(filename_failed_old));
@ -279,7 +279,7 @@ static void udev_event_run(struct udevd_uevent_msg *msg)
static void msg_queue_insert(struct udevd_uevent_msg *msg) static void msg_queue_insert(struct udevd_uevent_msg *msg)
{ {
char filename[PATH_SIZE]; char filename[UTIL_PATH_SIZE];
int fd; int fd;
msg->queue_time = time(NULL); msg->queue_time = time(NULL);
@ -346,7 +346,7 @@ static int compare_devpath(const char *running, const char *waiting)
{ {
int i; int i;
for (i = 0; i < PATH_SIZE; i++) { for (i = 0; i < UTIL_PATH_SIZE; i++) {
/* identical device event found */ /* identical device event found */
if (running[i] == '\0' && waiting[i] == '\0') if (running[i] == '\0' && waiting[i] == '\0')
return 1; return 1;
@ -750,7 +750,7 @@ static int init_uevent_netlink_sock(struct udev *udev)
static void export_initial_seqnum(struct udev *udev) static void export_initial_seqnum(struct udev *udev)
{ {
char filename[PATH_SIZE]; char filename[UTIL_PATH_SIZE];
int fd; int fd;
char seqnum[32]; char seqnum[32];
ssize_t len = 0; ssize_t len = 0;