Home | History | Annotate | Download | only in jni
      1 /*
      2  * Copyright (C) 2013 The Android Open Source Project
      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 <jni.h>
     18 #include <sys/types.h>
     19 #include <unistd.h>
     20 #include <sys/xattr.h>
     21 #include <errno.h>
     22 
     23 static jboolean android_security_cts_KernelSettingsTest_supportsXattr(JNIEnv* env, jobject thiz)
     24 {
     25     int result = getxattr("/system/bin/toolbox", "security.capability", NULL, 0);
     26     return ((result >= 0) || (errno == ENODATA));
     27 }
     28 
     29 static JNINativeMethod gMethods[] = {
     30     {  "supportsXattr", "()Z",
     31             (void *) android_security_cts_KernelSettingsTest_supportsXattr },
     32 };
     33 
     34 int register_android_security_cts_KernelSettingsTest(JNIEnv* env)
     35 {
     36     jclass clazz = env->FindClass("android/security/cts/KernelSettingsTest");
     37     return env->RegisterNatives(clazz, gMethods,
     38             sizeof(gMethods) / sizeof(JNINativeMethod));
     39 }
     40