chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
gpt-auto-generator: there's no point in looking for a superblock on raw disk, we...
[elogind.git]
/
src
/
udev
/
udevadm-test.c
diff --git
a/src/udev/udevadm-test.c
b/src/udev/udevadm-test.c
index 65e9f3ecca31f23b7ed726a42bb60c988bf25ed7..6cd311b27db4ca559ceb14da3068abd359013107 100644
(file)
--- a/
src/udev/udevadm-test.c
+++ b/
src/udev/udevadm-test.c
@@
-1,6
+1,6
@@
/*
* Copyright (C) 2003-2004 Greg Kroah-Hartman <greg@kroah.com>
/*
* Copyright (C) 2003-2004 Greg Kroah-Hartman <greg@kroah.com>
- * Copyright (C) 2004-2008 Kay Sievers <kay
.sievers
@vrfy.org>
+ * Copyright (C) 2004-2008 Kay Sievers <kay@vrfy.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@
-30,6
+30,7
@@
#include <sys/signalfd.h>
#include "udev.h"
#include <sys/signalfd.h>
#include "udev.h"
+#include "udev-util.h"
static int adm_test(struct udev *udev, int argc, char *argv[])
{
static int adm_test(struct udev *udev, int argc, char *argv[])
{
@@
-37,13
+38,13
@@
static int adm_test(struct udev *udev, int argc, char *argv[])
char filename[UTIL_PATH_SIZE];
const char *action = "add";
const char *syspath = NULL;
char filename[UTIL_PATH_SIZE];
const char *action = "add";
const char *syspath = NULL;
- struct udev_event *event = NULL;
- struct udev_device *dev = NULL;
- struct udev_rules *rules = NULL;
struct udev_list_entry *entry;
struct udev_list_entry *entry;
+ _cleanup_udev_rules_unref_ struct udev_rules *rules = NULL;
+ _cleanup_udev_device_unref_ struct udev_device *dev = NULL;
+ _cleanup_udev_event_unref_ struct udev_event *event = NULL;
sigset_t mask, sigmask_orig;
int err;
sigset_t mask, sigmask_orig;
int err;
- int rc = 0;
+ int rc = 0
, c
;
static const struct option options[] = {
{ "action", required_argument, NULL, 'a' },
static const struct option options[] = {
{ "action", required_argument, NULL, 'a' },
@@
-52,43
+53,40
@@
static int adm_test(struct udev *udev, int argc, char *argv[])
{}
};
{}
};
- log_debug("version %s
\n
", VERSION);
+ log_debug("version %s", VERSION);
- for (;;) {
- int option;
-
- option = getopt_long(argc, argv, "a:s:N:fh", options, NULL);
- if (option == -1)
- break;
-
- switch (option) {
+ while((c = getopt_long(argc, argv, "a:N:h", options, NULL)) >= 0)
+ switch (c) {
case 'a':
action = optarg;
break;
case 'N':
case 'a':
action = optarg;
break;
case 'N':
- if (str
cmp (optarg, "early") == 0
) {
+ if (str
eq (optarg, "early")
) {
resolve_names = 1;
resolve_names = 1;
- } else if (str
cmp (optarg, "late") == 0
) {
+ } else if (str
eq (optarg, "late")
) {
resolve_names = 0;
resolve_names = 0;
- } else if (str
cmp (optarg, "never") == 0
) {
+ } else if (str
eq (optarg, "never")
) {
resolve_names = -1;
} else {
fprintf(stderr, "resolve-names must be early, late or never\n");
resolve_names = -1;
} else {
fprintf(stderr, "resolve-names must be early, late or never\n");
- log_error("resolve-names must be early, late or never
\n
");
+ log_error("resolve-names must be early, late or never");
exit(EXIT_FAILURE);
}
break;
case 'h':
printf("Usage: udevadm test OPTIONS <syspath>\n"
exit(EXIT_FAILURE);
}
break;
case 'h':
printf("Usage: udevadm test OPTIONS <syspath>\n"
- " --action=<string> set action string\n"
- " --help\n\n");
+ " -a,--action=ACTION set action string\n"
+ " -N,--resolve-names=early|late|never when to resolve names\n"
+ " -h,--help print this help string\n"
+ "\n");
exit(EXIT_SUCCESS);
exit(EXIT_SUCCESS);
-
default
:
+
case '?'
:
exit(EXIT_FAILURE);
exit(EXIT_FAILURE);
+ default:
+ assert_not_reached("Unknown option");
}
}
- }
- syspath = argv[optind];
+ syspath = argv[optind];
if (syspath == NULL) {
fprintf(stderr, "syspath parameter missing\n");
rc = 2;
if (syspath == NULL) {
fprintf(stderr, "syspath parameter missing\n");
rc = 2;
@@
-113,9
+111,9
@@
static int adm_test(struct udev *udev, int argc, char *argv[])
/* add /sys if needed */
if (!startswith(syspath, "/sys"))
/* add /sys if needed */
if (!startswith(syspath, "/sys"))
-
util_
strscpyl(filename, sizeof(filename), "/sys", syspath, NULL);
+ strscpyl(filename, sizeof(filename), "/sys", syspath, NULL);
else
else
-
util_
strscpy(filename, sizeof(filename), syspath);
+ strscpy(filename, sizeof(filename), syspath);
util_remove_trailing_chars(filename, '/');
dev = udev_device_new_from_syspath(udev, filename);
util_remove_trailing_chars(filename, '/');
dev = udev_device_new_from_syspath(udev, filename);
@@
-157,9
+155,6
@@
static int adm_test(struct udev *udev, int argc, char *argv[])
out:
if (event != NULL && event->fd_signal >= 0)
close(event->fd_signal);
out:
if (event != NULL && event->fd_signal >= 0)
close(event->fd_signal);
- udev_event_unref(event);
- udev_device_unref(dev);
- udev_rules_unref(rules);
udev_builtin_exit(udev);
return rc;
}
udev_builtin_exit(udev);
return rc;
}