From 131a4dcfd4375f235a1f512339c0909e8bcc730b Mon Sep 17 00:00:00 2001 From: Kay Sievers Date: Sun, 22 Jan 2012 18:20:42 +0100 Subject: login: move seat udev rules to login subdir --- Makefile.am | 33 +++---- src/.gitignore | 7 +- src/70-uaccess.rules | 72 ---------------- src/71-seat.rules | 22 ----- src/73-seat-late.rules.in | 17 ---- src/hostname/.gitignore | 1 + src/locale/.gitignore | 1 + src/login/.gitignore | 2 + src/login/70-uaccess.rules | 72 ++++++++++++++++ src/login/71-seat.rules | 22 +++++ src/login/73-seat-late.rules.in | 17 ++++ src/login/sysfs-show.c | 187 ++++++++++++++++++++++++++++++++++++++++ src/sysfs-show.c | 187 ---------------------------------------- src/timedate/.gitignore | 1 + 14 files changed, 322 insertions(+), 319 deletions(-) delete mode 100644 src/70-uaccess.rules delete mode 100644 src/71-seat.rules delete mode 100644 src/73-seat-late.rules.in create mode 100644 src/hostname/.gitignore create mode 100644 src/locale/.gitignore create mode 100644 src/login/70-uaccess.rules create mode 100644 src/login/71-seat.rules create mode 100644 src/login/73-seat-late.rules.in create mode 100644 src/login/sysfs-show.c delete mode 100644 src/sysfs-show.c create mode 100644 src/timedate/.gitignore diff --git a/Makefile.am b/Makefile.am index be5e70c9f8..1df603ba60 100644 --- a/Makefile.am +++ b/Makefile.am @@ -73,6 +73,7 @@ pkginclude_HEADERS = lib_LTLIBRARIES = pkgconfiglib_DATA = polkitpolicy_in_files = +dist_udevrules_DATA = AM_CPPFLAGS = \ -include $(top_builddir)/config.h \ @@ -222,11 +223,7 @@ dist_dbuspolicy_DATA = \ dist_dbussystemservice_DATA = \ src/org.freedesktop.systemd1.service -dist_udevrules_DATA = \ - src/71-seat.rules - nodist_udevrules_DATA = \ - src/73-seat-late.rules \ src/99-systemd.rules dbusinterface_DATA = \ @@ -370,7 +367,6 @@ EXTRA_DIST += \ units/user@.service.in \ src/systemd.pc.in \ introspect.awk \ - src/73-seat-late.rules.in \ src/99-systemd.rules.in \ man/custom-html.xsl @@ -1861,11 +1857,11 @@ rootlibexec_PROGRAMS += \ systemd_loginctl_SOURCES = \ src/login/loginctl.c \ + src/login/sysfs-show.c \ src/dbus-common.c \ src/cgroup-show.c \ src/cgroup-util.c \ - src/pager.c \ - src/sysfs-show.c + src/pager.c systemd_loginctl_CFLAGS = \ $(AM_CFLAGS) \ @@ -2017,7 +2013,13 @@ rootlibexec_PROGRAMS += \ systemd-uaccess dist_udevrules_DATA += \ - src/70-uaccess.rules + src/login/70-uaccess.rules + +dist_udevrules_DATA += \ + src/login/71-seat.rules + +nodist_udevrules_DATA += \ + src/login/73-seat-late.rules MANPAGES += \ man/systemd-logind.conf.5 \ @@ -2063,8 +2065,6 @@ man/sd_get_uids.3: man/sd_get_seats.3 EXTRA_DIST += \ src/login/logind-gperf.gperf \ - units/systemd-logind.service.in \ - units/systemd-user-sessions.service.in \ src/login/libsystemd-login.pc.in \ src/login/libsystemd-login.sym \ src/login/logind.h \ @@ -2072,10 +2072,14 @@ EXTRA_DIST += \ src/login/logind-seat.h \ src/login/logind-session.h \ src/login/logind-user.h \ - src/login/logind-acl.h + src/login/logind-acl.h \ + src/login/73-seat-late.rules.in \ + units/systemd-logind.service.in \ + units/systemd-user-sessions.service.in CLEANFILES += \ - src/login/logind-gperf.c + src/login/logind-gperf.c \ + src/login/73-seat-late.rules endif # ------------------------------------------------------------------------------ @@ -2152,11 +2156,10 @@ CLEANFILES += \ $(pkgconfigdata_DATA) \ $(pkgconfiglib_DATA) \ $(nodist_polkitpolicy_DATA) \ - src/73-seat-late.rules \ - src/99-systemd.rules \ src/load-fragment-gperf.gperf \ src/load-fragment-gperf.c \ - src/load-fragment-gperf-nulstr.c + src/load-fragment-gperf-nulstr.c \ + src/99-systemd.rules if HAVE_VALAC CLEANFILES += \ diff --git a/src/.gitignore b/src/.gitignore index c54c6f6514..4b123f86d2 100644 --- a/src/.gitignore +++ b/src/.gitignore @@ -3,14 +3,9 @@ load-fragment-gperf-nulstr.c load-fragment-gperf.c load-fragment-gperf.gperf org.freedesktop.systemd1.policy.in -99-systemd.rules -org.freedesktop.hostname1.policy -org.freedesktop.locale1.policy -org.freedesktop.login1.policy -org.freedesktop.timedate1.policy org.freedesktop.systemd1.policy gnome-ask-password-agent.c systemd-interfaces.c systemadm.c wraplabel.c -73-seat-late.rules +99-systemd.rules diff --git a/src/70-uaccess.rules b/src/70-uaccess.rules deleted file mode 100644 index 6932492260..0000000000 --- a/src/70-uaccess.rules +++ /dev/null @@ -1,72 +0,0 @@ -# This file is part of systemd. -# -# systemd 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. - -ACTION=="remove", GOTO="uaccess_end" -ENV{MAJOR}=="", GOTO="uaccess_end" - -# PTP/MTP protocol devices, cameras, portable media players -SUBSYSTEM=="usb", ENV{ID_USB_INTERFACES}=="", ENV{DEVTYPE}=="usb_device", IMPORT{program}="usb_id --export %p" -SUBSYSTEM=="usb", ENV{ID_USB_INTERFACES}=="*:060101:*", TAG+="uaccess" - -# Digicams with proprietary protocol -ENV{ID_GPHOTO2}=="*?", TAG+="uaccess" - -# SCSI and USB scanners -ENV{libsane_matched}=="yes", TAG+="uaccess" - -# HPLIP devices (necessary for ink level check and HP tool maintenance) -ENV{ID_HPLIP}=="1", TAG+="uaccess" - -# optical drives -SUBSYSTEM=="block", ENV{ID_CDROM}=="1", TAG+="uaccess" -SUBSYSTEM=="scsi_generic", SUBSYSTEMS=="scsi", ATTRS{type}=="4|5", TAG+="uaccess" - -# Sound devices -SUBSYSTEM=="sound", TAG+="uaccess" - -# ffado is an userspace driver for firewire sound cards -SUBSYSTEM=="firewire", ENV{ID_FFADO}=="1", TAG+="uaccess" - -# Webcams, frame grabber, TV cards -SUBSYSTEM=="video4linux", TAG+="uaccess" -SUBSYSTEM=="dvb", TAG+="uaccess" - -# IIDC devices: industrial cameras and some webcams -SUBSYSTEM=="firewire", ATTR{units}=="*0x00a02d:0x00010*", TAG+="uaccess" -SUBSYSTEM=="firewire", ATTR{units}=="*0x00b09d:0x00010*", TAG+="uaccess" -# AV/C devices: camcorders, set-top boxes, TV sets, audio devices, and more -SUBSYSTEM=="firewire", ATTR{units}=="*0x00a02d:0x010001*", TAG+="uaccess" -SUBSYSTEM=="firewire", ATTR{units}=="*0x00a02d:0x014001*", TAG+="uaccess" - -# DRI video devices -SUBSYSTEM=="drm", KERNEL=="card*", TAG+="uaccess" - -# KVM -SUBSYSTEM=="misc", KERNEL=="kvm", TAG+="uaccess" - -# smart-card readers -ENV{ID_SMARTCARD_READER}=="*?", TAG+="uaccess" - -# PDA devices -ENV{ID_PDA}=="*?", TAG+="uaccess" - -# Programmable remote control -ENV{ID_REMOTE_CONTROL}=="1", TAG+="uaccess" - -# joysticks -SUBSYSTEM=="input", ENV{ID_INPUT_JOYSTICK}=="?*", TAG+="uaccess" - -# color measurement devices -ENV{COLOR_MEASUREMENT_DEVICE}=="*?", TAG+="uaccess" - -# DDC/CI device, usually high-end monitors such as the DreamColor -ENV{DDC_DEVICE}=="*?", TAG+="uaccess" - -# media player raw devices (for user-mode drivers, Android SDK, etc.) -SUBSYSTEM=="usb", ENV{ID_MEDIA_PLAYER}=="?*", TAG+="uaccess" - -LABEL="uaccess_end" diff --git a/src/71-seat.rules b/src/71-seat.rules deleted file mode 100644 index 99425adfb7..0000000000 --- a/src/71-seat.rules +++ /dev/null @@ -1,22 +0,0 @@ -# This file is part of systemd. -# -# systemd 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. - -ACTION=="remove", GOTO="seat_end" - -TAG=="uaccess", SUBSYSTEM!="sound", TAG+="seat" -SUBSYSTEM=="sound", KERNEL=="card*", TAG+="seat" -SUBSYSTEM=="input", KERNEL=="input*", TAG+="seat" -SUBSYSTEM=="graphics", KERNEL=="fb[0-9]*", TAG+="seat" -SUBSYSTEM=="usb", ATTR{bDeviceClass}=="09", TAG+="seat" - -# 'Plugable' USB hub, sound, network, graphics adapter -SUBSYSTEM=="usb", ATTR{idVendor}=="2230", ATTR{idProduct}=="000[13]", ENV{ID_AUTOSEAT}="1" - -TAG=="seat", ENV{ID_PATH}=="", IMPORT{program}="path_id %p" -TAG=="seat", ENV{ID_FOR_SEAT}=="", ENV{ID_PATH_TAG}!="", ENV{ID_FOR_SEAT}="$env{SUBSYSTEM}-$env{ID_PATH_TAG}" - -LABEL="seat_end" diff --git a/src/73-seat-late.rules.in b/src/73-seat-late.rules.in deleted file mode 100644 index 0847932d77..0000000000 --- a/src/73-seat-late.rules.in +++ /dev/null @@ -1,17 +0,0 @@ -# This file is part of systemd. -# -# systemd 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. - -ACTION=="remove", GOTO="seat_late_end" - -ENV{ID_SEAT}=="", ENV{ID_AUTOSEAT}=="1", ENV{ID_FOR_SEAT}!="", ENV{ID_SEAT}="seat-$env{ID_FOR_SEAT}" -ENV{ID_SEAT}=="", IMPORT{parent}="ID_SEAT" - -ENV{ID_SEAT}!="", TAG+="$env{ID_SEAT}" - -TAG=="uaccess", ENV{MAJOR}!="", RUN+="@rootlibexecdir@/systemd-uaccess $env{DEVNAME} $env{ID_SEAT}" - -LABEL="seat_late_end" diff --git a/src/hostname/.gitignore b/src/hostname/.gitignore new file mode 100644 index 0000000000..1ff281b231 --- /dev/null +++ b/src/hostname/.gitignore @@ -0,0 +1 @@ +org.freedesktop.hostname1.policy diff --git a/src/locale/.gitignore b/src/locale/.gitignore new file mode 100644 index 0000000000..b1e0ba755e --- /dev/null +++ b/src/locale/.gitignore @@ -0,0 +1 @@ +org.freedesktop.locale1.policy diff --git a/src/login/.gitignore b/src/login/.gitignore index 7c420cb09b..1c0f3995ed 100644 --- a/src/login/.gitignore +++ b/src/login/.gitignore @@ -1 +1,3 @@ logind-gperf.c +org.freedesktop.login1.policy +73-seat-late.rules diff --git a/src/login/70-uaccess.rules b/src/login/70-uaccess.rules new file mode 100644 index 0000000000..6932492260 --- /dev/null +++ b/src/login/70-uaccess.rules @@ -0,0 +1,72 @@ +# This file is part of systemd. +# +# systemd 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. + +ACTION=="remove", GOTO="uaccess_end" +ENV{MAJOR}=="", GOTO="uaccess_end" + +# PTP/MTP protocol devices, cameras, portable media players +SUBSYSTEM=="usb", ENV{ID_USB_INTERFACES}=="", ENV{DEVTYPE}=="usb_device", IMPORT{program}="usb_id --export %p" +SUBSYSTEM=="usb", ENV{ID_USB_INTERFACES}=="*:060101:*", TAG+="uaccess" + +# Digicams with proprietary protocol +ENV{ID_GPHOTO2}=="*?", TAG+="uaccess" + +# SCSI and USB scanners +ENV{libsane_matched}=="yes", TAG+="uaccess" + +# HPLIP devices (necessary for ink level check and HP tool maintenance) +ENV{ID_HPLIP}=="1", TAG+="uaccess" + +# optical drives +SUBSYSTEM=="block", ENV{ID_CDROM}=="1", TAG+="uaccess" +SUBSYSTEM=="scsi_generic", SUBSYSTEMS=="scsi", ATTRS{type}=="4|5", TAG+="uaccess" + +# Sound devices +SUBSYSTEM=="sound", TAG+="uaccess" + +# ffado is an userspace driver for firewire sound cards +SUBSYSTEM=="firewire", ENV{ID_FFADO}=="1", TAG+="uaccess" + +# Webcams, frame grabber, TV cards +SUBSYSTEM=="video4linux", TAG+="uaccess" +SUBSYSTEM=="dvb", TAG+="uaccess" + +# IIDC devices: industrial cameras and some webcams +SUBSYSTEM=="firewire", ATTR{units}=="*0x00a02d:0x00010*", TAG+="uaccess" +SUBSYSTEM=="firewire", ATTR{units}=="*0x00b09d:0x00010*", TAG+="uaccess" +# AV/C devices: camcorders, set-top boxes, TV sets, audio devices, and more +SUBSYSTEM=="firewire", ATTR{units}=="*0x00a02d:0x010001*", TAG+="uaccess" +SUBSYSTEM=="firewire", ATTR{units}=="*0x00a02d:0x014001*", TAG+="uaccess" + +# DRI video devices +SUBSYSTEM=="drm", KERNEL=="card*", TAG+="uaccess" + +# KVM +SUBSYSTEM=="misc", KERNEL=="kvm", TAG+="uaccess" + +# smart-card readers +ENV{ID_SMARTCARD_READER}=="*?", TAG+="uaccess" + +# PDA devices +ENV{ID_PDA}=="*?", TAG+="uaccess" + +# Programmable remote control +ENV{ID_REMOTE_CONTROL}=="1", TAG+="uaccess" + +# joysticks +SUBSYSTEM=="input", ENV{ID_INPUT_JOYSTICK}=="?*", TAG+="uaccess" + +# color measurement devices +ENV{COLOR_MEASUREMENT_DEVICE}=="*?", TAG+="uaccess" + +# DDC/CI device, usually high-end monitors such as the DreamColor +ENV{DDC_DEVICE}=="*?", TAG+="uaccess" + +# media player raw devices (for user-mode drivers, Android SDK, etc.) +SUBSYSTEM=="usb", ENV{ID_MEDIA_PLAYER}=="?*", TAG+="uaccess" + +LABEL="uaccess_end" diff --git a/src/login/71-seat.rules b/src/login/71-seat.rules new file mode 100644 index 0000000000..99425adfb7 --- /dev/null +++ b/src/login/71-seat.rules @@ -0,0 +1,22 @@ +# This file is part of systemd. +# +# systemd 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. + +ACTION=="remove", GOTO="seat_end" + +TAG=="uaccess", SUBSYSTEM!="sound", TAG+="seat" +SUBSYSTEM=="sound", KERNEL=="card*", TAG+="seat" +SUBSYSTEM=="input", KERNEL=="input*", TAG+="seat" +SUBSYSTEM=="graphics", KERNEL=="fb[0-9]*", TAG+="seat" +SUBSYSTEM=="usb", ATTR{bDeviceClass}=="09", TAG+="seat" + +# 'Plugable' USB hub, sound, network, graphics adapter +SUBSYSTEM=="usb", ATTR{idVendor}=="2230", ATTR{idProduct}=="000[13]", ENV{ID_AUTOSEAT}="1" + +TAG=="seat", ENV{ID_PATH}=="", IMPORT{program}="path_id %p" +TAG=="seat", ENV{ID_FOR_SEAT}=="", ENV{ID_PATH_TAG}!="", ENV{ID_FOR_SEAT}="$env{SUBSYSTEM}-$env{ID_PATH_TAG}" + +LABEL="seat_end" diff --git a/src/login/73-seat-late.rules.in b/src/login/73-seat-late.rules.in new file mode 100644 index 0000000000..0847932d77 --- /dev/null +++ b/src/login/73-seat-late.rules.in @@ -0,0 +1,17 @@ +# This file is part of systemd. +# +# systemd 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. + +ACTION=="remove", GOTO="seat_late_end" + +ENV{ID_SEAT}=="", ENV{ID_AUTOSEAT}=="1", ENV{ID_FOR_SEAT}!="", ENV{ID_SEAT}="seat-$env{ID_FOR_SEAT}" +ENV{ID_SEAT}=="", IMPORT{parent}="ID_SEAT" + +ENV{ID_SEAT}!="", TAG+="$env{ID_SEAT}" + +TAG=="uaccess", ENV{MAJOR}!="", RUN+="@rootlibexecdir@/systemd-uaccess $env{DEVNAME} $env{ID_SEAT}" + +LABEL="seat_late_end" diff --git a/src/login/sysfs-show.c b/src/login/sysfs-show.c new file mode 100644 index 0000000000..b8b356d77b --- /dev/null +++ b/src/login/sysfs-show.c @@ -0,0 +1,187 @@ +/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/ + +/*** + This file is part of systemd. + + Copyright 2010 Lennart Poettering + + systemd 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. + + systemd 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 systemd; If not, see . +***/ + +#include +#include +#include + +#include "util.h" +#include "sysfs-show.h" + +static int show_sysfs_one( + struct udev *udev, + const char *seat, + struct udev_list_entry **item, + const char *sub, + const char *prefix, + unsigned n_columns) { + + assert(udev); + assert(seat); + assert(item); + assert(prefix); + + while (*item) { + struct udev_list_entry *next, *lookahead; + struct udev_device *d; + const char *sn, *name, *sysfs, *subsystem, *sysname; + char *l, *k; + + sysfs = udev_list_entry_get_name(*item); + if (!path_startswith(sysfs, sub)) + return 0; + + d = udev_device_new_from_syspath(udev, sysfs); + if (!d) { + *item = udev_list_entry_get_next(*item); + continue; + } + + sn = udev_device_get_property_value(d, "ID_SEAT"); + if (isempty(sn)) + sn = "seat0"; + + /* fixme, also check for tag 'seat' here */ + if (!streq(seat, sn) || !udev_device_has_tag(d, "seat")) { + udev_device_unref(d); + *item = udev_list_entry_get_next(*item); + continue; + } + + name = udev_device_get_sysattr_value(d, "name"); + if (!name) + name = udev_device_get_sysattr_value(d, "id"); + subsystem = udev_device_get_subsystem(d); + sysname = udev_device_get_sysname(d); + + /* Look if there's more coming after this */ + lookahead = next = udev_list_entry_get_next(*item); + while (lookahead) { + const char *lookahead_sysfs; + + lookahead_sysfs = udev_list_entry_get_name(lookahead); + + if (path_startswith(lookahead_sysfs, sub) && + !path_startswith(lookahead_sysfs, sysfs)) { + struct udev_device *lookahead_d; + + lookahead_d = udev_device_new_from_syspath(udev, lookahead_sysfs); + if (lookahead_d) { + const char *lookahead_sn; + bool found; + + lookahead_sn = udev_device_get_property_value(d, "ID_SEAT"); + if (isempty(lookahead_sn)) + lookahead_sn = "seat0"; + + found = streq(seat, lookahead_sn) && udev_device_has_tag(lookahead_d, "seat"); + udev_device_unref(lookahead_d); + + if (found) + break; + } + } + + lookahead = udev_list_entry_get_next(lookahead); + } + + k = ellipsize(sysfs, n_columns, 20); + printf("%s%s %s\n", prefix, lookahead ? "\342\224\234" : "\342\224\224", k ? k : sysfs); + free(k); + + if (asprintf(&l, + "(%s:%s)%s%s%s", + subsystem, sysname, + name ? " \"" : "", name ? name : "", name ? "\"" : "") < 0) { + udev_device_unref(d); + return -ENOMEM; + } + + k = ellipsize(l, n_columns, 70); + printf("%s%s %s\n", prefix, lookahead ? "\342\224\202" : " ", k ? k : l); + free(k); + free(l); + + *item = next; + if (*item) { + char *p; + + p = strappend(prefix, lookahead ? "\342\224\202 " : " "); + show_sysfs_one(udev, seat, item, sysfs, p ? p : prefix, n_columns - 2); + free(p); + } + + udev_device_unref(d); + } + + return 0; +} + +int show_sysfs(const char *seat, const char *prefix, unsigned n_columns) { + struct udev *udev; + struct udev_list_entry *first = NULL; + struct udev_enumerate *e; + int r; + + if (n_columns <= 0) + n_columns = columns(); + + if (!prefix) + prefix = ""; + + if (isempty(seat)) + seat = "seat0"; + + udev = udev_new(); + if (!udev) + return -ENOMEM; + + e = udev_enumerate_new(udev); + if (!e) { + r = -ENOMEM; + goto finish; + } + + if (!streq(seat, "seat0")) + r = udev_enumerate_add_match_tag(e, seat); + else + r = udev_enumerate_add_match_tag(e, "seat"); + + if (r < 0) + goto finish; + + r = udev_enumerate_scan_devices(e); + if (r < 0) + goto finish; + + first = udev_enumerate_get_list_entry(e); + if (first) + show_sysfs_one(udev, seat, &first, "/", prefix, n_columns); + +finish: + if (e) + udev_enumerate_unref(e); + + if (udev) + udev_unref(udev); + + return r; +} diff --git a/src/sysfs-show.c b/src/sysfs-show.c deleted file mode 100644 index b8b356d77b..0000000000 --- a/src/sysfs-show.c +++ /dev/null @@ -1,187 +0,0 @@ -/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/ - -/*** - This file is part of systemd. - - Copyright 2010 Lennart Poettering - - systemd 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. - - systemd 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 systemd; If not, see . -***/ - -#include -#include -#include - -#include "util.h" -#include "sysfs-show.h" - -static int show_sysfs_one( - struct udev *udev, - const char *seat, - struct udev_list_entry **item, - const char *sub, - const char *prefix, - unsigned n_columns) { - - assert(udev); - assert(seat); - assert(item); - assert(prefix); - - while (*item) { - struct udev_list_entry *next, *lookahead; - struct udev_device *d; - const char *sn, *name, *sysfs, *subsystem, *sysname; - char *l, *k; - - sysfs = udev_list_entry_get_name(*item); - if (!path_startswith(sysfs, sub)) - return 0; - - d = udev_device_new_from_syspath(udev, sysfs); - if (!d) { - *item = udev_list_entry_get_next(*item); - continue; - } - - sn = udev_device_get_property_value(d, "ID_SEAT"); - if (isempty(sn)) - sn = "seat0"; - - /* fixme, also check for tag 'seat' here */ - if (!streq(seat, sn) || !udev_device_has_tag(d, "seat")) { - udev_device_unref(d); - *item = udev_list_entry_get_next(*item); - continue; - } - - name = udev_device_get_sysattr_value(d, "name"); - if (!name) - name = udev_device_get_sysattr_value(d, "id"); - subsystem = udev_device_get_subsystem(d); - sysname = udev_device_get_sysname(d); - - /* Look if there's more coming after this */ - lookahead = next = udev_list_entry_get_next(*item); - while (lookahead) { - const char *lookahead_sysfs; - - lookahead_sysfs = udev_list_entry_get_name(lookahead); - - if (path_startswith(lookahead_sysfs, sub) && - !path_startswith(lookahead_sysfs, sysfs)) { - struct udev_device *lookahead_d; - - lookahead_d = udev_device_new_from_syspath(udev, lookahead_sysfs); - if (lookahead_d) { - const char *lookahead_sn; - bool found; - - lookahead_sn = udev_device_get_property_value(d, "ID_SEAT"); - if (isempty(lookahead_sn)) - lookahead_sn = "seat0"; - - found = streq(seat, lookahead_sn) && udev_device_has_tag(lookahead_d, "seat"); - udev_device_unref(lookahead_d); - - if (found) - break; - } - } - - lookahead = udev_list_entry_get_next(lookahead); - } - - k = ellipsize(sysfs, n_columns, 20); - printf("%s%s %s\n", prefix, lookahead ? "\342\224\234" : "\342\224\224", k ? k : sysfs); - free(k); - - if (asprintf(&l, - "(%s:%s)%s%s%s", - subsystem, sysname, - name ? " \"" : "", name ? name : "", name ? "\"" : "") < 0) { - udev_device_unref(d); - return -ENOMEM; - } - - k = ellipsize(l, n_columns, 70); - printf("%s%s %s\n", prefix, lookahead ? "\342\224\202" : " ", k ? k : l); - free(k); - free(l); - - *item = next; - if (*item) { - char *p; - - p = strappend(prefix, lookahead ? "\342\224\202 " : " "); - show_sysfs_one(udev, seat, item, sysfs, p ? p : prefix, n_columns - 2); - free(p); - } - - udev_device_unref(d); - } - - return 0; -} - -int show_sysfs(const char *seat, const char *prefix, unsigned n_columns) { - struct udev *udev; - struct udev_list_entry *first = NULL; - struct udev_enumerate *e; - int r; - - if (n_columns <= 0) - n_columns = columns(); - - if (!prefix) - prefix = ""; - - if (isempty(seat)) - seat = "seat0"; - - udev = udev_new(); - if (!udev) - return -ENOMEM; - - e = udev_enumerate_new(udev); - if (!e) { - r = -ENOMEM; - goto finish; - } - - if (!streq(seat, "seat0")) - r = udev_enumerate_add_match_tag(e, seat); - else - r = udev_enumerate_add_match_tag(e, "seat"); - - if (r < 0) - goto finish; - - r = udev_enumerate_scan_devices(e); - if (r < 0) - goto finish; - - first = udev_enumerate_get_list_entry(e); - if (first) - show_sysfs_one(udev, seat, &first, "/", prefix, n_columns); - -finish: - if (e) - udev_enumerate_unref(e); - - if (udev) - udev_unref(udev); - - return r; -} diff --git a/src/timedate/.gitignore b/src/timedate/.gitignore new file mode 100644 index 0000000000..48757f0968 --- /dev/null +++ b/src/timedate/.gitignore @@ -0,0 +1 @@ +org.freedesktop.timedate1.policy -- cgit v1.2.3-54-g00ecf