summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorroot <root@avtech.domain.avtechpulse.com>1970-01-01 09:01:03 +0900
committerroot <root@avtech.domain.avtechpulse.com>1970-01-01 09:01:03 +0900
commit9e02a7ee2335ba91e5bd0cbb79ab8a5a58f57bde (patch)
treec41616f855d66609896236dfefb63defcff53f33
parent5d5d9873f31ae857e0cd713f529f12407a6936a1 (diff)
file root normally read-only now, for safe power-off. Major OS changes too.INSTRUMENT_6_2_00
-rw-r--r--device-functions.c19
-rw-r--r--flash.c24
-rw-r--r--flash.h2
-rw-r--r--instr-daemon.c20
-rw-r--r--version.h2
5 files changed, 40 insertions, 27 deletions
diff --git a/device-functions.c b/device-functions.c
index ac4a9b4..061f759 100644
--- a/device-functions.c
+++ b/device-functions.c
@@ -4492,25 +4492,32 @@ int change_password(gchar *old_password, gchar *new_password)
struct lu_error *error = NULL;
struct lu_ent *ent;
+ int result;
+ result = OK;
+
+ remount_root_as_writeable ();
+
ctx = lu_start(user, lu_user, NULL, NULL, lu_prompt_console_quiet, NULL, &error);
if (ctx == NULL ) {
- return password_change_error;
+ result = password_change_error;
}
ent = lu_ent_new();
- if (lu_user_lookup_name(ctx, user, ent, &error) == FALSE) {
- return password_change_error; // user doesn't exist
+ if (!result && (lu_user_lookup_name(ctx, user, ent, &error) == FALSE)) {
+ result = password_change_error; // user doesn't exist
}
- if (lu_user_setpass(ctx, ent, new_password, FALSE, &error) == FALSE) {
- return password_change_error;
+ if (!result && (lu_user_setpass(ctx, ent, new_password, FALSE, &error) == FALSE)) {
+ result = password_change_error;
}
lu_end(ctx);
- return OK;
+ remount_root_as_not_writeable ();
+
+ return result;
} else {
return password_change_error;
}
diff --git a/flash.c b/flash.c
index 9aaef45..d371c39 100644
--- a/flash.c
+++ b/flash.c
@@ -307,6 +307,19 @@ hdrlengthok:
}
+
+void remount_root_as_writeable ()
+{
+ system("/usr/bin/mount -o remount,rw /dev/mmcblk03 /");
+}
+
+
+void remount_root_as_not_writeable ()
+{
+ system("/usr/bin/mount -o remount,ro /dev/mmcblk03 /");
+}
+
+
static int readUserBlock(FlashStruct *mem)
{
@@ -329,8 +342,12 @@ static int readUserBlock(FlashStruct *mem)
// if the backup was good overwrite the main file
if (!globals.Sys.shutdown_started) {
globals.Sys.flash_write_in_progress = TRUE;
+ remount_root_as_writeable ();
+
persistence_copyfile(BACKUPFILE, MAINFILE);
+
globals.Sys.flash_write_in_progress = FALSE;
+ remount_root_as_not_writeable ();
}
return sizeof(*mem);
}
@@ -359,11 +376,17 @@ void writeUserBlockNow(FlashStruct *mem, int addr, int numbytes)
if (!globals.Sys.shutdown_started) {
globals.Sys.flash_write_in_progress = TRUE;
+ remount_root_as_writeable ();
+
bool backup_ok = persistence_copyfile(MAINFILE, BACKUPFILE);
+
globals.Sys.flash_write_in_progress = FALSE;
+ remount_root_as_not_writeable ();
if (backup_ok && !globals.Sys.shutdown_started) {
+
globals.Sys.flash_write_in_progress = TRUE;
+ remount_root_as_writeable ();
if (!persistence_freeze(MAINFILE, mem, addr, numbytes, sizeof(*mem), 0)) {
if (errno != PERSIST_ERR_COULDNTWRITE) {
@@ -373,6 +396,7 @@ void writeUserBlockNow(FlashStruct *mem, int addr, int numbytes)
}
}
globals.Sys.flash_write_in_progress = FALSE;
+ remount_root_as_not_writeable ();
} else {
printf("Could not backup current file. **Write did not happen!!!**\n");
}
diff --git a/flash.h b/flash.h
index 2432c07..3627275 100644
--- a/flash.h
+++ b/flash.h
@@ -8,6 +8,8 @@ void initFlash(FlashStruct *mem, gboolean reset_to_defaults, int starting_locati
void writeUserBlock(FlashStruct *mem, int addr, int numbytes);
void fixFlash(FlashStruct *mem);
void stopFlashWriterThread();
+void remount_root_as_writeable();
+void remount_root_as_not_writeable();
#endif
diff --git a/instr-daemon.c b/instr-daemon.c
index 9547df5..f155fab 100644
--- a/instr-daemon.c
+++ b/instr-daemon.c
@@ -378,26 +378,6 @@ static gboolean periodic_poll (void)
g_usleep(1000);
}
- LCD_clear();
- // 0123456789012345678901234567890123456789
- LCD_write(0,0,"PWR: Wait 10s. If still frozen, turn");
- LCD_write(1,0,"off 1min & retry.");
-
- // use plain old open to avoid any buffering etc
- int enablefd = open("/proc/sys/kernel/sysrq", O_SYNC | O_RDWR);
- int trgfd = open("/proc/sysrq-trigger", O_SYNC | O_RDWR);
-
- // enable sysrq
- write(enablefd, "1\n", 2);
- close(enablefd);
-
- // sync disks
- write(trgfd, "s\n", 2);
-
- // remount ro
- write(trgfd, "u\n", 2);
- close(trgfd);
-
// poweroff
system ("/usr/bin/systemctl poweroff -f");
diff --git a/version.h b/version.h
index 2dc64ce..84ce3fc 100644
--- a/version.h
+++ b/version.h
@@ -1,2 +1,2 @@
-#define FW_VERSION "6.0.28"
+#define FW_VERSION "6.2.00"
#define SCPI_version "1996.0"