/* SPDX-License-Identifier: GPL-2.0+ */
-/*
- * Copyright (C) 2004-2009 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
- * 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/>.
- */
#include <ctype.h>
#include <errno.h>
#include "dirent-util.h"
#include "fd-util.h"
#include "string-util.h"
-#include "udev-util.h"
#include "udev.h"
+#include "udevadm.h"
#include "udevadm-util.h"
static bool skip_attribute(const char *name) {
return 0;
}
-static int export_devices(struct udev *udev) {
- _cleanup_udev_enumerate_unref_ struct udev_enumerate *udev_enumerate;
+static int export_devices(void) {
+ _cleanup_(udev_enumerate_unrefp) struct udev_enumerate *udev_enumerate;
struct udev_list_entry *list_entry;
- udev_enumerate = udev_enumerate_new(udev);
+ udev_enumerate = udev_enumerate_new(NULL);
if (udev_enumerate == NULL)
return -ENOMEM;
udev_enumerate_scan_devices(udev_enumerate);
udev_list_entry_foreach(list_entry, udev_enumerate_get_list_entry(udev_enumerate)) {
- _cleanup_udev_device_unref_ struct udev_device *device;
+ _cleanup_(udev_device_unrefp) struct udev_device *device;
- device = udev_device_new_from_syspath(udev, udev_list_entry_get_name(list_entry));
+ device = udev_device_new_from_syspath(NULL, udev_list_entry_get_name(list_entry));
if (device != NULL)
print_record(device);
}
}
}
-static void cleanup_db(struct udev *udev) {
+static void cleanup_db(void) {
_cleanup_closedir_ DIR *dir1 = NULL, *dir2 = NULL, *dir3 = NULL, *dir4 = NULL, *dir5 = NULL;
(void) unlink("/run/udev/queue.bin");
, program_invocation_short_name);
}
-static int uinfo(struct udev *udev, int argc, char *argv[]) {
- _cleanup_udev_device_unref_ struct udev_device *device = NULL;
+int info_main(int argc, char *argv[], void *userdata) {
+ _cleanup_(udev_device_unrefp) struct udev_device *device = NULL;
bool root = 0;
bool export = 0;
const char *export_prefix = NULL;
return 2;
}
- device = find_device(udev, optarg, "/dev/");
+ device = find_device(optarg, "/dev/");
if (device == NULL) {
fprintf(stderr, "device node not found\n");
return 2;
return 2;
}
- device = find_device(udev, optarg, "/sys");
+ device = find_device(optarg, "/sys");
if (device == NULL) {
fprintf(stderr, "syspath not found\n");
return 2;
action = ACTION_ATTRIBUTE_WALK;
break;
case 'e':
- if (export_devices(udev) < 0)
+ if (export_devices() < 0)
return 1;
return 0;
case 'c':
- cleanup_db(udev);
+ cleanup_db();
return 0;
case 'x':
export = true;
help();
return 2;
}
- device = find_device(udev, argv[optind], NULL);
+ device = find_device(argv[optind], NULL);
if (!device) {
fprintf(stderr, "Unknown device, --name=, --path=, or absolute path in /dev/ or /sys expected.\n");
return 4;
break;
case ACTION_ATTRIBUTE_WALK:
if (!device && argv[optind]) {
- device = find_device(udev, argv[optind], NULL);
+ device = find_device(argv[optind], NULL);
if (!device) {
fprintf(stderr, "Unknown device, absolute path in /dev/ or /sys expected.\n");
return 4;
return 0;
}
-
-const struct udevadm_cmd udevadm_info = {
- .name = "info",
- .cmd = uinfo,
- .help = "Query sysfs or the udev database",
-};