chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
[PATCH] support log-priority levels in udev.conf
[elogind.git]
/
udevinfo.c
diff --git
a/udevinfo.c
b/udevinfo.c
index e30a036ac6ee17be4cd2e95cbd8398116beb5f05..3fb37b41e917791538cc65fd0cf68441dea2cfc3 100644
(file)
--- a/
udevinfo.c
+++ b/
udevinfo.c
@@
-27,7
+27,7
@@
#include <errno.h>
#include "libsysfs/sysfs/libsysfs.h"
#include <errno.h>
#include "libsysfs/sysfs/libsysfs.h"
-#include "
libsysfs/dlist
.h"
+#include "
udev_libc_wrapper
.h"
#include "udev.h"
#include "udev_utils.h"
#include "udev_version.h"
#include "udev.h"
#include "udev_utils.h"
#include "udev_version.h"
@@
-35,15
+35,16
@@
#include "logging.h"
#include "logging.h"
-#define SYSFS_VALUE_SIZE 256
-
#ifdef USE_LOG
#ifdef USE_LOG
-void log_message (int
level
, const char *format, ...)
+void log_message (int
priority
, const char *format, ...)
{
va_list args;
{
va_list args;
+ if (priority > udev_log_priority)
+ return;
+
va_start(args, format);
va_start(args, format);
- vsyslog(
level
, format, args);
+ vsyslog(
priority
, format, args);
va_end(args);
}
#endif
va_end(args);
}
#endif
@@
-51,12
+52,12
@@
void log_message (int level, const char *format, ...)
static void print_all_attributes(struct dlist *attr_list)
{
struct sysfs_attribute *attr;
static void print_all_attributes(struct dlist *attr_list)
{
struct sysfs_attribute *attr;
- char value[
SYSFS_
VALUE_SIZE];
+ char value[VALUE_SIZE];
int len;
dlist_for_each_data(attr_list, attr, struct sysfs_attribute) {
if (attr->value != NULL) {
int len;
dlist_for_each_data(attr_list, attr, struct sysfs_attribute) {
if (attr->value != NULL) {
- str
fieldcpy(value, attr->value
);
+ str
lcpy(value, attr->value, sizeof(value)
);
len = strlen(value);
if (len == 0)
continue;
len = strlen(value);
if (len == 0)
continue;
@@
-181,7
+182,7
@@
exit:
}
static int print_dump(const char *devpath, const char *name) {
}
static int print_dump(const char *devpath, const char *name) {
- printf("%s
:
%s/%s\n", devpath, udev_root, name);
+ printf("%s
=
%s/%s\n", devpath, udev_root, name);
return 0;
}
return 0;
}
@@
-193,9
+194,9
@@
int main(int argc, char *argv[], char *envp[])
int root = 0;
int attributes = 0;
enum query_type query = NONE;
int root = 0;
int attributes = 0;
enum query_type query = NONE;
- char path[
NAME
_SIZE] = "";
- char name[
NAME
_SIZE] = "";
- char temp[
NAME
_SIZE];
+ char path[
PATH
_SIZE] = "";
+ char name[
PATH
_SIZE] = "";
+ char temp[
PATH
_SIZE];
struct name_entry *name_loop;
char *pos;
int retval = 0;
struct name_entry *name_loop;
char *pos;
int retval = 0;
@@
-215,12
+216,12
@@
int main(int argc, char *argv[], char *envp[])
switch (option) {
case 'n':
dbg("udev name: %s\n", optarg);
switch (option) {
case 'n':
dbg("udev name: %s\n", optarg);
- str
fieldcpy(name, optarg
);
+ str
lcpy(name, optarg, sizeof(name)
);
break;
case 'p':
dbg("udev path: %s\n", optarg);
break;
case 'p':
dbg("udev path: %s\n", optarg);
- str
fieldcpy(path, optarg
);
+ str
lcpy(path, optarg, sizeof(path)
);
break;
case 'q':
break;
case 'q':
@@
-284,7
+285,7
@@
int main(int argc, char *argv[], char *envp[])
if (path[0] != '/') {
/* prepend '/' if missing */
strcpy(temp, "/");
if (path[0] != '/') {
/* prepend '/' if missing */
strcpy(temp, "/");
- str
fieldcat(temp, path
);
+ str
lcpy(temp, path, sizeof(temp)
);
pos = temp;
} else {
pos = path;
pos = temp;
} else {
pos = path;
@@
-299,7
+300,7
@@
int main(int argc, char *argv[], char *envp[])
}
if (name[0] != '\0') {
}
if (name[0] != '\0') {
- char devpath[
NAME
_SIZE];
+ char devpath[
PATH
_SIZE];
int len;
/* remove udev_root if given */
int len;
/* remove udev_root if given */
@@
-309,7
+310,7
@@
int main(int argc, char *argv[], char *envp[])
} else
pos = name;
} else
pos = name;
- retval = udev_db_search_name(devpath,
DEVPATH_SIZE
, pos);
+ retval = udev_db_search_name(devpath,
sizeof(devpath)
, pos);
if (retval != 0) {
printf("device not found in database\n");
goto exit;
if (retval != 0) {
printf("device not found in database\n");
goto exit;
@@
-360,9
+361,9
@@
print:
} else {
if (strncmp(path, sysfs_path, strlen(sysfs_path)) != 0) {
/* prepend sysfs mountpoint if not given */
} else {
if (strncmp(path, sysfs_path, strlen(sysfs_path)) != 0) {
/* prepend sysfs mountpoint if not given */
- s
trfieldcpy(temp
, path);
-
strfieldcpy(path, sysfs_path)
;
- str
fieldcat(path, temp
);
+ s
nprintf(temp, sizeof(temp), "%s%s", sysfs_path
, path);
+
temp[sizeof(temp)-1] = '\0'
;
+ str
lcpy(path, temp, sizeof(temp)
);
}
print_device_chain(path);
goto exit;
}
print_device_chain(path);
goto exit;