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 file = filp_open(filename, O_CREAT | O_WRONLY | O_TRUNC, 0644);
30 struct super_block *sb = file->f_path.dentry->d_sb;
33 if (!strncmp(cmd, "fota", 4))
35 else if (!strncmp(cmd, "recovery", 8))
37 else if (!strncmp(cmd, "download", 8))
44 vfs_write(file, cmd, strlen(cmd), &pos);
46 down_read(&sb->s_umount);
48 up_read(&sb->s_umount);
52 pr_err("Reboot parameter passing is failed.\n"
53 "Inform file path should be described correctly in config.\n");
59 static struct notifier_block nb_inform_reboot_block = {
60 .notifier_call = inform_reboot_notifier,
64 static int __init inform_reboot_init(void)
66 /* to support reboot parameter passing */
67 register_reboot_notifier(&nb_inform_reboot_block);
71 subsys_initcall(inform_reboot_init);