chiark / gitweb /
vol_id: make the --offset= argument optional
authorKay Sievers <kay.sievers@vrfy.org>
Fri, 22 Aug 2008 08:04:55 +0000 (10:04 +0200)
committerKay Sievers <kay.sievers@vrfy.org>
Fri, 22 Aug 2008 08:04:55 +0000 (10:04 +0200)
extras/cdrom_id/cdrom_id.c
extras/volume_id/vol_id.c

index acf7a97..9e27471 100644 (file)
@@ -693,11 +693,11 @@ print:
                printf("ID_CDROM_MEDIA_SESSION_COUNT=%d\n", cd_media_session_count);
        if (cd_media_track_count > 0)
                printf("ID_CDROM_MEDIA_TRACK_COUNT=%d\n", cd_media_track_count);
-       if (cd_media_track_count_audio)
+       if (cd_media_track_count_audio > 0)
                printf("ID_CDROM_MEDIA_TRACK_COUNT_AUDIO=%d\n", cd_media_track_count_audio);
-       if (cd_media_track_count_data)
+       if (cd_media_track_count_data > 0)
                printf("ID_CDROM_MEDIA_TRACK_COUNT_DATA=%d\n", cd_media_track_count_data);
-       if (cd_media_session_last_offset)
+       if (cd_media_session_last_offset > 0)
                printf("ID_CDROM_MEDIA_SESSION_LAST_OFFSET=%llu\n", cd_media_session_last_offset);
 exit:
        if (fd >= 0)
index 60428ab..b3f810f 100644 (file)
@@ -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"