/*
* Copyright (C) 2004-2009 Kay Sievers <kay@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 <ctype.h>
#include <dirent.h>
#include <errno.h>
#include <fcntl.h>
#include <getopt.h>
#include <stddef.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include "fd-util.h"
#include "string-util.h"
#include "udev-util.h"
#include "udev.h"
#include "udevadm-util.h"
static const char* const skip[] = {
"uevent",
"dev",
"modalias",
"resource",
"driver",
"subsystem",
"module",
};
unsigned int i;
for (i = 0; i < ELEMENTSOF(skip); i++)
return true;
return false;
}
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");
}
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;
if (i != 0)
printf("L: %i\n", i);
printf("E: %s=%s\n",
printf("\n");
}
return -1;
if (export) {
prefix = "INFO_";
printf("%sMAJOR=%u\n"
"%sMINOR=%u\n",
} else
return 0;
}
if (udev_enumerate == NULL)
return -1;
}
}
return 0;
}
if (depth <= 0)
return;
continue;
continue;
continue;
} else
}
}
}
}
}
}
}
}
static void help(void) {
printf("%s info [OPTIONS] [DEVPATH|FILE]\n\n"
"Query sysfs or the udev database.\n\n"
" -h --help Print this message\n"
" --version Print version of the program\n"
" -q --query=TYPE Query device information:\n"
" name Name of device node\n"
" symlink Pointing to node\n"
" path sysfs device path\n"
" property The device properties\n"
" all All values\n"
" -p --path=SYSPATH sysfs device path used for query or attribute walk\n"
" -n --name=NAME Node or symlink name used for query or attribute walk\n"
" -r --root Prepend dev directory to path names\n"
" -a --attribute-walk Print all key matches walking along the chain\n"
" of parent devices\n"
" -d --device-id-of-file=FILE Print major:minor of device containing this file\n"
" -P --export-prefix Export the key name with a prefix\n"
" -e --export-db Export the content of the udev database\n"
" -c --cleanup-db Clean up the udev database\n"
}
bool root = 0;
bool export = 0;
int c;
{}
};
enum action_type {
enum query_type {
switch (c) {
case 'n': {
return 2;
}
return 2;
}
break;
}
case 'p':
return 2;
}
return 2;
}
break;
case 'q':
query = QUERY_NAME;
query = QUERY_PATH;
else {
return 3;
}
break;
case 'r':
root = true;
break;
case 'd':
break;
case 'a':
break;
case 'e':
return 0;
case 'c':
return 0;
case 'x':
export = true;
break;
case 'P':
break;
case 'V':
return 0;
case 'h':
help();
return 0;
default:
return 1;
}
switch (action) {
case ACTION_QUERY:
if (!device) {
help();
return 2;
}
if (!device) {
return 4;
}
}
switch(query) {
case QUERY_NAME: {
return 5;
}
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:
return 0;
case QUERY_PROPERTY:
while (list_entry != NULL) {
if (export) {
prefix = "";
} else {
}
}
break;
case QUERY_ALL:
break;
default:
assert_not_reached("unknown query type");
}
break;
case ACTION_ATTRIBUTE_WALK:
if (!device) {
return 4;
}
}
if (!device) {
return 4;
}
break;
case ACTION_DEVICE_ID_FILE:
return 1;
break;
}
return 0;
}
.name = "info",
.help = "Query sysfs or the udev database",
};