1 // SPDX-License-Identifier: GPL-2.0
5 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 only,
9 * as published by the Free Software Foundation.
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License version 2 for more details (a copy is included
15 * in the LICENSE file that accompanied this code).
17 * You should have received a copy of the GNU General Public License
18 * version 2 along with this program; If not, see
19 * http://www.gnu.org/licenses/gpl-2.0.html
24 * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
25 * Use is subject to license terms.
27 * Copyright (c) 2011, 2012, Intel Corporation.
30 * This file is part of Lustre, http://www.lustre.org/
31 * Lustre is a trademark of Sun Microsystems, Inc.
34 #define DEBUG_SUBSYSTEM S_LNET
35 #include <linux/module.h>
36 #include <linux/kernel.h>
37 #include <linux/fs_struct.h>
38 #include <linux/sched/signal.h>
40 #include <linux/libcfs/libcfs.h>
42 #if defined(CONFIG_KGDB)
43 #include <linux/kgdb.h>
47 cfs_block_allsigs(void)
52 spin_lock_irqsave(¤t->sighand->siglock, flags);
53 old = current->blocked;
54 sigfillset(¤t->blocked);
56 spin_unlock_irqrestore(¤t->sighand->siglock, flags);
60 EXPORT_SYMBOL(cfs_block_allsigs);
62 sigset_t cfs_block_sigs(unsigned long sigs)
67 spin_lock_irqsave(¤t->sighand->siglock, flags);
68 old = current->blocked;
69 sigaddsetmask(¤t->blocked, sigs);
71 spin_unlock_irqrestore(¤t->sighand->siglock, flags);
74 EXPORT_SYMBOL(cfs_block_sigs);
76 /* Block all signals except for the @sigs */
77 sigset_t cfs_block_sigsinv(unsigned long sigs)
82 spin_lock_irqsave(¤t->sighand->siglock, flags);
83 old = current->blocked;
84 sigaddsetmask(¤t->blocked, ~sigs);
86 spin_unlock_irqrestore(¤t->sighand->siglock, flags);
90 EXPORT_SYMBOL(cfs_block_sigsinv);
93 cfs_restore_sigs(sigset_t old)
97 spin_lock_irqsave(¤t->sighand->siglock, flags);
98 current->blocked = old;
100 spin_unlock_irqrestore(¤t->sighand->siglock, flags);
102 EXPORT_SYMBOL(cfs_restore_sigs);
105 cfs_clear_sigpending(void)
109 spin_lock_irqsave(¤t->sighand->siglock, flags);
110 clear_tsk_thread_flag(current, TIF_SIGPENDING);
111 spin_unlock_irqrestore(¤t->sighand->siglock, flags);
113 EXPORT_SYMBOL(cfs_clear_sigpending);