/usr/bin/avos:AOS parse unit()

From ArchosDocs

Jump to: navigation, search

Description

Reads the UNIT block and make sure the Product Name returned by SysInfo_GetProductName() matches the one claimed in the UNIT block. Optionally, checks that the product key returned by SYSINFO_GetPK() matches the one claimed in the UNIT block.

References To

The Code

int AOS_parse_unit(int fd)
{
char pk[14] // -0x236
char buf[40]; // -0x228
int read; // -0x18
int pos; // -0x14
char *ptr; // -0x10
 
read = _aos_read(fd, &buf, 40);
if(read != 40)
return 211;
 
if(*(uint32_t *)&buf[0] != 0x554E4954 /* UNIT */)
return 210;
 
ptr = &buf[8];
printf("product [%s] marked in file [%s]\r\n",
SysInfo_GetProductName(), ptr);
 
if(strcmp(ptr, SysInfo_GetProductName()) != 0)
return 212;
 
strncpy(&pk, SYSINFO_GetPK(), 14);
if((char)ptr[16] != 0) {
if(strncmp(&pk, ptr[16], 14) != 0)
return 213;
}
 
printf("_aos_seek 1\r\n");
 
_aos_seek(fd, SEEK_SET, (pos + *(uint32_t *)&buf[4]));
 
printf("_aos_seek 2\r\n");
 
return 0;
}
Personal tools