1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
4 * Lustre curproc API implementation for Linux kernel
6 * Copyright (C) 2004 Cluster File Systems, Inc.
7 * Author: Nikita Danilov <nikita@clusterfs.com>
9 * This file is part of Lustre, http://www.lustre.org.
11 * Lustre is free software; you can redistribute it and/or modify it under the
12 * terms of version 2 of the GNU General Public License as published by the
13 * Free Software Foundation. Lustre is distributed in the hope that it will be
14 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
16 * Public License for more details. You should have received a copy of the GNU
17 * General Public License along with Lustre; if not, write to the Free
18 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 #include <linux/sched.h>
23 #define DEBUG_SUBSYSTEM S_LNET
25 #include <libcfs/libcfs.h>
28 * Implementation of cfs_curproc API (see portals/include/libcfs/curproc.h)
32 uid_t cfs_curproc_uid(void)
37 gid_t cfs_curproc_gid(void)
42 uid_t cfs_curproc_fsuid(void)
44 return current->fsuid;
47 gid_t cfs_curproc_fsgid(void)
49 return current->fsgid;
52 pid_t cfs_curproc_pid(void)
57 int cfs_curproc_groups_nr(void)
61 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,4)
63 nr = current->group_info->ngroups;
66 nr = current->ngroups;
71 void cfs_curproc_groups_dump(gid_t *array, int size)
73 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,4)
75 size = min_t(int, size, current->group_info->ngroups);
76 memcpy(array, current->group_info->blocks[0], size * sizeof(__u32));
79 LASSERT(size <= NGROUPS);
80 size = min_t(int, size, current->ngroups);
81 memcpy(array, current->groups, size * sizeof(__u32));
86 int cfs_curproc_is_in_groups(gid_t gid)
88 return in_group_p(gid);
91 mode_t cfs_curproc_umask(void)
93 return current->fs->umask;
96 char *cfs_curproc_comm(void)
101 cfs_kernel_cap_t cfs_curproc_cap_get(void)
103 return current->cap_effective;
106 void cfs_curproc_cap_set(cfs_kernel_cap_t cap)
108 current->cap_effective = cap;
111 EXPORT_SYMBOL(cfs_curproc_uid);
112 EXPORT_SYMBOL(cfs_curproc_pid);
113 EXPORT_SYMBOL(cfs_curproc_gid);
114 EXPORT_SYMBOL(cfs_curproc_fsuid);
115 EXPORT_SYMBOL(cfs_curproc_fsgid);
116 EXPORT_SYMBOL(cfs_curproc_umask);
117 EXPORT_SYMBOL(cfs_curproc_comm);
118 EXPORT_SYMBOL(cfs_curproc_groups_nr);
119 EXPORT_SYMBOL(cfs_curproc_groups_dump);
120 EXPORT_SYMBOL(cfs_curproc_is_in_groups);
121 EXPORT_SYMBOL(cfs_curproc_cap_get);
122 EXPORT_SYMBOL(cfs_curproc_cap_set);
126 * c-indentation-style: "K&R"