linux/drivers/staging/lustre/lnet/libcfs/linux/linux-curproc.c
<<
>>
Prefs
   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, 2015, 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 * libcfs/libcfs/linux/linux-curproc.c
  33 *
  34 * Lustre curproc API implementation for Linux kernel
  35 *
  36 * Author: Nikita Danilov <nikita@clusterfs.com>
  37 */
  38
  39#include <linux/sched.h>
  40#include <linux/fs_struct.h>
  41
  42#include <linux/compat.h>
  43#include <linux/thread_info.h>
  44
  45#define DEBUG_SUBSYSTEM S_LNET
  46
  47#include "../../../include/linux/libcfs/libcfs.h"
  48
  49/*
  50 * Implementation of cfs_curproc API (see portals/include/libcfs/curproc.h)
  51 * for Linux kernel.
  52 */
  53
  54void cfs_cap_raise(cfs_cap_t cap)
  55{
  56        struct cred *cred;
  57
  58        cred = prepare_creds();
  59        if (cred) {
  60                cap_raise(cred->cap_effective, cap);
  61                commit_creds(cred);
  62        }
  63}
  64EXPORT_SYMBOL(cfs_cap_raise);
  65
  66void cfs_cap_lower(cfs_cap_t cap)
  67{
  68        struct cred *cred;
  69
  70        cred = prepare_creds();
  71        if (cred) {
  72                cap_lower(cred->cap_effective, cap);
  73                commit_creds(cred);
  74        }
  75}
  76EXPORT_SYMBOL(cfs_cap_lower);
  77
  78int cfs_cap_raised(cfs_cap_t cap)
  79{
  80        return cap_raised(current_cap(), cap);
  81}
  82EXPORT_SYMBOL(cfs_cap_raised);
  83
  84static void cfs_kernel_cap_pack(kernel_cap_t kcap, cfs_cap_t *cap)
  85{
  86        /* XXX lost high byte */
  87        *cap = kcap.cap[0];
  88}
  89
  90cfs_cap_t cfs_curproc_cap_pack(void)
  91{
  92        cfs_cap_t cap;
  93
  94        cfs_kernel_cap_pack(current_cap(), &cap);
  95        return cap;
  96}
  97EXPORT_SYMBOL(cfs_curproc_cap_pack);
  98
  99/*
 100 * Local variables:
 101 * c-indentation-style: "K&R"
 102 * c-basic-offset: 8
 103 * tab-width: 8
 104 * fill-column: 80
 105 * scroll-step: 1
 106 * End:
 107 */
 108