Commit 96bc93f1 authored by Mick Michalski's avatar Mick Michalski
Browse files

Bug fixes in swupdate-* files

parent 91017946
......@@ -23,8 +23,8 @@ int main(void) {
int doUpdate = 0;
/* Set the boot partition to the opposite of the current partition */
if(buffer[3] == '0') doUpdate += setBuffer(buffer, 1, '1');
else doUpdate += setBuffer(buffer, 1, '0');
if(buffer[3] == '1') doUpdate += setBuffer(buffer, 1, '0');
else doUpdate += setBuffer(buffer, 1, '1');
if(doUpdate){
/* Create a temp file */
......
......@@ -23,8 +23,8 @@ int main(void) {
int doUpdate = 0;
/* Set the boot partition to the opposite of the current partition */
if(buffer[2] == '0') doUpdate += setBuffer(buffer, 0, '1');
else doUpdate += setBuffer(buffer, 0, '0');
if(buffer[2] == '1') doUpdate += setBuffer(buffer, 0, '0');
else doUpdate += setBuffer(buffer, 0, '1');
if(doUpdate){
/* Create a temp file */
......
......@@ -14,6 +14,8 @@ int main(void) {
char *devKMain = getenv("DEVICE_KERNEL_MAIN");
char *devKAlt = getenv("DEVICE_KERNEL_ALT");
printf("----- start swupdate-prepost-boot -----\n");
if(!devSettings) {
printf("No settings found");
return 1;
......@@ -37,11 +39,19 @@ int main(void) {
buffer[3] = buffer[1];
doUpdate = 1;
}
int c;
for(c=0;c<4;c++) if((buffer[c] != '0') && (buffer[c] != '1')) buffer[c] = '0';
buffer[4]=0;
printf("Settings: %s\n", buffer);
char cmd[128];
if(doUpdate){
printf("Updating device settings with new boot partitions\n");
int c;
for(c=0;c<4;c++) if((buffer[c] != '0') && (buffer[c] != '1')) buffer[c] = '0';
/* Create a temp file */
char tempFile[64];
......@@ -51,6 +61,7 @@ int main(void) {
/* Write temp file to mtd0, then delete temp file */
snprintf(cmd, 127, "flashcp %s %s", tempFile, devSettings);
printf("Executing: %s\n", cmd);
system(cmd);
unlink(tempFile); /* automatically close and delete when done */
......@@ -58,21 +69,27 @@ int main(void) {
printf("Device settings unchanged\n");
}
if(buffer[3] == '0'){ /* The current filesystem */
snprintf(cmd, 127, "ln -sf %s /dev/dev-fs", devFsAlt);
if(buffer[3] == '1'){ /* The current filesystem */
snprintf(cmd, 127, "ln -sf %s /dev/dev-fs", devFsMain);
printf("Executing: %s\n", cmd);
system(cmd); /* Create a new link to alt fs partition */
} else {
snprintf(cmd, 127, "ln -sf %s /dev/dev-fs", devFsMain);
snprintf(cmd, 127, "ln -sf %s /dev/dev-fs", devFsAlt);
printf("Executing: %s\n", cmd);
system(cmd); /* Create a new link to main fs partition */
}
if(buffer[2] == '0'){ /* The current filesystem */
snprintf(cmd, 127, "ln -sf %s /dev/dev-k", devKAlt);
if(buffer[2] == '1'){ /* The current kernel */
snprintf(cmd, 127, "ln -sf %s /dev/dev-k", devKMain);
printf("Executing: %s\n", cmd);
system(cmd); /* Create a new link to alt kernel partition */
} else {
snprintf(cmd, 127, "ln -sf %s /dev/dev-k", devKMain);
snprintf(cmd, 127, "ln -sf %s /dev/dev-k", devKAlt);
printf("Executing: %s\n", cmd);
system(cmd); /* Create a new link to main kernel partition */
}
printf("----- end swupdate-prepost-boot -----\n");
return 0;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment