refactor: rename vlnk to hlnk in hisolnk tool

Rename vlnk.c→hlnk.c, vlnk.h→hlnk.h. Update crc32.c and main_linux.c
references. The file format concept changes from 'Ventoy Link' to
'Hiperiso Link' throughout. hisolnk tool builds successfully (19K).
This commit is contained in:
2026-06-30 19:53:35 +03:00
parent 2750e0bf78
commit 514f8a13e0
4 changed files with 58 additions and 58 deletions
+1 -1
View File
@@ -21,7 +21,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <stdint.h> #include <stdint.h>
#include <string.h> #include <string.h>
#include "vlnk.h" #include "hlnk.h"
static uint32_t crc32c_table [256]; static uint32_t crc32c_table [256];
+14 -14
View File
@@ -2,43 +2,43 @@
#include <stdlib.h> #include <stdlib.h>
#include <stdint.h> #include <stdint.h>
#include <string.h> #include <string.h>
#include "vlnk.h" #include "hlnk.h"
int hiperiso_create_vlnk(uint32_t disksig, uint64_t partoffset, const char *path, hiperiso_vlnk *vlnk) int hiperiso_create_hlnk(uint32_t disksig, uint64_t partoffset, const char *path, hiperiso_hlnk *hlnk)
{ {
uint32_t crc; uint32_t crc;
hiperiso_guid guid = HIPERISO_GUID; hiperiso_guid guid = HIPERISO_GUID;
memcpy(&(vlnk->guid), &guid, sizeof(hiperiso_guid)); memcpy(&(hlnk->guid), &guid, sizeof(hiperiso_guid));
vlnk->disk_signature = disksig; hlnk->disk_signature = disksig;
vlnk->part_offset = partoffset; hlnk->part_offset = partoffset;
#ifdef WIN32 #ifdef WIN32
strcpy_s(vlnk->filepath, sizeof(vlnk->filepath) - 1, path); strcpy_s(hlnk->filepath, sizeof(hlnk->filepath) - 1, path);
#else #else
strncpy(vlnk->filepath, path, sizeof(vlnk->filepath) - 1); strncpy(hlnk->filepath, path, sizeof(hlnk->filepath) - 1);
#endif #endif
crc = hiperiso_getcrc32c(0, vlnk, sizeof(hiperiso_vlnk)); crc = hiperiso_getcrc32c(0, hlnk, sizeof(hiperiso_hlnk));
vlnk->crc32 = crc; hlnk->crc32 = crc;
return 0; return 0;
} }
int CheckVlnkData(hiperiso_vlnk *vlnk) int CheckHlnkData(hiperiso_hlnk *hlnk)
{ {
uint32_t readcrc, calccrc; uint32_t readcrc, calccrc;
hiperiso_guid guid = HIPERISO_GUID; hiperiso_guid guid = HIPERISO_GUID;
if (memcmp(&vlnk->guid, &guid, sizeof(guid))) if (memcmp(&hlnk->guid, &guid, sizeof(guid)))
{ {
return 0; return 0;
} }
readcrc = vlnk->crc32; readcrc = hlnk->crc32;
vlnk->crc32 = 0; hlnk->crc32 = 0;
calccrc = hiperiso_getcrc32c(0, vlnk, sizeof(hiperiso_vlnk)); calccrc = hiperiso_getcrc32c(0, hlnk, sizeof(hiperiso_hlnk));
if (readcrc != calccrc) if (readcrc != calccrc)
{ {
+9 -9
View File
@@ -1,10 +1,10 @@
#ifndef __VLNK_H__ #ifndef __HLNK_H__
#define __VLNK_H__ #define __HLNK_H__
#define VLNK_FILE_LEN 32768 #define HLNK_FILE_LEN 32768
#define VLNK_NAME_MAX 384 #define HLNK_NAME_MAX 384
#define HIPERISO_GUID { 0x77772020, 0x2e77, 0x6576, { 0x6e, 0x74, 0x6f, 0x79, 0x2e, 0x6e, 0x65, 0x74 }} #define HIPERISO_GUID { 0x77772020, 0x2e77, 0x6576, { 0x6e, 0x74, 0x6f, 0x79, 0x2e, 0x6e, 0x65, 0x74 }}
@@ -18,20 +18,20 @@ typedef struct hiperiso_guid
uint8_t data4[8]; uint8_t data4[8];
}hiperiso_guid; }hiperiso_guid;
typedef struct hiperiso_vlnk typedef struct hiperiso_hlnk
{ {
hiperiso_guid guid; // HIPERISO_GUID hiperiso_guid guid; // HIPERISO_GUID
uint32_t crc32; // crc32 uint32_t crc32; // crc32
uint32_t disk_signature; uint32_t disk_signature;
uint64_t part_offset; // in bytes uint64_t part_offset; // in bytes
char filepath[VLNK_NAME_MAX]; char filepath[HLNK_NAME_MAX];
uint8_t reserverd[96]; uint8_t reserverd[96];
}hiperiso_vlnk; }hiperiso_hlnk;
#pragma pack() #pragma pack()
uint32_t hiperiso_getcrc32c (uint32_t crc, const void *buf, int size); uint32_t hiperiso_getcrc32c (uint32_t crc, const void *buf, int size);
int hiperiso_create_vlnk(uint32_t disksig, uint64_t partoffset, const char *path, hiperiso_vlnk *vlnk); int hiperiso_create_hlnk(uint32_t disksig, uint64_t partoffset, const char *path, hiperiso_hlnk *hlnk);
int CheckVlnkData(hiperiso_vlnk *vlnk); int CheckHlnkData(hiperiso_hlnk *hlnk);
int IsSupportedImgSuffix(char *suffix); int IsSupportedImgSuffix(char *suffix);
#endif #endif
+34 -34
View File
@@ -10,7 +10,7 @@
#include <dirent.h> #include <dirent.h>
#include <unistd.h> #include <unistd.h>
#include "vlnk.h" #include "hlnk.h"
#ifndef PATH_MAX #ifndef PATH_MAX
#define PATH_MAX 4096 #define PATH_MAX 4096
@@ -21,7 +21,7 @@
static int verbose = 0; static int verbose = 0;
#define debug(fmt, args...) if(verbose) printf(fmt, ##args) #define debug(fmt, args...) if(verbose) printf(fmt, ##args)
static uint8_t g_vlnk_buf[VLNK_FILE_LEN]; static uint8_t g_hlnk_buf[HLNK_FILE_LEN];
static int64_t get_file_size(char *file) static int64_t get_file_size(char *file)
{ {
@@ -173,13 +173,13 @@ static uint64_t get_part_offset(char *partname)
return offset; return offset;
} }
static int create_vlnk(char *infile, char *diskname, uint64_t partoff, char *outfile) static int create_hlnk(char *infile, char *diskname, uint64_t partoff, char *outfile)
{ {
FILE *fp; FILE *fp;
int len; int len;
uint32_t sig = 0; uint32_t sig = 0;
debug("create vlnk\n"); debug("create hlnk\n");
if (infile[0] == 0 || outfile[0] == 0 || diskname[0] == 0 || partoff == 0) if (infile[0] == 0 || outfile[0] == 0 || diskname[0] == 0 || partoff == 0)
{ {
@@ -188,9 +188,9 @@ static int create_vlnk(char *infile, char *diskname, uint64_t partoff, char *out
} }
len = (int)strlen(infile); len = (int)strlen(infile);
if (len >= VLNK_NAME_MAX) if (len >= HLNK_NAME_MAX)
{ {
printf("File name length %d is too long for vlnk!\n", len); printf("File name length %d is too long for hlnk!\n", len);
return 1; return 1;
} }
@@ -207,9 +207,9 @@ static int create_vlnk(char *infile, char *diskname, uint64_t partoff, char *out
return 1; return 1;
} }
memset(g_vlnk_buf, 0, sizeof(g_vlnk_buf)); memset(g_hlnk_buf, 0, sizeof(g_hlnk_buf));
hiperiso_create_vlnk(sig, partoff, infile, (hiperiso_vlnk *)g_vlnk_buf); hiperiso_create_hlnk(sig, partoff, infile, (hiperiso_hlnk *)g_hlnk_buf);
fwrite(g_vlnk_buf, 1, VLNK_FILE_LEN, fp); fwrite(g_hlnk_buf, 1, HLNK_FILE_LEN, fp);
fclose(fp); fclose(fp);
return 0; return 0;
@@ -252,7 +252,7 @@ static int get_mount_point(char *partname, char *mntpoint)
return rc; return rc;
} }
static int parse_vlnk(char *infile) static int parse_hlnk(char *infile)
{ {
int i; int i;
int fd; int fd;
@@ -262,9 +262,9 @@ static int parse_vlnk(char *infile)
char partname[128] = {0}; char partname[128] = {0};
char partpath[256] = {0}; char partpath[256] = {0};
char mntpoint[PATH_MAX]; char mntpoint[PATH_MAX];
hiperiso_vlnk vlnk; hiperiso_hlnk hlnk;
debug("parse vlnk\n"); debug("parse hlnk\n");
if (infile[0] == 0) if (infile[0] == 0)
{ {
@@ -279,18 +279,18 @@ static int parse_vlnk(char *infile)
return 1; return 1;
} }
memset(&vlnk, 0, sizeof(vlnk)); memset(&hlnk, 0, sizeof(hlnk));
read(fd, &vlnk, sizeof(vlnk)); read(fd, &hlnk, sizeof(hlnk));
close(fd); close(fd);
debug("disk_signature:%08X\n", vlnk.disk_signature); debug("disk_signature:%08X\n", hlnk.disk_signature);
debug("file path:<%s>\n", vlnk.filepath); debug("file path:<%s>\n", hlnk.filepath);
debug("part offset: %llu\n", (unsigned long long)vlnk.part_offset); debug("part offset: %llu\n", (unsigned long long)hlnk.part_offset);
cnt = find_disk_by_sig((uint8_t *)&(vlnk.disk_signature), diskname); cnt = find_disk_by_sig((uint8_t *)&(hlnk.disk_signature), diskname);
if (cnt != 1) if (cnt != 1)
{ {
printf("Disk in vlnk not found!\n"); printf("Disk in hlnk not found!\n");
return 1; return 1;
} }
@@ -312,7 +312,7 @@ static int parse_vlnk(char *infile)
snprintf(partname, sizeof(partname) - 1, "%s%d", diskname, i); snprintf(partname, sizeof(partname) - 1, "%s%d", diskname, i);
} }
if (get_part_offset(partname) == vlnk.part_offset) if (get_part_offset(partname) == hlnk.part_offset)
{ {
debug("Find correct partition </dev/%s>\n", partname); debug("Find correct partition </dev/%s>\n", partname);
break; break;
@@ -321,7 +321,7 @@ static int parse_vlnk(char *infile)
if (i > 128) if (i > 128)
{ {
printf("Partition in vlnk not found!"); printf("Partition in hlnk not found!");
return 1; return 1;
} }
@@ -333,8 +333,8 @@ static int parse_vlnk(char *infile)
} }
debug("moutpoint of %s is <%s>\n", partpath, mntpoint); debug("moutpoint of %s is <%s>\n", partpath, mntpoint);
strcat(mntpoint, vlnk.filepath); strcat(mntpoint, hlnk.filepath);
printf("Vlnk Point: %s\n", mntpoint); printf("Hlnk Point: %s\n", mntpoint);
if (access(mntpoint, F_OK) >= 0) if (access(mntpoint, F_OK) >= 0)
{ {
printf("File Exist: YES\n"); printf("File Exist: YES\n");
@@ -347,13 +347,13 @@ static int parse_vlnk(char *infile)
return 0; return 0;
} }
static int check_vlnk(char *infile) static int check_hlnk(char *infile)
{ {
int fd; int fd;
int64_t size; int64_t size;
hiperiso_vlnk vlnk; hiperiso_hlnk hlnk;
debug("check vlnk\n"); debug("check hlnk\n");
if (infile[0] == 0) if (infile[0] == 0)
{ {
@@ -362,9 +362,9 @@ static int check_vlnk(char *infile)
} }
size = get_file_size(infile); size = get_file_size(infile);
if (size != VLNK_FILE_LEN) if (size != HLNK_FILE_LEN)
{ {
debug("file size %lld is not a vlnk file size\n", (long long)size); debug("file size %lld is not a hlnk file size\n", (long long)size);
return 1; return 1;
} }
@@ -375,11 +375,11 @@ static int check_vlnk(char *infile)
return 1; return 1;
} }
memset(&vlnk, 0, sizeof(vlnk)); memset(&hlnk, 0, sizeof(hlnk));
read(fd, &vlnk, sizeof(vlnk)); read(fd, &hlnk, sizeof(hlnk));
close(fd); close(fd);
if (CheckVlnkData(&vlnk)) if (CheckHlnkData(&hlnk))
{ {
return 0; return 0;
} }
@@ -438,15 +438,15 @@ int main(int argc, char **argv)
if (cmd == 1) if (cmd == 1)
{ {
return create_vlnk(infile, diskname, partoff, outfile); return create_hlnk(infile, diskname, partoff, outfile);
} }
else if (cmd == 2) else if (cmd == 2)
{ {
return parse_vlnk(infile); return parse_hlnk(infile);
} }
else if (cmd == 3) else if (cmd == 3)
{ {
return check_vlnk(infile); return check_hlnk(infile);
} }
else else
{ {