1 /*
2 * GPL HEADER START
3 *
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 only,
8 * as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License version 2 for more details (a copy is included
14 * in the LICENSE file that accompanied this code).
15 *
16 * You should have received a copy of the GNU General Public License
17 * version 2 along with this program; If not, see
18 * http://www.gnu.org/licenses/gpl-2.0.html
19 *
20 * GPL HEADER END
21 */
22 /*
23 * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
24 * Use is subject to license terms.
25 *
26 * Copyright (c) 2011, 2012, Intel Corporation.
27 */
28 /*
29 * This file is part of Lustre, http://www.lustre.org/
30 * Lustre is a trademark of Sun Microsystems, Inc.
31 */
32
33 #define DEBUG_SUBSYSTEM S_LNET
34 #include <linux/module.h>
35 #include <linux/kernel.h>
36 #include <linux/fs_struct.h>
37 #include <linux/sched.h>
38
39 #include "../../../include/linux/libcfs/libcfs.h"
40
41 #if defined(CONFIG_KGDB)
42 #include <linux/kgdb.h>
43 #endif
44
45 sigset_t
cfs_block_allsigs(void)46 cfs_block_allsigs(void)
47 {
48 unsigned long flags;
49 sigset_t old;
50
51 spin_lock_irqsave(¤t->sighand->siglock, flags);
52 old = current->blocked;
53 sigfillset(¤t->blocked);
54 recalc_sigpending();
55 spin_unlock_irqrestore(¤t->sighand->siglock, flags);
56
57 return old;
58 }
59 EXPORT_SYMBOL(cfs_block_allsigs);
60
cfs_block_sigs(unsigned long sigs)61 sigset_t cfs_block_sigs(unsigned long sigs)
62 {
63 unsigned long flags;
64 sigset_t old;
65
66 spin_lock_irqsave(¤t->sighand->siglock, flags);
67 old = current->blocked;
68 sigaddsetmask(¤t->blocked, sigs);
69 recalc_sigpending();
70 spin_unlock_irqrestore(¤t->sighand->siglock, flags);
71 return old;
72 }
73 EXPORT_SYMBOL(cfs_block_sigs);
74
75 /* Block all signals except for the @sigs */
cfs_block_sigsinv(unsigned long sigs)76 sigset_t cfs_block_sigsinv(unsigned long sigs)
77 {
78 unsigned long flags;
79 sigset_t old;
80
81 spin_lock_irqsave(¤t->sighand->siglock, flags);
82 old = current->blocked;
83 sigaddsetmask(¤t->blocked, ~sigs);
84 recalc_sigpending();
85 spin_unlock_irqrestore(¤t->sighand->siglock, flags);
86
87 return old;
88 }
89 EXPORT_SYMBOL(cfs_block_sigsinv);
90
91 void
cfs_restore_sigs(sigset_t old)92 cfs_restore_sigs(sigset_t old)
93 {
94 unsigned long flags;
95
96 spin_lock_irqsave(¤t->sighand->siglock, flags);
97 current->blocked = old;
98 recalc_sigpending();
99 spin_unlock_irqrestore(¤t->sighand->siglock, flags);
100 }
101 EXPORT_SYMBOL(cfs_restore_sigs);
102
103 void
cfs_clear_sigpending(void)104 cfs_clear_sigpending(void)
105 {
106 unsigned long flags;
107
108 spin_lock_irqsave(¤t->sighand->siglock, flags);
109 clear_tsk_thread_flag(current, TIF_SIGPENDING);
110 spin_unlock_irqrestore(¤t->sighand->siglock, flags);
111 }
112 EXPORT_SYMBOL(cfs_clear_sigpending);
113