udevtest.c revision e5e322bc627a07d29a07e08f7c96bd644a3ae057
4196a3ead3cfb823670d225eefcb3e60e34c7d95Kay Sievers * Userspace devfs
4196a3ead3cfb823670d225eefcb3e60e34c7d95Kay Sievers * Copyright (C) 2003,2004 Greg Kroah-Hartman <greg@kroah.com>
4196a3ead3cfb823670d225eefcb3e60e34c7d95Kay Sievers * This program is free software; you can redistribute it and/or modify it
4196a3ead3cfb823670d225eefcb3e60e34c7d95Kay Sievers * under the terms of the GNU General Public License as published by the
4196a3ead3cfb823670d225eefcb3e60e34c7d95Kay Sievers * Free Software Foundation version 2 of the License.
4196a3ead3cfb823670d225eefcb3e60e34c7d95Kay Sievers * This program is distributed in the hope that it will be useful, but
4196a3ead3cfb823670d225eefcb3e60e34c7d95Kay Sievers * WITHOUT ANY WARRANTY; without even the implied warranty of
4196a3ead3cfb823670d225eefcb3e60e34c7d95Kay Sievers * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
4196a3ead3cfb823670d225eefcb3e60e34c7d95Kay Sievers * General Public License for more details.
4196a3ead3cfb823670d225eefcb3e60e34c7d95Kay Sievers * You should have received a copy of the GNU General Public License along
4196a3ead3cfb823670d225eefcb3e60e34c7d95Kay Sievers * with this program; if not, write to the Free Software Foundation, Inc.,
4196a3ead3cfb823670d225eefcb3e60e34c7d95Kay Sievers * 675 Mass Ave, Cambridge, MA 02139, USA.
c9679c652b3c31f2510e8805d81630680ebc7e95Lennart Poetteringvoid log_message (int level, const char *format, ...)
499b604b21c02ee64c8590a76d7900d64d7a5cb7Zbigniew Jędrzejewski-Szmekint main(int argc, char *argv[], char *envp[])
6936cd8926b6935364874b3701e86fe823e8c4ceLennart Poettering info("Usage: udevtest <devpath> [subsystem]");
499b604b21c02ee64c8590a76d7900d64d7a5cb7Zbigniew Jędrzejewski-Szmek /* initialize our configuration */
6936cd8926b6935364874b3701e86fe823e8c4ceLennart Poettering /* remove sysfs_path if given */
6936cd8926b6935364874b3701e86fe823e8c4ceLennart Poettering if (strncmp(argv[1], sysfs_path, strlen(sysfs_path)) == 0)
6936cd8926b6935364874b3701e86fe823e8c4ceLennart Poettering /* prepend '/' if missing */
6936cd8926b6935364874b3701e86fe823e8c4ceLennart Poettering snprintf(temp, sizeof(temp), "/%s", argv[1]);
6936cd8926b6935364874b3701e86fe823e8c4ceLennart Poettering /* initialize the naming deamon */
6936cd8926b6935364874b3701e86fe823e8c4ceLennart Poettering /* fill in values and test_run flag*/
6936cd8926b6935364874b3701e86fe823e8c4ceLennart Poettering udev_init_device(&udev, devpath, subsystem);
6936cd8926b6935364874b3701e86fe823e8c4ceLennart Poettering /* skip subsystems without "dev", but handle net devices */
6936cd8926b6935364874b3701e86fe823e8c4ceLennart Poettering if (udev.type != DEV_NET && subsystem_expect_no_dev(udev.subsystem)) {
6936cd8926b6935364874b3701e86fe823e8c4ceLennart Poettering info("don't care about '%s' devices", udev.subsystem);
6936cd8926b6935364874b3701e86fe823e8c4ceLennart Poettering /* open the device */
6936cd8926b6935364874b3701e86fe823e8c4ceLennart Poettering snprintf(path, sizeof(path), "%s%s", sysfs_path, udev.devpath);
6936cd8926b6935364874b3701e86fe823e8c4ceLennart Poettering class_dev = sysfs_open_class_device_path(path);
6936cd8926b6935364874b3701e86fe823e8c4ceLennart Poettering info("sysfs_open_class_device_path failed");
6936cd8926b6935364874b3701e86fe823e8c4ceLennart Poettering info("opened class_dev->name='%s'", class_dev->name);
6936cd8926b6935364874b3701e86fe823e8c4ceLennart Poettering /* simulate node creation with test flag */