udevadm-info.c revision 04a9d3a00a9290cbf254d0b0ba2ce4521be632ae
/*
* Copyright (C) 2004-2009 Kay Sievers <kay.sievers@vrfy.org>
*
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* 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, see <http://www.gnu.org/licenses/>.
*/
#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 <getopt.h>
#include <fcntl.h>
#include "udev.h"
static bool skip_attribute(const char *name)
{
static const char const *skip[] = {
"uevent",
"dev",
"modalias",
"resource",
"driver",
"subsystem",
"module",
};
unsigned int i;
for (i = 0; i < ARRAY_SIZE(skip); i++)
return true;
return false;
}
{
struct udev_list_entry *sysattr;
const char *name;
const char *value;
if (skip_attribute(name))
continue;
continue;
/* skip any values that look like a path */
if (value[0] == '/')
continue;
/* skip nonprintable attributes */
len--;
if (len > 0)
continue;
}
printf("\n");
}
{
struct udev_device *device_parent;
const char *str;
printf("\n"
"Udevadm info starts with the device specified by the devpath and then\n"
"walks up the chain of parent devices. It prints for every device\n"
"found, all possible attributes in the udev rules key format.\n"
"A rule to match, can be composed by the attributes of the device\n"
"and the attributes from one single parent device.\n"
"\n");
str = "";
str = "";
do {
if (device_parent == NULL)
break;
str = "";
str = "";
} while (device_parent != NULL);
return 0;
}
{
const char *str;
int i;
struct udev_list_entry *list_entry;
if (i != 0)
printf("L: %i\n", i);
}
printf("E: %s=%s\n",
printf("\n");
}
{
return -1;
if (export) {
prefix = "INFO_";
printf("%sMAJOR=%d\n"
"%sMINOR=%d\n",
} else
return 0;
}
{
struct udev_enumerate *udev_enumerate;
struct udev_list_entry *list_entry;
if (udev_enumerate == NULL)
return -1;
struct udev_device *device;
}
}
return 0;
}
{
if (depth <= 0)
return;
continue;
continue;
continue;
}
} else {
}
}
}
{
char filename[UTIL_PATH_SIZE];
}
}
}
}
}
}
{
bool root = 0;
bool export = 0;
const char *export_prefix = NULL;
char path[UTIL_PATH_SIZE];
char name[UTIL_PATH_SIZE];
struct udev_list_entry *list_entry;
int rc = 0;
{}
};
enum action_type {
} action = ACTION_NONE;
enum query_type {
} query = QUERY_NONE;
for (;;) {
int option;
if (option == -1)
break;
switch (option) {
case 'n':
rc = 2;
goto exit;
}
/* remove /dev if given */
else
rc = 2;
goto exit;
} else {
char type;
type = 'b';
type = 'c';
} else {
rc = 2;
goto exit;
}
rc = 2;
goto exit;
}
}
break;
case 'p':
rc = 2;
goto exit;
}
/* add sys dir if needed */
else
rc = 2;
goto exit;
}
break;
case 'q':
query = QUERY_NAME;
query = QUERY_PATH;
} else {
rc = 3;
goto exit;
}
break;
case 'r':
if (action == ACTION_NONE)
root = true;
break;
case 'R':
goto exit;
case 'd':
break;
case 'a':
break;
case 'e':
goto exit;
case 'c':
goto exit;
case 'x':
export = true;
break;
case 'P':
break;
case 'V':
goto exit;
case 'h':
printf("Usage: udevadm info OPTIONS\n"
" --query=<type> query device information:\n"
" name name of device node\n"
" symlink pointing to node\n"
" path sys device path\n"
" property the device properties\n"
" all all values\n"
" --path=<syspath> sys device path used for query or attribute walk\n"
" --name=<name> node or symlink name used for query or attribute walk\n"
" --root prepend dev directory to path names\n"
" --attribute-walk print all key matches while walking along the chain\n"
" of parent devices\n"
" --device-id-of-file=<file> print major:minor of device containing this file\n"
" --export-prefix export the key name with a prefix\n"
" --export-db export the content of the udev database\n"
" --cleanup-db cleanup the udev database\n"
" --help\n\n");
goto exit;
default:
rc = 1;
goto exit;
}
}
switch (action) {
case ACTION_QUERY:
rc = 4;
goto exit;
}
switch(query) {
case QUERY_NAME: {
rc = 5;
goto exit;
}
if (root) {
} else {
}
break;
}
case QUERY_SYMLINK:
while (list_entry != NULL) {
if (root) {
} else {
}
if (list_entry != NULL)
printf(" ");
}
printf("\n");
break;
case QUERY_PATH:
goto exit;
case QUERY_PROPERTY:
while (list_entry != NULL) {
if (export) {
const char *prefix = export_prefix;
prefix = "";
} else {
}
}
break;
case QUERY_ALL:
break;
default:
break;
}
break;
case ACTION_ATTRIBUTE_WALK:
rc = 4;
goto exit;
}
break;
case ACTION_DEVICE_ID_FILE:
rc = 1;
break;
case ACTION_ROOT:
break;
default:
rc = 1;
break;
}
exit:
return rc;
}
const struct udevadm_cmd udevadm_info = {
.name = "info",
.help = "query sysfs or the udev database",
};