Add SDcard password confirm popup
[platform/core/security/ode.git] / server / kernel-keyring.cpp
1 /*
2  *  Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  *  Licensed under the Apache License, Version 2.0 (the "License");
5  *  you may not use this file except in compliance with the License.
6  *  You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  *  Unless required by applicable law or agreed to in writing, software
11  *  distributed under the License is distributed on an "AS IS" BASIS,
12  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  *  See the License for the specific language governing permissions and
14  *  limitations under the License
15  */
16
17 #include <unistd.h>
18 #include <sys/mount.h>
19 #include <sys/syscall.h>
20 #include <linux/limits.h>
21
22 #include "kernel-keyring.h"
23
24 #ifndef KEYCTL_SEARCH
25 #define KEYCTL_SEARCH   10
26 #endif
27
28 int32_t KernelKeyRing::add(const std::string& type, const std::string& description, const void* payload, size_t plen, int32_t ringid)
29 {
30         return ::syscall(__NR_add_key, type.c_str(), description.c_str(), payload, plen, ringid);
31 }
32
33 long KernelKeyRing::search(int32_t ringid, const std::string& type, const std::string& description, int32_t destringid)
34 {
35         return ::syscall(__NR_keyctl, KEYCTL_SEARCH, ringid, type.c_str(), description.c_str(), destringid);
36 }
37
38 long KernelKeyRing::link(int32_t keyid, int32_t ringid)
39 {
40         return ::syscall(__NR_keyctl, KEYCTL_LINK, keyid, ringid);
41 }
42
43 long KernelKeyRing::unlink(int32_t keyid, int32_t ringid)
44 {
45         return ::syscall(__NR_keyctl, KEYCTL_UNLINK, keyid, ringid);
46 }