Add get_reboot_mode() for silent reboot 62/230162/10 accepted/tizen_6.0_unified_hotfix tizen_6.0_hotfix accepted/tizen/6.0/unified/20201030.123922 accepted/tizen/6.0/unified/hotfix/20201103.051144 accepted/tizen/unified/20200422.123204 submit/tizen/20200421.052338 submit/tizen_6.0/20201029.205101 submit/tizen_6.0_hotfix/20201102.192501 submit/tizen_6.0_hotfix/20201103.114801 tizen_6.0.m2_release
authorYoungjae Cho <y0.cho@samsung.com>
Wed, 8 Apr 2020 08:00:51 +0000 (17:00 +0900)
committerYoungjae Cho <y0.cho@samsung.com>
Tue, 21 Apr 2020 05:03:28 +0000 (14:03 +0900)
Change-Id: I3451e383e7300935cfae01601d98afe4f9ad8dd5
Signed-off-by: Youngjae Cho <y0.cho@samsung.com>
CMakeLists.txt
packaging/system-plugin.spec
src/libsysplugin/CMakeLists.txt [new file with mode: 0644]
src/libsysplugin/reboot_mode.c [new file with mode: 0644]

index e339888..a043ab3 100644 (file)
@@ -1,3 +1,4 @@
 CMAKE_MINIMUM_REQUIRED(VERSION 3.9.4)
 
 ADD_SUBDIRECTORY(src/session-bind)
+ADD_SUBDIRECTORY(src/libsysplugin)
index 9b8757e..5402d87 100644 (file)
@@ -99,6 +99,12 @@ Requires: %{name} = %{version}-%{release}
 %description feature-session-bind
 This package provides a mount utils for user sessions.
 
+%package feature-bootmode
+Summary:  Support bootmode state by reading /proc/cmdline
+
+%description feature-bootmode
+This package provides function that gets bootmode
+
 %package config-env-headless
 Summary:  System configuration files for headless images
 Requires: %{name} = %{version}-%{release}
@@ -340,6 +346,11 @@ rm -f %{_sbindir}/e4crypt
 %{_userunitdir}/session-bind.service
 %{_userunitdir}/basic.target.wants/session-bind.service
 
+%files feature-bootmode
+%manifest %{name}.manifest
+%license LICENSE.Apache-2.0
+/usr/lib/deviced/bootmode.so
+
 %post feature-session-bind
 echo ""
 echo "------------------------------------------------------------------------"
diff --git a/src/libsysplugin/CMakeLists.txt b/src/libsysplugin/CMakeLists.txt
new file mode 100644 (file)
index 0000000..dbac7d4
--- /dev/null
@@ -0,0 +1,10 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT(libsysplugin C)
+
+SET(LIBSYSPLUGIN_SRCS
+       reboot_mode.c)
+
+ADD_LIBRARY(${PROJECT_NAME} SHARED ${LIBSYSPLUGIN_SRCS})
+SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES PREFIX "")
+SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES OUTPUT_NAME bootmode)
+INSTALL(TARGETS ${PROJECT_NAME} DESTINATION /usr/lib/deviced COMPONENT RuntimeLibraries)
diff --git a/src/libsysplugin/reboot_mode.c b/src/libsysplugin/reboot_mode.c
new file mode 100644 (file)
index 0000000..4fe4b98
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#define KEY_SILENT_REBOOT      "silent_reboot="
+
+int get_reboot_mode(void)
+{
+       FILE *fp;
+       char *line = NULL;
+       char *key, *val;
+       size_t n;
+       int ret = 0;
+
+       fp = fopen("/proc/cmdline", "r");
+       if (!fp)
+               return ret;
+
+       if (getline(&line, &n, fp)) {
+               key = strstr(line, KEY_SILENT_REBOOT);
+               if (key) {
+                       val = key + strlen(KEY_SILENT_REBOOT);
+                       if (*val == '1')
+                               ret = 1;
+               }
+       }
+
+       fclose(fp);
+       free(line);
+
+       return ret;
+}