X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=blobdiff_plain;f=libcfs%2Finclude%2Flibcfs%2Flinux%2Flinux-misc.h;h=06f58e2e7ddc53d2719dfeebb92a023c16f66a9a;hp=cb7c4cbfb52e7ac247f36d5e16a3793f23320ea4;hb=b9a32054600a8d63948cced361191aa6ae7ea8f2;hpb=b8bddf048483d3ed95201de06f2da0925c82cd54 diff --git a/libcfs/include/libcfs/linux/linux-misc.h b/libcfs/include/libcfs/linux/linux-misc.h index cb7c4cb..06f58e2 100644 --- a/libcfs/include/libcfs/linux/linux-misc.h +++ b/libcfs/include/libcfs/linux/linux-misc.h @@ -15,11 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf - * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ @@ -27,7 +23,7 @@ * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. * Use is subject to license terms. * - * Copyright (c) 2011, 2014, Intel Corporation. + * Copyright (c) 2011, 2017, Intel Corporation. */ /* * This file is part of Lustre, http://www.lustre.org/ @@ -37,6 +33,10 @@ #ifndef __LIBCFS_LINUX_MISC_H__ #define __LIBCFS_LINUX_MISC_H__ +#include +#include +#include + #ifdef HAVE_SYSCTL_CTLNAME #define INIT_CTL_NAME .ctl_name = CTL_UNNUMBERED, #define INIT_STRATEGY .strategy = &sysctl_intvec, @@ -45,6 +45,112 @@ #define INIT_STRATEGY #endif +#ifndef HAVE_MODULE_PARAM_LOCKING +static DEFINE_MUTEX(param_lock); +#endif + +#ifndef HAVE_UIDGID_HEADER + +#ifndef _LINUX_UIDGID_H +#define _LINUX_UIDGID_H + +typedef uid_t kuid_t; +typedef gid_t kgid_t; + +#define INVALID_UID -1 +#define INVALID_GID -1 + +#define GLOBAL_ROOT_UID 0 +#define GLOBAL_ROOT_GID 0 + +static inline uid_t __kuid_val(kuid_t uid) +{ + return uid; +} + +static inline gid_t __kgid_val(kgid_t gid) +{ + return gid; +} + +static inline kuid_t make_kuid(struct user_namespace *from, uid_t uid) +{ + return uid; +} + +static inline kgid_t make_kgid(struct user_namespace *from, gid_t gid) +{ + return gid; +} + +static inline uid_t from_kuid(struct user_namespace *to, kuid_t uid) +{ + return uid; +} + +static inline gid_t from_kgid(struct user_namespace *to, kgid_t gid) +{ + return gid; +} + +static inline bool uid_eq(kuid_t left, kuid_t right) +{ + return left == right; +} + +static inline bool uid_valid(kuid_t uid) +{ + return uid != (typeof(uid))INVALID_UID; +} + +static inline bool gid_valid(kgid_t gid) +{ + return gid != (typeof(gid))INVALID_GID; +} +#endif /* _LINUX_UIDGID_H */ + +#endif + +int cfs_get_environ(const char *key, char *value, int *val_len); + +#ifndef HAVE_WAIT_QUEUE_ENTRY +#define wait_queue_entry_t wait_queue_t +#endif + +int cfs_kernel_write(struct file *filp, char *buf, size_t count, loff_t *pos); + +/* + * For RHEL6 struct kernel_parm_ops doesn't exist. Also + * the arguments for .set and .get take different + * parameters which is handled below + */ +#ifdef HAVE_KERNEL_PARAM_OPS +#define cfs_kernel_param_arg_t const struct kernel_param +#else +#define cfs_kernel_param_arg_t struct kernel_param_ops +#define kernel_param_ops kernel_param +#endif /* ! HAVE_KERNEL_PARAM_OPS */ + +#ifndef HAVE_KERNEL_PARAM_LOCK +static inline void kernel_param_unlock(struct module *mod) +{ +#ifndef HAVE_MODULE_PARAM_LOCKING + mutex_unlock(¶m_lock); +#else + __kernel_param_unlock(); +#endif +} + +static inline void kernel_param_lock(struct module *mod) +{ +#ifndef HAVE_MODULE_PARAM_LOCKING + mutex_lock(¶m_lock); +#else + __kernel_param_lock(); +#endif +} +#endif /* ! HAVE_KERNEL_PARAM_LOCK */ + #ifndef HAVE_KSTRTOUL static inline int kstrtoul(const char *s, unsigned int base, unsigned long *res) { @@ -57,4 +163,10 @@ static inline int kstrtoul(const char *s, unsigned int base, unsigned long *res) } #endif /* !HAVE_KSTRTOUL */ +#ifndef HAVE_KSTRTOBOOL_FROM_USER + +#define kstrtobool strtobool + +int kstrtobool_from_user(const char __user *s, size_t count, bool *res); +#endif #endif