Motr  M0
kcookie.c
Go to the documentation of this file.
1 /* -*- C -*- */
2 /*
3  * Copyright (c) 2012-2020 Seagate Technology LLC and/or its Affiliates
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  * For any questions about this software or licensing,
18  * please email opensource@seagate.com or cortx-questions@seagate.com.
19  *
20  */
21 
22 
27 #include <linux/uaccess.h>
28 
29 #define try_read(addr, dummy) \
30 ({ \
31  long rc; \
32  mm_segment_t save_fs = get_fs(); \
33  \
34  set_fs(KERNEL_DS); \
35  pagefault_disable(); \
36  rc = __copy_from_user_inatomic(&(dummy), \
37  (__force typeof(dummy) __user *)(addr), \
38  sizeof(dummy)); \
39  pagefault_enable(); \
40  set_fs(save_fs); \
41  rc; \
42 })
43 
44 M0_INTERNAL bool m0_arch_addr_is_sane(const uint64_t * addr)
45 {
46  uint64_t dummy;
47 
48  return try_read(addr, dummy) == 0;
49 }
50 
51 M0_INTERNAL int m0_arch_cookie_global_init(void)
52 {
53  return 0;
54 }
55 
59 M0_INTERNAL void m0_arch_cookie_global_fini(void)
60 {
61 }
62 
65 /*
66  * Local variables:
67  * c-indentation-style: "K&R"
68  * c-basic-offset: 8
69  * tab-width: 8
70  * fill-column: 80
71  * scroll-step: 1
72  * End:
73  */
static struct m0_be_active_record_domain dummy
Definition: active_record.c:35
Definition: xcode.h:73