"sgl-router/py_src/sglang_router/router.py" did not exist on "86c37d010aeabb1bd2f4a05e19b6bb7f14c3d8da"
vlnk.c 1.48 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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include "vlnk.h"

int ventoy_create_vlnk(uint32_t disksig, uint64_t partoffset, const char *path, ventoy_vlnk *vlnk)
{
    uint32_t crc;
    ventoy_guid guid = VENTOY_GUID;

    memcpy(&(vlnk->guid), &guid, sizeof(ventoy_guid));
    vlnk->disk_signature = disksig;
    vlnk->part_offset = partoffset;

#ifdef WIN32
    strcpy_s(vlnk->filepath, sizeof(vlnk->filepath) - 1, path);
#else
    strncpy(vlnk->filepath, path, sizeof(vlnk->filepath) - 1);
#endif

    crc = ventoy_getcrc32c(0, vlnk, sizeof(ventoy_vlnk));
    vlnk->crc32 = crc;

    return 0;
}


int CheckVlnkData(ventoy_vlnk *vlnk)
{
    uint32_t readcrc, calccrc;
    ventoy_guid guid = VENTOY_GUID;

    if (memcmp(&vlnk->guid, &guid, sizeof(guid)))
    {
        return 0;
    }

    readcrc = vlnk->crc32;
    vlnk->crc32 = 0;
    calccrc = ventoy_getcrc32c(0, vlnk, sizeof(ventoy_vlnk));

    if (readcrc != calccrc)
    {
        return 0;
    }

    return 1;
}

int IsSupportedImgSuffix(char *suffix)
{
    int i = 0;
    const char *suffixs[] =
    {
        ".iso", ".img", ".wim", ".efi", ".vhd", ".vhdx", ".dat", ".vtoy", NULL
    };

    if (!suffix)
    {
        return 0;
    }

    while (suffixs[i])
    {

#ifdef WIN32
        if (_stricmp(suffixs[i], suffix) == 0)
#else
        if (strcasecmp(suffixs[i], suffix) == 0)
#endif
        {
            return 1;
        }

        i++;
    }

    return 0;
}