From c8572fa3d809c345fd202cf4a3c38b7ce93c9528 Mon Sep 17 00:00:00 2001 From: vanhofen Date: Sun, 29 Dec 2019 00:17:23 +0100 Subject: [PATCH] neutrino: use proc_put() to write to procfs Origin commit data ------------------ Commit: https://github.com/neutrino-images/ni-neutrino/commit/b4287625099fd07632d27df925d9e75215e97a7d Author: vanhofen Date: 2019-12-29 (Sun, 29 Dec 2019) Origin message was: ------------------ - neutrino: use proc_put() to write to procfs --- src/neutrino.cpp | 43 +++++-------------------------------------- 1 file changed, 5 insertions(+), 38 deletions(-) diff --git a/src/neutrino.cpp b/src/neutrino.cpp index 5812b6448..eef0a1548 100644 --- a/src/neutrino.cpp +++ b/src/neutrino.cpp @@ -124,6 +124,7 @@ #include #include #include +#include #include #include @@ -4439,8 +4440,6 @@ void CNeutrinoApp::ExitRun(int exit_code) #endif if (exit_code != CNeutrinoApp::EXIT_REBOOT) { - FILE *f; - if (timer_minutes) { /* prioritize proc filesystem */ @@ -4451,56 +4450,24 @@ void CNeutrinoApp::ExitRun(int exit_code) strftime(date, sizeof(date), "%c", lt); printf("wakeup time : %s (%ld)\n", date, timer_minutes * 60); - // FIXME: use proc_put() - - if (access("/proc/stb/fp/wakeup_time", F_OK) == 0) - { - f = fopen("/proc/stb/fp/wakeup_time","w"); - if (f) - { - fprintf(f, "%ld\n", timer_minutes * 60); - fclose(f); - } - else - perror("fopen /proc/stb/fp/wakeup_time"); - } + proc_put("/proc/stb/fp/wakeup_time", timer_minutes * 60); t = time(NULL); lt = localtime(&t); strftime(date, sizeof(date), "%c", lt); printf("current time: %s (%ld)\n", date, t); - if (access("/proc/stb/fp/rtc", F_OK) == 0) - { - f = fopen("/proc/stb/fp/rtc","w"); - if (f) - { - fprintf(f, "%ld\n", t); - fclose(f); - } - else - perror("fopen /proc/stb/fp/rtc"); - } + proc_put("/proc/stb/fp/rtc", t); struct tm *gt = gmtime(&t); int offset = (lt->tm_hour - gt->tm_hour) * 3600; printf("rtc_offset : %d\n", offset); - if (access("/proc/stb/fp/rtc_offset", F_OK) == 0) - { - f = fopen("/proc/stb/fp/rtc_offset","w"); - if (f) - { - fprintf(f, "%d\n", offset); - fclose(f); - } - else - perror("fopen /proc/stb/fp/rtc_offset"); - } + proc_put("/proc/stb/fp/rtc_offset", offset); } /* not platform specific */ - f = fopen("/tmp/.timer", "w"); + FILE *f = fopen("/tmp/.timer", "w"); if (f) { fprintf(f, "%ld\n", timer_minutes ? timer_minutes * 60 : 0);