chiark / gitweb /
libudev: require LIBUDEV_I_KNOW_THE_API_IS_SUBJECT_TO_CHANGE
[elogind.git] / extras / volume_id / vol_id.c
index 04e85abb7f8bd02bd69a59ad09a0d112de0bfe5d..b3f810fc9d3d6082af10e4ad8e1a132fcc44c617 100644 (file)
@@ -34,7 +34,7 @@
 #include <fcntl.h>
 #include <sys/ioctl.h>
 
-#include "../../udev.h"
+#include "../../udev/udev.h"
 #include "lib/libvolume_id.h"
 
 #define BLKGETSIZE64 _IOR(0x12,114,size_t)
@@ -134,7 +134,7 @@ int main(int argc, char *argv[])
                { "export", 0, NULL, 'x' },
                { "skip-raid", 0, NULL, 's' },
                { "probe-all", 0, NULL, 'a' },
-               { "offset", 1, NULL, 'o' },
+               { "offset", 2, NULL, 'o' },
                { "help", 0, NULL, 'h' },
                {}
        };
@@ -196,7 +196,8 @@ int main(int argc, char *argv[])
                        probe_all = 1;
                        break;
                case 'o':
-                       offset = strtoull(optarg, NULL, 0);
+                       if (optarg[0] != '\0')
+                               offset = strtoull(optarg, NULL, 0);
                        break;
                case 'h':
                        printf("Usage: vol_id [options] <device>\n"
@@ -218,7 +219,7 @@ int main(int argc, char *argv[])
 
        node = argv[optind];
        if (!node) {
-               err("no device");
+               err("no device\n");
                fprintf(stderr, "no device\n");
                rc = 1;
                goto exit;
@@ -239,7 +240,7 @@ int main(int argc, char *argv[])
 
        if (ioctl(fd, BLKGETSIZE64, &size) != 0)
                size = 0;
-       dbg("BLKGETSIZE64=%llu", (unsigned long long)size);
+       dbg("BLKGETSIZE64=%llu\n", (unsigned long long)size);
 
        /* try to drop all privileges before reading disk content */
        if (getuid() == 0) {
@@ -250,7 +251,7 @@ int main(int argc, char *argv[])
                        if (setgroups(0, NULL) != 0 ||
                            setgid(pw->pw_gid) != 0 ||
                            setuid(pw->pw_uid) != 0)
-                               info("unable to drop privileges: %s\n", strerror(errno));
+                               info("unable to drop privileges: %s\n\n", strerror(errno));
                }
        }