char name[64 - sizeof(unsigned long)];
};
+struct modversion_info2 {
+ /* Offset of the next modversion entry in relation to this one. */
+ uint32_t next;
+ uint32_t crc;
+ char name[0];
+};
+
typedef struct ko_param
{
return 1;
}
-static int vtoykmod_update_modcrc(char *oldmodver, int oldcnt, char *newmodver, int newcnt)
+static int vtoykmod_update_modcrc1(char *oldmodver, int oldcnt, char *newmodver, int newcnt)
{
int i, j;
struct modversion_info *pold, *pnew;
-
+
pold = (struct modversion_info *)oldmodver;
pnew = (struct modversion_info *)newmodver;
+ debug("module update modver format 1\n");
for (i = 0; i < oldcnt; i++)
{
for (j = 0; j < newcnt; j++)
return 0;
}
+
+static int vtoykmod_update_modcrc2(char *oldmodver, int oldlen, char *newmodver, int newlen)
+{
+ struct modversion_info2 *pold, *pnew, *pnewend;
+
+ pold = (struct modversion_info2 *)oldmodver;
+ pnew = (struct modversion_info2 *)newmodver;
+ pnewend = (struct modversion_info2 *)(newmodver + newlen);
+
+ debug("module update modver format 2\n");
+ /* here we think that there is only module_layout in oldmodver */
+
+ for (; pnew < pnewend && pnew->next; pnew = (struct modversion_info2 *)((char *)pnew + pnew->next))
+ {
+ if (strcmp(pnew->name, "module_layout") == 0)
+ {
+ debug("CRC 0x%08x --> 0x%08x %s\n", pold->crc, pnew->crc, pnew->name);
+ memset(pold, 0, oldlen);
+ pold->next = 0x18; /* 8 + module_layout align 8 */
+ pold->crc = pnew->crc;
+ strcpy(pold->name, pnew->name);
+ break;
+ }
+ }
+
+ return 0;
+}
+
+
+static int vtoykmod_update_modcrc(char *oldmodver, int oldlen, char *newmodver, int newlen)
+{
+ uint32_t uiCrc = 0;
+
+ memcpy(&uiCrc, newmodver + 4, 4);
+
+ if (uiCrc > 0)
+ {
+ return vtoykmod_update_modcrc2(oldmodver, oldlen, newmodver, newlen);
+ }
+ else
+ {
+ return vtoykmod_update_modcrc1(oldmodver, oldlen / 64, newmodver, newlen / 64);
+ }
+}
+
static int vtoykmod_update_vermagic(char *oldbuf, int oldsize, char *newbuf, int newsize, int *modver)
{
int i = 0;
if (rc == 0)
{
- vtoykmod_update_modcrc(oldbuf + oldoff, oldlen / 64, newbuf + newoff, newlen / 64);
+ vtoykmod_update_modcrc(oldbuf + oldoff, oldlen, newbuf + newoff, newlen);
}
}
else