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);
36 struct super_block *sb = file->f_path.dentry->d_sb;
39 if (!strncmp(cmd, "fota", 4))
41 else if (!strncmp(cmd, "recovery", 8))
48 vfs_write(file, cmd, strlen(cmd), &pos);
50 down_read(&sb->s_umount);
52 up_read(&sb->s_umount);
58 pr_err("Reboot parameter passing is failed.\n"
59 "Inform file path should be described correctly in config.\n");
67 static struct notifier_block nb_inform_reboot_block = {
68 .notifier_call = inform_reboot_notifier,
72 static int __init inform_reboot_init(void)
74 /* to support reboot parameter passing */
75 register_reboot_notifier(&nb_inform_reboot_block);
79 subsys_initcall(inform_reboot_init);