libudev.c revision ba6929f6690a72485ac3c6b7610ffbd5ab319be7
c343be283b7152554bac0c02493a4e1759c163f7Kay Sievers * libudev - interface to udev device information
c343be283b7152554bac0c02493a4e1759c163f7Kay Sievers * Copyright (C) 2008 Kay Sievers <kay.sievers@vrfy.org>
b3ae710c251d0ce5cf2cef63208e325497b5e323Zbigniew Jędrzejewski-Szmek * This program is free software: you can redistribute it and/or modify
19aadacf92ad86967ffb678e37b2ff9e83cb9480Jan Engelhardt * it under the terms of the GNU General Public License as published by
cff452c7e974db5053cdbd0d7bbbab2e3b4c91b9Kay Sievers * the Free Software Foundation, either version 2 of the License, or
cff452c7e974db5053cdbd0d7bbbab2e3b4c91b9Kay Sievers * (at your option) any later version.
cff452c7e974db5053cdbd0d7bbbab2e3b4c91b9Kay Sievers * This program is distributed in the hope that it will be useful,
f957632b960a0a42999b38ded7089fa602b41745Kay Sievers * but WITHOUT ANY WARRANTY; without even the implied warranty of
f957632b960a0a42999b38ded7089fa602b41745Kay Sievers * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
f957632b960a0a42999b38ded7089fa602b41745Kay Sievers * GNU General Public License for more details.
a40593a0d0d740efa387e35411e1e456a6c5aba7Lennart Poettering * You should have received a copy of the GNU General Public License
20ffc4c4a9226b0e45cc02ad9c0108981626c0bbKay Sievers * along with this program. If not, see <http://www.gnu.org/licenses/>.
3de03738fc970496d2d3da668c72767a48ccc41bLennart Poettering int priority, const char *file, int line, const char *fn,
8891f695c71bd4c266d827c9aaedbbbbaf79d3ebLennart Poettering int priority, const char *file, int line, const char *fn,
8891f695c71bd4c266d827c9aaedbbbbaf79d3ebLennart Poettering const char *format, ...)
8dfb5bced205a12d5380c95de035100ad6c09454Lennart Poettering udev->log_fn(udev, priority, file, line, fn, format, args);
7348b3adb324614132cf376f478e883bd7de28f1Lennart Poettering int priority, const char *file, int line, const char *fn,
11fb37f16ed99c1603c9d770b60ce4953b96a58dLennart Poettering/* glue to udev logging, needed until udev logging code is "fixed" */
01083ad094664e5c685060f4fb35a05ea2f212edLennart Poetteringvoid log_message(int priority, const char *format, ...)
b107b705cc97d3033e37c44229deb37b5aa31df5Lennart Poettering log_stderr(NULL, priority, NULL, 0, "", format, args);
6a3f892a23db71544d0439355f96c44350dafa8fLennart Poettering * Create udev library context.
2a781fc9bd33982c81e5ff75974a442a33d4f167Lennart Poettering * The initial refcount is 1, and needs to be decremented to
6a3f892a23db71544d0439355f96c44350dafa8fLennart Poettering * release the ressources of the udev library context.
efc141b8ffbfa1e449da40ce27fccaa81428f779Lennart Poettering * Returns: a new udev library context
650264033f2f98f6319513958d94d59078654af8Lennart Poettering memset(udev, 0x00, (sizeof(struct udev)));
eda8f06755bd98c4639293c26b856c225f0d1fe1Lennart Poettering log_info(udev, "context %p created\n", udev);
af1082b04a3d45a9b1d796b4271f44e87e307026Lennart Poettering * @udev: udev library context
488ad3b32a7e2b5b1380abf4a15e5f65fa65f3feLennart Poettering * Take a reference of the udev library context.
488ad3b32a7e2b5b1380abf4a15e5f65fa65f3feLennart Poettering * Returns: the passed udev library context
09ecd746c9d6581664873674c2188f8c93ed7780Lennart Poettering * @udev: udev library context
ef417cfd2211ae017a38b9796c6db29130133e63Zbigniew Jędrzejewski-Szmek * Drop a reference of the udev library context. If the refcount
3333d748facc15f49935b6b793490ba0824976e6Zbigniew Jędrzejewski-Szmek * reaches zero, the ressources of the context will be released.
f38afcd0c7f558ca5bf0854b42f8c6954f8ad7f3Lennart Poettering log_info(udev, "context %p released\n", udev);
47c94a96df29080f8b3a97e7362df4e9c6ba3265Lennart Poettering * udev_set_log_fn:
718db96199eb307751264e4163555662c9a389faLennart Poettering * @udev: udev library context
718db96199eb307751264e4163555662c9a389faLennart Poettering * @log_fn: function to be called for logging messages
718db96199eb307751264e4163555662c9a389faLennart Poettering * The built-in logging, which writes to stderr if the
718db96199eb307751264e4163555662c9a389faLennart Poettering * LIBUDEV_DEBUG environment variable is set, can be
718db96199eb307751264e4163555662c9a389faLennart Poettering * overridden by a custom function, to plug log messages
966204e010ed432a1d7a0481d41a326d8ec7b0c8Lennart Poettering * into the users logging functionality.
ced4d06784dbb19666688947901961f949f2aa6dLennart Poettering int priority, const char *file, int line, const char *fn,
416446221d905b6815175dc4d525d27f8ae43d1bLennart Poettering log_info(udev, "custom logging function %p registered\n", udev);
19aadacf92ad86967ffb678e37b2ff9e83cb9480Jan Engelhardt * udev_get_sys_path:
df5f6971e6e15b4632884916c71daa076c8bae96Lennart Poettering * @udev: udev library context
fcba531ed4c6e6f8f21d8ca4e3a56e3162b1c578Lennart Poettering * Retrieve the sysfs mount point. The default is "/sys". For
fcba531ed4c6e6f8f21d8ca4e3a56e3162b1c578Lennart Poettering * testing purposes, it can be overridden with the environment
8b8f259170e35b93e6c6d1757cb8b835bbdaa40cZbigniew Jędrzejewski-Szmek * variable SYSFS_PATH.
e10e429f2dcbb586215e65f62847f40c7d8b5956David Herrmann * Returns: the sys mount point
6aaa8c2f783cd1b3ac27c5ce40625d032e7e3d71Zbigniew Jędrzejewski-Szmekconst char *udev_get_sys_path(struct udev *udev)
4e09014daf8f98584b3f15e64e93bed232e70a6bLennart Poettering * udev_get_dev_path:
4e09014daf8f98584b3f15e64e93bed232e70a6bLennart Poettering * @udev: udev library context
6bb648a16ae4a682ad4784412af706d2e6a3e4daTom Gundersen * Retrieve the device directory path. The default value is "/dev",
e30fa16e27cbd48f960113a1d72d9a15c3b2d67bLennart Poettering * the actual value may be overridden in the udev configuration
7973ca1927e1f3bac9438f3529458c9ff868905dLennart Poettering * Returns: the device directory path
7973ca1927e1f3bac9438f3529458c9ff868905dLennart Poetteringconst char *udev_get_dev_path(struct udev *udev)