2 * Tizen reboot parameter passing notifier
4 * Written by: Junghoon Kim <jhoon20.kim@samsung.com>
6 * Copyright (C) 2017 Samsung Electronics Co., Ltd.
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
13 #include <linux/notifier.h>
14 #include <linux/reboot.h>
15 #include <linux/syscalls.h>
16 #include <linux/file.h>
17 #include <linux/fcntl.h>
18 #include <linux/uaccess.h>
20 static int inform_reboot_notifier(struct notifier_block *nb,
21 unsigned long val, void *buf)
24 char *filename = CONFIG_TIZEN_INFORM_PATH;
28 mm_segment_t old_fs = get_fs();
32 fd = sys_open(filename, O_CREAT | O_WRONLY | O_TRUNC, 0644);
37 if (!strncmp(cmd, "fota", 4))
39 else if (!strncmp(cmd, "recovery", 8))
46 vfs_write(file, cmd, strlen(cmd), &pos);
51 /* to guarantee all file data and metadata sync */
54 pr_err("Reboot parameter passing is failed.\n"
55 "Inform file path should be described correctly in config.\n");
63 static struct notifier_block nb_inform_reboot_block = {
64 .notifier_call = inform_reboot_notifier
67 static int __init inform_reboot_init(void)
69 /* to support reboot parameter passing */
70 register_reboot_notifier(&nb_inform_reboot_block);
74 subsys_initcall(inform_reboot_init);