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 = ksys_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))
43 else if (!strncmp(cmd, "download", 8))
50 vfs_write(file, cmd, strlen(cmd), &pos);
52 down_read(&sb->s_umount);
54 up_read(&sb->s_umount);
60 pr_err("Reboot parameter passing is failed.\n"
61 "Inform file path should be described correctly in config.\n");
69 static struct notifier_block nb_inform_reboot_block = {
70 .notifier_call = inform_reboot_notifier,
74 static int __init inform_reboot_init(void)
76 /* to support reboot parameter passing */
77 register_reboot_notifier(&nb_inform_reboot_block);
81 subsys_initcall(inform_reboot_init);