udevinfo.c revision 1aa1e24848903d11780db1ade355be73ad61a937
/*
* udevinfo.c - fetches stored device information or sysfs attributes
*
* Copyright (C) 2004-2005 Kay Sievers <kay.sievers@vrfy.org>
*
* under the terms of the GNU General Public License as published by the
* Free Software Foundation version 2 of the License.
*
* This program 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 this program; if not, write to the Free Software Foundation, Inc.,
* 675 Mass Ave, Cambridge, MA 02139, USA.
*
*/
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <stddef.h>
#include <ctype.h>
#include <stdarg.h>
#include <unistd.h>
#include <dirent.h>
#include <errno.h>
#include "udev.h"
#ifdef USE_LOG
{
if (priority > udev_log_priority)
return;
}
#endif
static void print_all_attributes(const char *devpath)
{
char *attr_value;
if (attr_value == NULL)
continue;
/* remove trailing newlines */
/* skip nonprintable attributes */
len--;
if (len) {
continue;
}
}
}
printf("\n");
}
static int print_device_chain(const char *devpath)
{
struct sysfs_device *dev;
printf("\n"
"udevinfo starts with the device the node belongs to and then walks up the\n"
"device chain, to print for every device found, all possibly useful attributes\n"
"in the udev key format.\n"
"Only attributes within one device section may be used together in one rule,\n"
"to match the device for which the node will be created.\n"
"\n");
return -1;
/* walk up the chain of devices */
while (1) {
break;
}
return 0;
}
{
struct name_entry *name_loop;
}
}
printf("\n");
}
struct name_entry *name_loop;
udev_db = udev_device_init();
continue;
}
}
static void print_help(void)
{
" -q TYPE query database for the specified value:\n"
" 'name' name of device node\n"
" 'symlink' pointing to node\n"
" 'path' sysfs device path\n"
" 'env' the device related imported environment\n"
" 'all' all values\n"
"\n"
" -p PATH sysfs device path used for query or chain\n"
"\n"
" -r prepend to query result or print udev_root\n"
" -a print all SYSFS_attributes along the device chain\n"
" -e export the content of the udev database\n"
" -V print udev version\n"
" -h print this help text\n"
"\n");
}
{
static const char short_options[] = "aden:p:q:rVh";
int option;
int root = 0;
enum action_type {
} action = ACTION_NONE;
enum query_type {
} query = QUERY_NONE;
struct name_entry *name_loop;
char *pos;
int rc = 0;
logging_init("udevinfo");
sysfs_init();
udev = udev_device_init();
rc = 1;
goto exit;
}
/* get command line options */
while (1) {
if (option == -1)
break;
switch (option) {
case 'n':
break;
case 'p':
/* remove sysfs mountpoint if not given */
else
break;
case 'q':
query = QUERY_NAME;
break;
}
break;
}
query = QUERY_PATH;
break;
}
break;
}
break;
}
rc = 2;
goto exit;
case 'r':
if (action == ACTION_NONE)
root = 1;
break;
case 'a':
break;
case 'd':
goto exit;
case 'e':
goto exit;
case 'V':
goto exit;
case 'h':
case '?':
default:
print_help();
goto exit;
}
}
/* run action */
switch (action) {
case ACTION_QUERY:
if (path[0] != '\0') {
/* remove sysfs_path if given */
} else {
if (path[0] != '/') {
/* prepend '/' if missing */
} else {
}
}
rc = 3;
goto exit;
}
} else if (name[0] != '\0') {
int len;
/* remove udev_root if given */
} else
rc = 3;
goto exit;
}
} else {
rc = 4;
goto exit;
}
switch(query) {
case QUERY_NAME:
if (root)
else
break;
case QUERY_SYMLINK:
goto exit;
if (root)
else
printf("\n");
break;
case QUERY_PATH:
goto exit;
case QUERY_ENV:
break;
case QUERY_ALL:
break;
default:
print_help();
break;
}
break;
case ACTION_ATTRIBUTE_WALK:
if (path[0] == '\0') {
rc = 4;
goto exit;
} else
break;
case ACTION_ROOT:
break;
default:
print_help();
rc = 1;
break;
}
exit:
return rc;
}