summaryrefslogtreecommitdiff
path: root/extras/volume_id
diff options
context:
space:
mode:
authorKay Sievers <kay.sievers@vrfy.org>2008-09-06 16:37:00 +0200
committerKay Sievers <kay.sievers@vrfy.org>2008-09-06 16:37:00 +0200
commitf640b32fddfc45210361813b50c629a80d2889d2 (patch)
treec3db230176841eb3cc296260a268552df8173a13 /extras/volume_id
parent7643819062985d9fc6c7664072576e71d3822b10 (diff)
vol_id: add --debug option
Diffstat (limited to 'extras/volume_id')
-rw-r--r--extras/volume_id/vol_id.c38
-rw-r--r--extras/volume_id/vol_id.xml15
2 files changed, 41 insertions, 12 deletions
diff --git a/extras/volume_id/vol_id.c b/extras/volume_id/vol_id.c
index dcfb0bb92f..d8302bc229 100644
--- a/extras/volume_id/vol_id.c
+++ b/extras/volume_id/vol_id.c
@@ -1,7 +1,7 @@
/*
* vol_id - read filesystem label and uuid
*
- * Copyright (C) 2005-2006 Kay Sievers <kay.sievers@vrfy.org>
+ * Copyright (C) 2005-2008 Kay Sievers <kay.sievers@vrfy.org>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
@@ -39,11 +39,18 @@
#define BLKGETSIZE64 _IOR(0x12,114,size_t)
+static int debug;
+
static void log_fn(struct udev *udev, int priority,
const char *file, int line, const char *fn,
const char *format, va_list args)
{
- vsyslog(priority, format, args);
+ if (debug) {
+ fprintf(stderr, "%s: ", fn != NULL ? fn : file);
+ vfprintf(stderr, format, args);
+ } else {
+ vsyslog(priority, format, args);
+ }
}
static void vid_log(int priority, const char *file, int line, const char *format, ...)
@@ -113,6 +120,7 @@ int main(int argc, char *argv[])
{ "skip-raid", 0, NULL, 's' },
{ "probe-all", 0, NULL, 'a' },
{ "offset", 2, NULL, 'o' },
+ { "debug", 0, NULL, 'd' },
{ "help", 0, NULL, 'h' },
{}
};
@@ -151,11 +159,16 @@ int main(int argc, char *argv[])
while (1) {
int option;
- option = getopt_long(argc, argv, "lLutxsaoh", options, NULL);
+ option = getopt_long(argc, argv, "lLutxsaodh", options, NULL);
if (option == -1)
break;
switch (option) {
+ case 'd':
+ debug = 1;
+ if (udev_get_log_priority(udev) < LOG_INFO)
+ udev_set_log_priority(udev, LOG_INFO);
+ break;
case 'l':
print = PRINT_LABEL;
break;
@@ -183,14 +196,15 @@ int main(int argc, char *argv[])
break;
case 'h':
printf("Usage: vol_id [options] <device>\n"
- " --export export key/value pairs\n"
- " --type filesystem type\n"
- " --label filesystem label\n"
- " --label-raw raw label\n"
- " --uuid filesystem uuid\n"
- " --skip-raid don't probe for raid\n"
- " --probe-all find possibly conflicting signatures\n"
- " --offset skip given number of bytes of input\n"
+ " --export export key/value pairs\n"
+ " --type filesystem type\n"
+ " --label filesystem label\n"
+ " --label-raw raw label\n"
+ " --uuid filesystem uuid\n"
+ " --skip-raid don't probe for raid\n"
+ " --probe-all find possibly conflicting signatures\n"
+ " --offset=<bytes> probe at the given offset\n"
+ " --debug print debug output to stderr\n"
" --help\n\n");
goto exit;
default:
@@ -222,7 +236,7 @@ int main(int argc, char *argv[])
if (ioctl(fd, BLKGETSIZE64, &size) != 0)
size = 0;
- dbg(udev, "BLKGETSIZE64=%llu\n", (unsigned long long)size);
+ info(udev, "BLKGETSIZE64=%llu (%lluGB)\n", (unsigned long long)size, (unsigned long long)size >> 30);
/* try to drop all privileges before reading disk content */
if (getuid() == 0) {
diff --git a/extras/volume_id/vol_id.xml b/extras/volume_id/vol_id.xml
index 6d0a6c6923..fcf3a31fa5 100644
--- a/extras/volume_id/vol_id.xml
+++ b/extras/volume_id/vol_id.xml
@@ -32,6 +32,8 @@
<arg><option>--uuid</option></arg>
<arg><option>--skip-raid</option></arg>
<arg><option>--probe-all</option></arg>
+ <arg><option>--offset=<replaceable>bytes</replaceable></option></arg>
+ <arg><option>--debug</option></arg>
<arg><option>--help</option></arg>
<arg><replaceable>device</replaceable></arg>
</cmdsynopsis>
@@ -96,6 +98,19 @@
</listitem>
</varlistentry>
<varlistentry>
+ <term><option>--offset=<replaceable>bytes</replaceable></option></term>
+ <listitem>
+ <para>Probing at the given offset, instead of the start of the volume.
+ The offset value is specified in bytes.</para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><option>--debug</option></term>
+ <listitem>
+ <para>Print debug output to stderr.</para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
<term><option>--help</option></term>
<listitem>
<para>Print usage.</para>