udevadm-test-builtin.c revision 7c85d636e646a5c2021d1daaab10282f340e0134
b9e697e180c323785bf1cb8a29f5ec6288da8ec4Jaco Jooste * Copyright (C) 2011 Kay Sievers <kay.sievers@vrfy.org>
b9e697e180c323785bf1cb8a29f5ec6288da8ec4Jaco Jooste * This program is free software: you can redistribute it and/or modify
b9e697e180c323785bf1cb8a29f5ec6288da8ec4Jaco Jooste * it under the terms of the GNU General Public License as published by
b9e697e180c323785bf1cb8a29f5ec6288da8ec4Jaco Jooste * the Free Software Foundation, either version 2 of the License, or
b9e697e180c323785bf1cb8a29f5ec6288da8ec4Jaco Jooste * (at your option) any later version.
b9e697e180c323785bf1cb8a29f5ec6288da8ec4Jaco Jooste * This program is distributed in the hope that it will be useful,
b9e697e180c323785bf1cb8a29f5ec6288da8ec4Jaco Jooste * but WITHOUT ANY WARRANTY; without even the implied warranty of
b9e697e180c323785bf1cb8a29f5ec6288da8ec4Jaco Jooste * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
b9e697e180c323785bf1cb8a29f5ec6288da8ec4Jaco Jooste * GNU General Public License for more details.
590e03a0114f53c994d970cfb356dadaaa57e39dJaco Jooste * You should have received a copy of the GNU General Public License
b9e697e180c323785bf1cb8a29f5ec6288da8ec4Jaco Jooste * along with this program. If not, see <http://www.gnu.org/licenses/>.
b9e697e180c323785bf1cb8a29f5ec6288da8ec4Jaco Jooste fprintf(stderr, "Usage: udevadm builtin [--help] <command> <syspath>\n");
7197110fbdb6deb7868581c455516161cbcf7e0fJaco Joostestatic int adm_builtin(struct udev *udev, int argc, char *argv[])
0a915e9189b4078b8b3763451da6dc5d9b7edbdeJaco Jooste option = getopt_long(argc, argv, "h", options, NULL);
590e03a0114f53c994d970cfb356dadaaa57e39dJaco Jooste fprintf(stderr, "unknown command '%s'\n", command);
590e03a0114f53c994d970cfb356dadaaa57e39dJaco Jooste /* add /sys if needed */
590e03a0114f53c994d970cfb356dadaaa57e39dJaco Jooste if (strncmp(syspath, udev_get_sys_path(udev), strlen(udev_get_sys_path(udev))) != 0)
ece5a262d20a50d0abf584d0f7ec73929ede9cfdJaco Jooste util_strscpyl(filename, sizeof(filename), udev_get_sys_path(udev), syspath, NULL);
590e03a0114f53c994d970cfb356dadaaa57e39dJaco Jooste util_strscpy(filename, sizeof(filename), syspath);
ece5a262d20a50d0abf584d0f7ec73929ede9cfdJaco Jooste dev = udev_device_new_from_syspath(udev, filename);
590e03a0114f53c994d970cfb356dadaaa57e39dJaco Jooste fprintf(stderr, "unable to open device '%s'\n\n", filename);
ece5a262d20a50d0abf584d0f7ec73929ede9cfdJaco Jooste if (udev_builtin_run(dev, cmd, command, true) < 0) {
ece5a262d20a50d0abf584d0f7ec73929ede9cfdJaco Jooste fprintf(stderr, "error executing '%s'\n\n", command);