vtoydump.c 17.3 KB
Newer Older
longpanda's avatar
longpanda committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
/******************************************************************************
 * vtoydump.c  ---- Dump ventoy os parameters 
 *
 * Copyright (c) 2020, longpanda <admin@ventoy.net>
 *
 * 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 Free Software Foundation; either version 3 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 <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
25
#include <ctype.h>
longpanda's avatar
longpanda committed
26
27
28
29
30
31
32
33
34
#include <unistd.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/mman.h>
#include <sys/ioctl.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <linux/fs.h>
#include <dirent.h>
longpanda's avatar
longpanda committed
35
#include "vtoytool.h"
longpanda's avatar
longpanda committed
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53

#ifndef O_BINARY
#define O_BINARY 0
#endif
#if defined(_dragon_fly) || defined(_free_BSD) || defined(_QNX)
#define MMAP_FLAGS          MAP_SHARED
#else
#define MMAP_FLAGS          MAP_PRIVATE
#endif

#define SEARCH_MEM_START 0x80000
#define SEARCH_MEM_LEN   0x1c000

static int verbose = 0;
#define debug(fmt, ...) if(verbose) printf(fmt, ##__VA_ARGS__)

static ventoy_guid vtoy_guid = VENTOY_GUID;

longpanda's avatar
longpanda committed
54
55
static const char *g_ventoy_fs[ventoy_fs_max] = 
{
longpanda's avatar
longpanda committed
56
    "exfat", "ntfs", "ext*", "xfs", "udf", "fat"
longpanda's avatar
longpanda committed
57
58
};

longpanda's avatar
longpanda committed
59
60
61
62
63
64
65
66
static int vtoy_check_os_param(ventoy_os_param *param)
{
    uint32_t i;
    uint8_t  chksum = 0;
    uint8_t *buf = (uint8_t *)param;
    
    if (memcmp(&param->guid, &vtoy_guid, sizeof(ventoy_guid)))
    {
longpanda's avatar
longpanda committed
67
68
69
70
71
72
73
74
75
76
        uint8_t *data1 = (uint8_t *)(&param->guid);
        uint8_t *data2 = (uint8_t *)(&vtoy_guid);
        
        for (i = 0; i < 16; i++)
        {
            if (data1[i] != data2[i])
            {
                debug("guid not equal i = %u, 0x%02x, 0x%02x\n", i, data1[i], data2[i]);
            }
        }
longpanda's avatar
longpanda committed
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
        return 1;
    }

    for (i = 0; i < sizeof(ventoy_os_param); i++)
    {
        chksum += buf[i];
    }

    if (chksum)
    {
        debug("Invalid checksum 0x%02x\n", chksum);
        return 1;
    }

    return 0;
}

static int vtoy_os_param_from_file(const char *filename, ventoy_os_param *param)
{
    int fd = 0;
    int rc = 0;

    fd = open(filename, O_RDONLY | O_BINARY);
    if (fd < 0)
    {
        fprintf(stderr, "Failed to open file %s error %d\n", filename, errno);
        return errno;
    }

    read(fd, param, sizeof(ventoy_os_param));

    if (vtoy_check_os_param(param) == 0)
    {
        debug("find ventoy os param in file %s\n", filename);
    }
    else
    {
        debug("ventoy os pararm NOT found in file %s\n", filename);
        rc = 1;
    }
    
    close(fd);
    return rc;
}

static void vtoy_dump_os_param(ventoy_os_param *param)
{
    printf("################# dump os param ################\n");

    printf("param->chksum = 0x%x\n", param->chksum);
    printf("param->vtoy_disk_guid = %02x %02x %02x %02x\n", 
        param->vtoy_disk_guid[0], param->vtoy_disk_guid[1], 
        param->vtoy_disk_guid[2], param->vtoy_disk_guid[3]);
130
131
132
133
134
    
    printf("param->vtoy_disk_signature = %02x %02x %02x %02x\n", 
        param->vtoy_disk_signature[0], param->vtoy_disk_signature[1], 
        param->vtoy_disk_signature[2], param->vtoy_disk_signature[3]);
    
longpanda's avatar
longpanda committed
135
136
137
138
139
140
141
    printf("param->vtoy_disk_size = %llu\n", (unsigned long long)param->vtoy_disk_size);
    printf("param->vtoy_disk_part_id = %u\n", param->vtoy_disk_part_id);
    printf("param->vtoy_disk_part_type = %u\n", param->vtoy_disk_part_type);
    printf("param->vtoy_img_path = <%s>\n", param->vtoy_img_path);
    printf("param->vtoy_img_size = <%llu>\n", (unsigned long long)param->vtoy_img_size);
    printf("param->vtoy_img_location_addr = <0x%llx>\n", (unsigned long long)param->vtoy_img_location_addr);
    printf("param->vtoy_img_location_len = <%u>\n", param->vtoy_img_location_len);
longpanda's avatar
longpanda committed
142
143
144
145
146
147
148
149
150
151
    printf("param->vtoy_reserved = %02x %02x %02x %02x %02x %02x %02x %02x\n", 
        param->vtoy_reserved[0],
        param->vtoy_reserved[1],
        param->vtoy_reserved[2],
        param->vtoy_reserved[3],
        param->vtoy_reserved[4],
        param->vtoy_reserved[5],
        param->vtoy_reserved[6],
        param->vtoy_reserved[7]
        );
longpanda's avatar
longpanda committed
152
153
154
155
    
    printf("\n");
}

156
static int vtoy_get_disk_guid(const char *diskname, uint8_t *vtguid, uint8_t *vtsig)
longpanda's avatar
longpanda committed
157
158
159
160
161
162
163
164
165
166
167
168
{
    int i = 0;
    int fd = 0;
    char devdisk[128] = {0};

    snprintf(devdisk, sizeof(devdisk) - 1, "/dev/%s", diskname);
    
    fd = open(devdisk, O_RDONLY | O_BINARY);
    if (fd >= 0)
    {
        lseek(fd, 0x180, SEEK_SET);
        read(fd, vtguid, 16);
169
170
171
        
        lseek(fd, 0x1b8, SEEK_SET);
        read(fd, vtsig, 4);
longpanda's avatar
longpanda committed
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
        close(fd);

        debug("GUID for %s: <", devdisk);
        for (i = 0; i < 16; i++)
        {
            debug("%02x", vtguid[i]);
        }
        debug(">\n");
        
        return 0;
    }
    else
    {
        debug("failed to open %s %d\n", devdisk, errno);
        return errno;
    }
}

static unsigned long long vtoy_get_disk_size_in_byte(const char *disk)
{
    int fd;
    int rc;
    unsigned long long size = 0;
    char diskpath[256] = {0};
    char sizebuf[64] = {0};

    // Try 1: get size from sysfs
    snprintf(diskpath, sizeof(diskpath) - 1, "/sys/block/%s/size", disk);
    if (access(diskpath, F_OK) >= 0)
    {
        debug("get disk size from sysfs for %s\n", disk);
        
        fd = open(diskpath, O_RDONLY | O_BINARY);
        if (fd >= 0)
        {
            read(fd, sizebuf, sizeof(sizebuf));
            size = strtoull(sizebuf, NULL, 10);
            close(fd);
            return (size * 512);
        }
    }
    else
    {
        debug("%s not exist \n", diskpath);
    }

    // Try 2: get size from ioctl
    snprintf(diskpath, sizeof(diskpath) - 1, "/dev/%s", disk);
    fd = open(diskpath, O_RDONLY);
    if (fd >= 0)
    {
        debug("get disk size from ioctl for %s\n", disk);
        rc = ioctl(fd, BLKGETSIZE64, &size);
        if (rc == -1)
        {
            size = 0;
            debug("failed to ioctl %d\n", rc);
        }
        close(fd);
    }
    else
    {
        debug("failed to open %s %d\n", diskpath, errno);
    }

    debug("disk %s size %llu bytes\n", disk, (unsigned long long)size);
    return size;
}

static int vtoy_is_possible_blkdev(const char *name)
{
    if (name[0] == '.')
    {
        return 0;
    }

    /* /dev/ramX */
    if (name[0] == 'r' && name[1] == 'a' && name[2] == 'm')
    {
        return 0;
    }

    /* /dev/loopX */
    if (name[0] == 'l' && name[1] == 'o' && name[2] == 'o' && name[3] == 'p')
    {
        return 0;
    }

    /* /dev/dm-X */
    if (name[0] == 'd' && name[1] == 'm' && name[2] == '-' && IS_DIGIT(name[3]))
    {
        return 0;
    }

    /* /dev/srX */
    if (name[0] == 's' && name[1] == 'r' && IS_DIGIT(name[2]))
    {
        return 0;
    }
    
    return 1;
}

static int vtoy_find_disk_by_size(unsigned long long size, char *diskname)
{
    unsigned long long cursize = 0;
    DIR* dir = NULL;
    struct dirent* p = NULL;
    int rc = 0;

    dir = opendir("/sys/block");
longpanda's avatar
longpanda committed
283
284
285
286
287
    if (!dir)
    {
        return 0;
    }
    
longpanda's avatar
longpanda committed
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
    while ((p = readdir(dir)) != NULL)
    {
        if (!vtoy_is_possible_blkdev(p->d_name))
        {
            debug("disk %s is filted by name\n", p->d_name);
            continue;
        }
    
        cursize = vtoy_get_disk_size_in_byte(p->d_name);
        debug("disk %s size %llu\n", p->d_name, (unsigned long long)cursize);
        if (cursize == size)
        {
            sprintf(diskname, "%s", p->d_name);
            rc++;
        }
    }
    closedir(dir);
    return rc;    
}

longpanda's avatar
longpanda committed
308
int vtoy_find_disk_by_guid(ventoy_os_param *param, char *diskname)
longpanda's avatar
longpanda committed
309
310
311
312
313
314
{
    int rc = 0;
    int count = 0;
    DIR* dir = NULL;
    struct dirent* p = NULL;
    uint8_t vtguid[16];
315
    uint8_t vtsig[16];
longpanda's avatar
longpanda committed
316
317

    dir = opendir("/sys/block");
longpanda's avatar
longpanda committed
318
319
320
321
322
    if (!dir)
    {
        return 0;
    }
    
longpanda's avatar
longpanda committed
323
324
325
326
327
328
329
330
331
    while ((p = readdir(dir)) != NULL)
    {
        if (!vtoy_is_possible_blkdev(p->d_name))
        {
            debug("disk %s is filted by name\n", p->d_name);        
            continue;
        }
    
        memset(vtguid, 0, sizeof(vtguid));
longpanda's avatar
longpanda committed
332
        memset(vtsig, 0, sizeof(vtsig));
333
334
335
        rc = vtoy_get_disk_guid(p->d_name, vtguid, vtsig);
        if (rc == 0 && memcmp(vtguid, param->vtoy_disk_guid, 16) == 0 && 
            memcmp(vtsig, param->vtoy_disk_signature, 4) == 0)
longpanda's avatar
longpanda committed
336
337
338
339
340
341
342
343
344
345
        {
            sprintf(diskname, "%s", p->d_name);
            count++;
        }
    }
    closedir(dir);
    
    return count;    
}

longpanda's avatar
longpanda committed
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
static int vtoy_find_disk_by_sig(uint8_t *sig, char *diskname)
{
    int rc = 0;
    int count = 0;
    DIR* dir = NULL;
    struct dirent* p = NULL;
    uint8_t vtguid[16];
    uint8_t vtsig[16];

    dir = opendir("/sys/block");
    if (!dir)
    {
        return 0;
    }
    
    while ((p = readdir(dir)) != NULL)
    {
        if (!vtoy_is_possible_blkdev(p->d_name))
        {
            debug("disk %s is filted by name\n", p->d_name);        
            continue;
        }

        memset(vtguid, 0, sizeof(vtguid));
        memset(vtsig, 0, sizeof(vtsig));
        rc = vtoy_get_disk_guid(p->d_name, vtguid, vtsig);
        if (rc == 0 && memcmp(vtsig, sig, 4) == 0)
        {
            sprintf(diskname, "%s", p->d_name);
            count++;
        }
    }
    closedir(dir);
    
    return count;    
}

longpanda's avatar
longpanda committed
383
384
385
386
387
388
static int vtoy_printf_iso_path(ventoy_os_param *param)
{
    printf("%s\n", param->vtoy_img_path);
    return 0;
}

389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
static int vtoy_printf_fs(ventoy_os_param *param)
{
    const char *fs[] = 
    {
        "exfat", "ntfs", "ext", "xfs", "udf", "fat"
    };

    if (param->vtoy_disk_part_type < 6)
    {
        printf("%s\n", fs[param->vtoy_disk_part_type]);
    }
    else
    {
        printf("unknown\n");
    }
    return 0;
}

longpanda's avatar
longpanda committed
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
static int vtoy_vlnk_printf(ventoy_os_param *param, char *diskname)
{
    int cnt = 0;
    uint8_t disk_sig[4];
    uint8_t mbr[512];
    int fd = -1;
    char diskpath[128];
    uint8_t check[8] = { 0x56, 0x54, 0x00, 0x47, 0x65, 0x00, 0x48, 0x44 };
    
    memcpy(disk_sig, param->vtoy_reserved + 7, 4);

    debug("vlnk disk sig: %02x %02x %02x %02x \n", disk_sig[0], disk_sig[1], disk_sig[2], disk_sig[3]);

    cnt = vtoy_find_disk_by_sig(disk_sig, diskname);
    if (cnt == 1)
    {
        snprintf(diskpath, sizeof(diskpath), "/dev/%s", diskname);
        fd = open(diskpath, O_RDONLY | O_BINARY);
        if (fd >= 0)
        {
            memset(mbr, 0, sizeof(mbr));
            read(fd, mbr, sizeof(mbr));
            close(fd);

            if (memcmp(mbr + 0x190, check, 8) == 0)
            {
                printf("/dev/%s", diskname);
                return 0;                
            }
            else
            {
                debug("check data failed /dev/%s\n", diskname);
            }
        }
    }

    debug("find count=%d\n", cnt);
    printf("unknown");
    return 1;
}

448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
static int vtoy_check_iso_path_alpnum(ventoy_os_param *param)
{
    char c;
    int i = 0;
    
    while (param->vtoy_img_path[i])
    {
        c = param->vtoy_img_path[i]; 
        
        if (isalnum(c) || c == '_' || c == '-')
        {
            
        }
        else
        {
            return 1;
        }
        i++;
    }

    return 0;
}

longpanda's avatar
longpanda committed
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
static int vtoy_check_device(ventoy_os_param *param, const char *device)
{
    unsigned long long size; 
    uint8_t vtguid[16] = {0};
    uint8_t vtsig[4] = {0};

    debug("vtoy_check_device for <%s>\n", device);

    size = vtoy_get_disk_size_in_byte(device);
    vtoy_get_disk_guid(device, vtguid, vtsig);

    debug("param->vtoy_disk_size=%llu size=%llu\n", 
        (unsigned long long)param->vtoy_disk_size, (unsigned long long)size);

    if (memcmp(vtguid, param->vtoy_disk_guid, 16) == 0 &&
        memcmp(vtsig, param->vtoy_disk_signature, 4) == 0)
    {
        debug("<%s> is right ventoy disk\n", device);
        return 0;
    }
    else
    {
        debug("<%s> is NOT right ventoy disk\n", device);
        return 1;
    }
}

longpanda's avatar
longpanda committed
498
499
static int vtoy_print_os_param(ventoy_os_param *param, char *diskname)
{
500
501
    int fd, size;
    int cnt = 0;
longpanda's avatar
longpanda committed
502
503
    char *path = param->vtoy_img_path;
    const char *fs;
504
505
506
    char diskpath[256] = {0};
    char sizebuf[64] = {0};
    
longpanda's avatar
longpanda committed
507
    cnt = vtoy_find_disk_by_size(param->vtoy_disk_size, diskname);
longpanda's avatar
longpanda committed
508
509
    debug("find disk by size %llu, cnt=%d...\n", (unsigned long long)param->vtoy_disk_size, cnt);
    if (1 == cnt)
longpanda's avatar
longpanda committed
510
    {
longpanda's avatar
longpanda committed
511
512
513
514
        if (vtoy_check_device(param, diskname) != 0)
        {
            cnt = 0;
        }
longpanda's avatar
longpanda committed
515
    }
longpanda's avatar
longpanda committed
516
    else
longpanda's avatar
longpanda committed
517
    {
518
        cnt = vtoy_find_disk_by_guid(param, diskname);
longpanda's avatar
longpanda committed
519
        debug("find disk by guid cnt=%d...\n", cnt);
longpanda's avatar
longpanda committed
520
    }
longpanda's avatar
longpanda committed
521
    
longpanda's avatar
longpanda committed
522
    if (param->vtoy_disk_part_type < ventoy_fs_max)
longpanda's avatar
longpanda committed
523
    {
longpanda's avatar
longpanda committed
524
        fs = g_ventoy_fs[param->vtoy_disk_part_type];
longpanda's avatar
longpanda committed
525
526
527
528
529
530
531
532
    }
    else
    {
        fs = "unknown";
    }

    if (1 == cnt)
    {
533
534
535
536
537
538
539
540
541
        if (strstr(diskname, "nvme") || strstr(diskname, "mmc") || strstr(diskname, "nbd"))
        {
            snprintf(diskpath, sizeof(diskpath) - 1, "/sys/class/block/%sp2/size", diskname);
        }
        else
        {
            snprintf(diskpath, sizeof(diskpath) - 1, "/sys/class/block/%s2/size", diskname);
        }

longpanda's avatar
longpanda committed
542
        if (param->vtoy_reserved[6] == 0 && access(diskpath, F_OK) >= 0)
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
        {
            debug("get part size from sysfs for %s\n", diskpath);

            fd = open(diskpath, O_RDONLY | O_BINARY);
            if (fd >= 0)
            {
                read(fd, sizebuf, sizeof(sizebuf));
                size = (int)strtoull(sizebuf, NULL, 10);
                close(fd);
                if ((size != (64 * 1024)) && (size != (8 * 1024)))
                {
                    debug("sizebuf=<%s> size=%d\n", sizebuf, size);
                    return 1;
                }
            }
        }
        else
        {
            debug("%s not exist \n", diskpath);
        }

longpanda's avatar
longpanda committed
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
        printf("/dev/%s#%s#%s\n", diskname, fs, path);
        return 0;
    }
    else
    {
        return 1;
    }
}

/*
 *  Find disk and image path from ventoy runtime data.
 *  By default data is read from phymem(legacy bios) or efivar(UEFI), if -f is input, data is read from file.
 *  
 *  -f datafile     os param data file. 
 *  -c /dev/xxx     check ventoy disk
 *  -v              be verbose
 *  -l              also print image disk location 
 */
int vtoydump_main(int argc, char **argv)
{
    int rc;
    int ch;
longpanda's avatar
longpanda committed
586
    int print_path = 0;
587
    int check_ascii = 0;
588
    int print_fs = 0;
longpanda's avatar
longpanda committed
589
    int vlnk_print = 0;
longpanda's avatar
longpanda committed
590
591
592
593
594
    char filename[256] = {0};
    char diskname[256] = {0};
    char device[64] = {0};
    ventoy_os_param *param = NULL;

595
    while ((ch = getopt(argc, argv, "a:c:f:p:t:s:v::")) != -1)
longpanda's avatar
longpanda committed
596
597
598
599
600
601
602
603
604
605
606
607
608
    {
        if (ch == 'f')
        {
            strncpy(filename, optarg, sizeof(filename) - 1);
        }
        else if (ch == 'v')
        {
            verbose = 1;
        }
        else if (ch == 'c')
        {
            strncpy(device, optarg, sizeof(device) - 1);
        }
longpanda's avatar
longpanda committed
609
610
611
612
613
        else if (ch == 'p')
        {
            print_path = 1;
            strncpy(filename, optarg, sizeof(filename) - 1);
        }
614
615
616
617
618
        else if (ch == 'a')
        {
            check_ascii = 1;
            strncpy(filename, optarg, sizeof(filename) - 1);
        }
longpanda's avatar
longpanda committed
619
620
621
622
623
        else if (ch == 't')
        {
            vlnk_print = 1;
            strncpy(filename, optarg, sizeof(filename) - 1);
        }
624
625
626
627
628
        else if (ch == 's')
        {
            print_fs = 1;
            strncpy(filename, optarg, sizeof(filename) - 1);
        }
longpanda's avatar
longpanda committed
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
        else
        {
            fprintf(stderr, "Usage: %s -f datafile [ -v ] \n", argv[0]);
            return 1;
        }
    }

    if (filename[0] == 0)
    {
        fprintf(stderr, "Usage: %s -f datafile [ -v ] \n", argv[0]);
        return 1;
    }

    param = malloc(sizeof(ventoy_os_param));
    if (NULL == param)
    {
        fprintf(stderr, "failed to alloc memory with size %d error %d\n", 
                (int)sizeof(ventoy_os_param), errno);
        return 1;
    }
    
    memset(param, 0, sizeof(ventoy_os_param));

    debug("get os pararm from file %s\n", filename);
    rc = vtoy_os_param_from_file(filename, param);
    if (rc)
    {
longpanda's avatar
update  
longpanda committed
656
657
658
659
660
661
662
663
664
665
666
667
668
669
        debug("ventoy os param not found %d %d\n", rc, ENOENT);
        if (ENOENT == rc)
        {
            debug("now try with file %s\n", "/ventoy/ventoy_os_param");
            rc = vtoy_os_param_from_file("/ventoy/ventoy_os_param", param);
            if (rc)
            {
                goto end;
            }
        }
        else
        {
            goto end;            
        }        
longpanda's avatar
longpanda committed
670
671
672
673
674
675
676
    }

    if (verbose)
    {
        vtoy_dump_os_param(param);
    }

longpanda's avatar
longpanda committed
677
678
679
680
    if (print_path)
    {
        rc = vtoy_printf_iso_path(param);
    }
681
682
683
684
    else if (print_fs)
    {
        rc = vtoy_printf_fs(param);
    }
longpanda's avatar
longpanda committed
685
686
687
688
    else if (vlnk_print)
    {
        rc = vtoy_vlnk_printf(param, diskname);
    }
longpanda's avatar
longpanda committed
689
    else if (device[0])
longpanda's avatar
longpanda committed
690
691
692
    {
        rc = vtoy_check_device(param, device);
    }
693
694
695
696
    else if (check_ascii)
    {
        rc = vtoy_check_iso_path_alpnum(param);
    }
longpanda's avatar
longpanda committed
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
    else
    {
        // print os param, you can change the output format in the function
        rc = vtoy_print_os_param(param, diskname);
    }

end:
    if (param)
    {
        free(param);
    }
    return rc;
}

// wrapper main
#ifndef BUILD_VTOY_TOOL
int main(int argc, char **argv)
{
    return vtoydump_main(argc, argv);
}
#endif