sysfs-show.c revision 2d96536dd7ef371c94be70cd9fb0fcbc0e5a0329
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
/***
This file is part of systemd.
Copyright 2010 Lennart Poettering
under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
#include <errno.h>
#include <string.h>
#include <libudev.h>
#include "util.h"
#include "sysfs-show.h"
#include "path-util.h"
static int show_sysfs_one(
const char *seat,
struct udev_list_entry **item,
const char *sub,
const char *prefix,
unsigned n_columns) {
while (*item) {
struct udev_device *d;
char *l, *k;
bool is_master;
return 0;
if (!d) {
continue;
}
sn = "seat0";
/* Explicitly also check for tag 'seat' here */
continue;
}
if (!name)
/* Look if there's more coming after this */
while (lookahead) {
const char *lookahead_sysfs;
struct udev_device *lookahead_d;
if (lookahead_d) {
const char *lookahead_sn;
bool found;
if (isempty(lookahead_sn))
lookahead_sn = "seat0";
if (found)
break;
}
}
}
k ? k : sysfs);
free(k);
if (asprintf(&l,
"%s%s:%s%s%s%s",
return -ENOMEM;
}
k ? k : l);
free(k);
free(l);
if (*item) {
char *p;
free(p);
}
}
return 0;
}
struct udev_enumerate *e;
int r;
if (n_columns <= 0)
if (!prefix)
prefix = "";
seat = "seat0";
if (!udev)
return -ENOMEM;
e = udev_enumerate_new(udev);
if (!e) {
r = -ENOMEM;
goto finish;
}
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;
if (first)
if (e)
if (udev)
return r;
}