else
case $LINUXRELEASE in
# ext4 was in 2.6.22-2.6.26 but not stable enough to use
- 2.6.2[0-6]*) enable_ext4='no' ;;
+ 2.6.2[[0-9]]*) enable_ext4='no' ;;
*) LC_KERNEL_WITH_EXT4([enable_ext4='yes'],
[enable_ext4='no']) ;;
esac
LB_LINUX_TRY_COMPILE([
#include <net/net_namespace.h>
],[
- struct net *net = &init_ns;
+ struct net *net = &init_net;
],[
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_INIT_NET, 1,
])
])
+# LIBCFS_CRED_WRAPPERS
+#
+# wrappers for task's credentials are in sles11
+#
+AC_DEFUN([LIBCFS_CRED_WRAPPERS],
+[AC_MSG_CHECKING([if kernel has wrappers for task's credentials])
+LB_LINUX_TRY_COMPILE([
+ #include <linux/sched.h>
+],[
+ uid_t uid;
+
+ uid = current_uid();
+],[
+ AC_MSG_RESULT([yes])
+ AC_DEFINE(HAVE_CRED_WRAPPERS, 1, [task's cred wrappers found])
+],[
+ AC_MSG_RESULT([no])
+])
+])
+
+#
+# LN_STRUCT_CRED_IN_TASK
+#
+# struct cred was introduced in 2.6.29 to streamline credentials in task struct
+#
+AC_DEFUN([LIBCFS_STRUCT_CRED_IN_TASK],
+[AC_MSG_CHECKING([if kernel has struct cred])
+LB_LINUX_TRY_COMPILE([
+ #include <linux/sched.h>
+],[
+ struct task_struct *tsk = NULL;
+ tsk->real_cred = NULL;
+],[
+ AC_MSG_RESULT([yes])
+ AC_DEFINE(HAVE_STRUCT_CRED, 1, [struct cred found])
+],[
+ AC_MSG_RESULT([no])
+])
+])
+
+#
+# LIBCFS_FUNC_UNSHARE_FS_STRUCT
+#
+# unshare_fs_struct was introduced in 2.6.30 to prevent others to directly
+# mess with copy_fs_struct
+#
+AC_DEFUN([LIBCFS_FUNC_UNSHARE_FS_STRUCT],
+[AC_MSG_CHECKING([if kernel defines unshare_fs_struct()])
+tmp_flags="$EXTRA_KCFLAGS"
+EXTRA_KCFLAGS="-Werror"
+LB_LINUX_TRY_COMPILE([
+ #include <linux/sched.h>
+ #include <linux/fs_struct.h>
+],[
+ unshare_fs_struct();
+],[
+ AC_MSG_RESULT([yes])
+ AC_DEFINE(HAVE_UNSHARE_FS_STRUCT, 1, [unshare_fs_struct found])
+],[
+ AC_MSG_RESULT([no])
+])
+EXTRA_KCFLAGS="$tmp_flags"
+])
+
#
# LIBCFS_PROG_LINUX
#
LIBCFS_FUNC_DUMP_TRACE
# 2.6.26
LIBCFS_SEM_COUNT
+# 2.6.27
+LIBCFS_CRED_WRAPPERS
+# 2.6.29
+LIBCFS_STRUCT_CRED_IN_TASK
+# 2.6.30
+LIBCFS_FUNC_UNSHARE_FS_STRUCT
LIBCFS_SOCK_MAP_FD_2ARG
])
*/
uid_t cfs_curproc_uid(void);
gid_t cfs_curproc_gid(void);
+uid_t cfs_curproc_euid(void);
+gid_t cfs_curproc_egid(void);
uid_t cfs_curproc_fsuid(void);
gid_t cfs_curproc_fsgid(void);
pid_t cfs_curproc_pid(void);
#define WITH_WATCHDOG
#endif
+#ifndef HAVE_STRUCT_CRED
+
+#define current_cred() (current)
+
+#define current_cred_xxx(xxx) \
+({ \
+ current->xxx; \
+})
+
+#ifndef HAVE_CRED_WRAPPERS
+
+#define current_uid() (current_cred_xxx(uid))
+#define current_gid() (current_cred_xxx(gid))
+#define current_euid() (current_cred_xxx(euid))
+#define current_egid() (current_cred_xxx(egid))
+#define current_suid() (current_cred_xxx(suid))
+#define current_sgid() (current_cred_xxx(sgid))
+#define current_fsuid() (current_cred_xxx(fsuid))
+#define current_fsgid() (current_cred_xxx(fsgid))
+#define current_cap() (current_cred_xxx(cap_effective))
+
+#endif /* HAVE_LINUX_CRED_H */
+
+#define current_user() (current_cred_xxx(user))
+#define current_user_ns() (current_cred_xxx(user)->user_ns)
+#define current_security() (current_cred_xxx(security))
+
+#define cred task_struct
+
+#define prepare_creds() (current)
+#define commit_creds(a)
+
+#endif /* HAVE_STRUCT_CRED */
+
#endif /* _LINUX_LIBCFS_H */
#include <net/sock.h>
+#ifndef HIPQUAD
+// XXX Should just kill all users
+#if defined(__LITTLE_ENDIAN)
+#define HIPQUAD(addr) \
+ ((unsigned char *)&addr)[3], \
+ ((unsigned char *)&addr)[2], \
+ ((unsigned char *)&addr)[1], \
+ ((unsigned char *)&addr)[0]
+#elif defined(__BIG_ENDIAN)
+#define HIPQUAD NIPQUAD
+#else
+#error "Please fix asm/byteorder.h"
+#endif /* __LITTLE_ENDIAN */
+#endif
+
typedef struct socket cfs_socket_t;
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,72))
prefetch(pos->member.next))
#endif /* cfs_list_for_each_entry */
+#ifndef cfs_list_for_each_entry_rcu
+#define cfs_list_for_each_entry_rcu(pos, head, member) \
+ list_for_each_entry(pos, head, member)
+#endif
+
+#ifndef cfs_list_for_each_entry_rcu
+#define cfs_list_for_each_entry_rcu(pos, head, member) \
+ list_for_each_entry(pos, head, member)
+#endif
+
#ifndef cfs_list_for_each_entry_reverse
/**
* Iterate backwards over a list of given type.
#endif
uid_t cfs_curproc_uid(void);
+gid_t cfs_curproc_gid(void);
+uid_t cfs_curproc_fsuid(void);
+gid_t cfs_curproc_fsgid(void);
#define LIBCFS_REALLOC(ptr, size) realloc(ptr, size)
*/
#include <linux/sched.h>
+#include <linux/fs_struct.h>
#define DEBUG_SUBSYSTEM S_LNET
uid_t cfs_curproc_uid(void)
{
- return current->uid;
+ return current_uid();
}
gid_t cfs_curproc_gid(void)
{
- return current->gid;
+ return current_gid();
}
uid_t cfs_curproc_fsuid(void)
{
- return current->fsuid;
+ return current_fsuid();
+}
+
+uid_t cfs_curproc_euid(void)
+{
+ return current_egid();
+}
+
+uid_t cfs_curproc_egid(void)
+{
+ return current_egid();
}
gid_t cfs_curproc_fsgid(void)
{
- return current->fsgid;
+ return current_fsgid();
}
pid_t cfs_curproc_pid(void)
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,4)
task_lock(current);
- nr = current->group_info->ngroups;
+ nr = current_cred()->group_info->ngroups;
task_unlock(current);
#else
nr = current->ngroups;
{
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,4)
task_lock(current);
- size = min_t(int, size, current->group_info->ngroups);
- memcpy(array, current->group_info->blocks[0], size * sizeof(__u32));
+ size = min_t(int, size, current_cred()->group_info->ngroups);
+ memcpy(array, current_cred()->group_info->blocks[0], size * sizeof(__u32));
task_unlock(current);
#else
LASSERT(size <= NGROUPS);
void cfs_cap_raise(cfs_cap_t cap)
{
- cap_raise(cfs_current()->cap_effective, cfs_cap_unpack(cap));
+ struct cred *cred;
+ if ((cred = prepare_creds())) {
+ cap_raise(cred->cap_effective, cfs_cap_unpack(cap));
+ commit_creds(cred);
+ }
}
void cfs_cap_lower(cfs_cap_t cap)
{
- cap_lower(cfs_current()->cap_effective, cfs_cap_unpack(cap));
+ struct cred *cred;
+ if ((cred = prepare_creds())) {
+ cap_lower(cred->cap_effective, cfs_cap_unpack(cap));
+ commit_creds(cred);
+ }
}
int cfs_cap_raised(cfs_cap_t cap)
{
- return cap_raised(cfs_current()->cap_effective, cfs_cap_unpack(cap));
+ return cap_raised(current_cap(), cfs_cap_unpack(cap));
}
-cfs_cap_t cfs_curproc_cap_pack(void)
+void cfs_kernel_cap_pack(cfs_kernel_cap_t kcap, cfs_cap_t *cap)
{
#if defined (_LINUX_CAPABILITY_VERSION) && _LINUX_CAPABILITY_VERSION == 0x19980330
- return cfs_cap_pack(current->cap_effective);
+ *cap = cfs_cap_pack(kcap);
#elif defined (_LINUX_CAPABILITY_VERSION) && _LINUX_CAPABILITY_VERSION == 0x20071026
- return cfs_cap_pack(current->cap_effective[0]);
+ *cap = cfs_cap_pack(kcap[0]);
#elif defined(_KERNEL_CAPABILITY_VERSION) && _KERNEL_CAPABILITY_VERSION == 0x20080522
/* XXX lost high byte */
- return cfs_cap_pack(current->cap_effective.cap[0]);
+ *cap = cfs_cap_pack(kcap.cap[0]);
#else
#error "need correct _KERNEL_CAPABILITY_VERSION "
#endif
}
-void cfs_curproc_cap_unpack(cfs_cap_t cap)
+void cfs_kernel_cap_unpack(cfs_kernel_cap_t *kcap, cfs_cap_t cap)
{
#if defined (_LINUX_CAPABILITY_VERSION) && _LINUX_CAPABILITY_VERSION == 0x19980330
- current->cap_effective = cfs_cap_unpack(cap);
+ *kcap = cfs_cap_unpack(cap);
#elif defined (_LINUX_CAPABILITY_VERSION) && _LINUX_CAPABILITY_VERSION == 0x20071026
- current->cap_effective[0] = cfs_cap_unpack(cap);
+ (*kcap)[0] = cfs_cap_unpack(cap);
#elif defined(_KERNEL_CAPABILITY_VERSION) && _KERNEL_CAPABILITY_VERSION == 0x20080522
- current->cap_effective.cap[0] = cfs_cap_unpack(cap);
+ kcap->cap[0] = cfs_cap_unpack(cap);
#else
#error "need correct _KERNEL_CAPABILITY_VERSION "
#endif
}
+cfs_cap_t cfs_curproc_cap_pack(void)
+{
+ cfs_cap_t cap;
+ cfs_kernel_cap_pack(current_cap(), &cap);
+ return cap;
+}
+
+void cfs_curproc_cap_unpack(cfs_cap_t cap)
+{
+ struct cred *cred;
+ if ((cred = prepare_creds())) {
+ cfs_kernel_cap_unpack(&cred->cap_effective, cap);
+ commit_creds(cred);
+ }
+}
+
int cfs_capable(cfs_cap_t cap)
{
return capable(cfs_cap_unpack(cap));
EXPORT_SYMBOL(cfs_curproc_uid);
EXPORT_SYMBOL(cfs_curproc_pid);
+EXPORT_SYMBOL(cfs_curproc_euid);
EXPORT_SYMBOL(cfs_curproc_gid);
+EXPORT_SYMBOL(cfs_curproc_egid);
EXPORT_SYMBOL(cfs_curproc_fsuid);
EXPORT_SYMBOL(cfs_curproc_fsgid);
EXPORT_SYMBOL(cfs_curproc_umask);
struct cfs_psdev_file pfile;
int rc = 0;
- if (current->fsuid != 0)
+ if (current_fsuid() != 0)
return -EACCES;
if ( _IOC_TYPE(cmd) != IOC_LIBCFS_TYPE ||
#endif
#include <linux/module.h>
#include <linux/kernel.h>
+#include <linux/fs_struct.h>
#include <linux/sched.h>
#include <libcfs/libcfs.h>
}
int cfs_daemonize_ctxt(char *str) {
- struct task_struct *tsk = current;
- struct fs_struct *fs = NULL;
cfs_daemonize(str);
+#ifndef HAVE_UNSHARE_FS_STRUCT
+ {
+ struct task_struct *tsk = current;
+ struct fs_struct *fs = NULL;
fs = copy_fs_struct(tsk->fs);
if (fs == NULL)
return -ENOMEM;
exit_fs(tsk);
tsk->fs = fs;
+ }
+#else
+ unshare_fs_struct();
+#endif
return 0;
}
-
sigset_t
cfs_get_blockedsigs(void)
{
return getuid();
}
+gid_t cfs_curproc_gid(void)
+{
+ return getgid();
+}
+
+uid_t cfs_curproc_fsuid(void)
+{
+ return getuid();
+}
+
+gid_t cfs_curproc_fsgid(void)
+{
+ return getgid();
+}
+
void cfs_enter_debugger(void)
{
/*
CFLAGS="$tmp_flags"
+AC_MSG_CHECKING(for POSIX 2008 preadv)
+tmp_flags="$CFLAGS"
+CFLAGS="$CFLAGS -Wall -Werror"
+AC_TRY_COMPILE([
+#include <sys/uio.h>
+ssize_t preadv (int __fd, const struct iovec *__iovec,
+ int __count, off_t off)
+{
+ return 0;
+}
+],[
+],[
+AC_DEFINE(HAVE_POSIX2008_PREADV, 1, [POSIX 2008 preadv])
+AC_MSG_RESULT(yes)
+],[
+AC_MSG_RESULT(no)
+])
+CFLAGS="$tmp_flags"
+
+AC_MSG_CHECKING(for POSIX 2008 scandir)
+tmp_flags="$CFLAGS"
+CFLAGS="$CFLAGS -Wall -Werror"
+AC_TRY_COMPILE([
+#define _BSD_SOURCE
+
+#include <stdio.h>
+#include <dirent.h>
+
+int scandir(const char *dir,
+ struct dirent ***namelist,
+ int(*filter)(const struct dirent *),
+ int(*compar)(const struct dirent **,
+ const struct dirent **)
+ );
+
+],[
+], [
+AC_DEFINE(HAVE_POSIX2008_SCANDIR, 1, [POSIX 2008 scandir])
+AC_MSG_RESULT(yes)
+],[
+AC_MSG_RESULT(no)
+])
+CFLAGS="$tmp_flags"
+
+
AC_MSG_CHECKING(whether .text pseudo-op must be used)
AC_CACHE_VAL(am_cv_sysio_asm_dot_text, [dnl
cat > conftest.s <<EOF
])
#
+# LC_D_OBTAIN_ALIAS
+# starting from 2.6.18 kernel don't export do_kern_mount
+# and want to use vfs_kern_mount instead.
+#
+AC_DEFUN([LC_D_OBTAIN_ALIAS],
+[AC_MSG_CHECKING([d_obtain_alias exist in kernel])
+LB_LINUX_TRY_COMPILE([
+ #include <linux/dcache.h>
+],[
+ d_obtain_alias(NULL);
+],[
+ AC_DEFINE(HAVE_D_OBTAIN_ALIAS, 1,
+ [d_obtain_alias exist in kernel])
+ AC_MSG_RESULT([yes])
+],[
+ AC_MSG_RESULT([no])
+])
+])
+
+#
# LC_INVALIDATEPAGE_RETURN_INT
# 2.6.17 changes return type for invalidatepage to 'void' from 'int'
#
AC_DEFINE(LIBLUSTRE_POSIX_ACL, 1, Liblustre Support ACL-enabled MDS)
fi
+# 2.6.29 change prepare/commit_write to write_begin/end
+AC_DEFUN([LC_WRITE_BEGIN_END],
+[AC_MSG_CHECKING([if kernel has .write_begin/end])
+LB_LINUX_TRY_COMPILE([
+ #include <linux/fs.h>
+ #include <linux/pagemap.h>
+#ifdef HAVE_LINUX_MMTYPES_H
+ #include <linux/mm_types.h>
+#endif
+],[
+ struct address_space_operations aops;
+ struct page *page;
+
+ aops.write_begin = NULL;
+ aops.write_end = NULL;
+ page = grab_cache_page_write_begin(NULL, 0, 0);
+], [
+ AC_MSG_RESULT([yes])
+ AC_DEFINE(HAVE_KERNEL_WRITE_BEGIN_END, 1,
+ [kernel has .write_begin/end])
+],[
+ AC_MSG_RESULT([no])
+])
+])
+
+# 2.6.29 blkdev_put has 2 arguments
+AC_DEFUN([LC_BLKDEV_PUT_2ARGS],
+[AC_MSG_CHECKING([blkdev_put needs 2 parameters])
+LB_LINUX_TRY_COMPILE([
+ #include <linux/fs.h>
+],[
+ blkdev_put(NULL, 0);
+],[
+ AC_DEFINE(HAVE_BLKDEV_PUT_2ARGS, 1,
+ [blkdev_put needs 2 paramters])
+ AC_MSG_RESULT([yes])
+],[
+ AC_MSG_RESULT([no])
+])
+])
+
+# 2.6.29 dentry_open has 4 arguments
+AC_DEFUN([LC_DENTRY_OPEN_4ARGS],
+[AC_MSG_CHECKING([dentry_open needs 4 parameters])
+LB_LINUX_TRY_COMPILE([
+ #include <linux/fs.h>
+],[
+ dentry_open(NULL, NULL, 0, NULL);
+],[
+ AC_DEFINE(HAVE_DENTRY_OPEN_4ARGS, 1,
+ [dentry_open needs 4 paramters])
+ AC_MSG_RESULT([yes])
+],[
+ AC_MSG_RESULT([no])
+])
+])
+
#
# --enable-mpitest
#
AC_DEFINE([USE_LU_REF], 1, [enable lu_ref reference tracking code])
fi
+ #2.6.29
+ LC_WRITE_BEGIN_END
+ LC_D_OBTAIN_ALIAS
+ LC_BLKDEV_PUT_2ARGS
+ LC_DENTRY_OPEN_4ARGS
+
])
#
#define cfs_current() current
#define cfs_curproc_pid() (current->pid)
#define cfs_curproc_comm() (current->comm)
+#define cfs_curproc_fsuid() (current->fsuid)
+#define cfs_curproc_fsgid() (current->fsgid)
extern struct task_struct *current;
int cfs_curproc_is_in_groups(gid_t gid);
#error sorry, lustre requires at least linux kernel 2.6.9 or later
#endif
+#include <linux/fs_struct.h>
#include <libcfs/linux/portals_compat25.h>
#include <linux/lustre_patchless_compat.h>
#define LOCK_DQONOFF_MUTEX(dqopt) cfs_down(&(dqopt)->dqonoff_sem)
#endif /* HAVE_DQUOTOFF_MUTEX */
-#define current_ngroups current->group_info->ngroups
-#define current_groups current->group_info->small_block
+#define current_ngroups current_cred()->group_info->ngroups
+#define current_groups current_cred()->group_info->small_block
#ifndef page_private
#define page_private(page) ((page)->private)
#define val_to_kdev(dev) (dev)
#define ILOOKUP(sb, ino, test, data) ilookup5(sb, ino, test, (void *)(data));
+#ifdef HAVE_BLKDEV_PUT_2ARGS
+#define ll_blkdev_put(a, b) blkdev_put(a, b)
+#else
+#define ll_blkdev_put(a, b) blkdev_put(a)
+#endif
+
+#ifdef HAVE_DENTRY_OPEN_4ARGS
+#define ll_dentry_open(a, b, c, d) dentry_open(a, b, c, d)
+#else
+#define ll_dentry_open(a, b, c, d) dentry_open(a, b, c)
+#endif
+
#include <linux/writeback.h>
static inline int cfs_cleanup_group_info(void)
#define LL_RENAME_DOES_D_MOVE FS_ODD_RENAME
#endif
+#ifndef HAVE_D_OBTAIN_ALIAS
+#define d_obtain_alias(inode) d_alloc_anon(inode)
+#endif
+
/* add a lustre compatible layer for crypto API */
#include <linux/crypto.h>
#ifdef HAVE_ASYNC_BLOCK_CIPHER
void *data,
struct file_operations *fops);
extern struct proc_dir_entry *lprocfs_add_symlink(const char *name,
- struct proc_dir_entry *parent, const char *dest);
+ struct proc_dir_entry *parent, const char *format, ...);
extern void lprocfs_free_per_client_stats(struct obd_device *obd);
extern int lprocfs_nid_stats_clear_write(struct file *file, const char *buffer,
unsigned long count, void *data);
struct file_operations *fops)
{return 0; }
static inline struct proc_dir_entry *lprocfs_add_symlink(const char *name,
- struct proc_dir_entry *parent, const char *dest)
+ struct proc_dir_entry *parent, const char *format, ...)
{return NULL; }
static inline void lprocfs_free_per_client_stats(struct obd_device *obd)
{}
#undef FIEMAP_FLAGS_COMPAT
#endif
-#define FIEMAP_FLAGS_COMPAT (FIEMAP_FLAG_SYNC | FIEMAP_FLAG_XATTR | \
- FIEMAP_FLAG_DEVICE_ORDER)
-
/* Lustre specific flags - use a high bit, don't conflict with upstream flag */
#define FIEMAP_EXTENT_NO_DIRECT 0x40000000 /* Data mapping undefined */
#define FIEMAP_EXTENT_NET 0x80000000 /* Data stored remotely.
int ldlm_cli_enqueue(struct obd_export *exp, struct ptlrpc_request **reqp,
struct ldlm_enqueue_info *einfo,
const struct ldlm_res_id *res_id,
- ldlm_policy_data_t *policy, int *flags,
+ ldlm_policy_data_t const *policy, int *flags,
void *lvb, __u32 lvb_len, struct lustre_handle *lockh,
int async);
int ldlm_prep_enqueue_req(struct obd_export *exp,
*/
if ((lock->l_resource->lr_type == LDLM_IBITS) &&
(exp && !(exp->exp_connect_flags & OBD_CONNECT_IBITS))) {
- struct ldlm_resource res = *lock->l_resource;
-
/* Make sure all the right bits are set in this lock we
are going to pass to client */
LASSERTF(lock->l_policy_data.l_inodebits.bits ==
"Inappropriate inode lock bits during "
"conversion " LPU64 "\n",
lock->l_policy_data.l_inodebits.bits);
- res.lr_type = LDLM_PLAIN;
- ldlm_res2desc(&res, &desc->l_resource);
+
+ ldlm_res2desc(lock->l_resource, &desc->l_resource);
+ desc->l_resource.lr_type = LDLM_PLAIN;
+
/* Convert "new" lock mode to something old client can
understand */
if ((lock->l_req_mode == LCK_CR) ||
int ldlm_cli_enqueue(struct obd_export *exp, struct ptlrpc_request **reqp,
struct ldlm_enqueue_info *einfo,
const struct ldlm_res_id *res_id,
- ldlm_policy_data_t *policy, int *flags,
+ ldlm_policy_data_t const *policy, int *flags,
void *lvb, __u32 lvb_len, struct lustre_handle *lockh,
int async)
{
GOTO(out_quotactl, rc = -EPERM);
break;
case Q_GETQUOTA:
- if (((type == USRQUOTA && current->euid != id) ||
+ if (((type == USRQUOTA && cfs_curproc_euid() != id) ||
(type == GRPQUOTA && !in_egroup_p(id))) &&
(!cfs_capable(CFS_CAP_SYS_ADMIN) ||
sbi->ll_flags & LL_SBI_RMT_CLIENT))
/* POSIX: check before ATTR_*TIME_SET set (from inode_change_ok) */
if (ia_valid & (ATTR_MTIME_SET | ATTR_ATIME_SET)) {
- if (current->fsuid != inode->i_uid &&
+ if (cfs_curproc_fsuid() != inode->i_uid &&
!cfs_capable(CFS_CAP_FOWNER))
RETURN(-EPERM);
}
{
struct ll_sb_info *sbi = ll_i2sbi(inode);
- CDEBUG(D_SEC, "flush context for user %d\n", current->uid);
+ CDEBUG(D_SEC, "flush context for user %d\n", cfs_curproc_uid());
obd_set_info_async(sbi->ll_md_exp,
sizeof(KEY_FLUSH_CTX), KEY_FLUSH_CTX,
struct lustre_sb_info *lsi = s2lsi(sb);
struct ll_sb_info *sbi = ll_s2sbi(sb);
struct obd_device *obd;
- struct obd_ioctl_data ioc_data = { 0 };
+ struct obd_ioctl_data *ioc_data;
ENTRY;
#ifdef HAVE_UMOUNTBEGIN_VFSMOUNT
return;
}
obd->obd_force = 1;
- obd_iocontrol(IOC_OSC_SET_ACTIVE, sbi->ll_md_exp, sizeof ioc_data,
- &ioc_data, NULL);
obd = class_exp2obd(sbi->ll_dt_exp);
if (obd == NULL) {
EXIT;
return;
}
-
obd->obd_force = 1;
- obd_iocontrol(IOC_OSC_SET_ACTIVE, sbi->ll_dt_exp, sizeof ioc_data,
- &ioc_data, NULL);
+
+ OBD_ALLOC_PTR(ioc_data);
+ if (ioc_data) {
+ obd_iocontrol(IOC_OSC_SET_ACTIVE, sbi->ll_md_exp,
+ sizeof ioc_data, ioc_data, NULL);
+
+ obd_iocontrol(IOC_OSC_SET_ACTIVE, sbi->ll_dt_exp,
+ sizeof ioc_data, ioc_data, NULL);
+
+ OBD_FREE_PTR(ioc_data);
+ }
+
/* Really, we'd like to wait until there are no requests outstanding,
* and then continue. For now, we just invalidate the requests,
op_data->op_namelen = namelen;
op_data->op_mode = mode;
op_data->op_mod_time = cfs_time_current_sec();
- op_data->op_fsuid = current->fsuid;
- op_data->op_fsgid = current->fsgid;
+ op_data->op_fsuid = cfs_curproc_fsuid();
+ op_data->op_fsgid = cfs_curproc_fsgid();
op_data->op_cap = cfs_curproc_cap_pack();
op_data->op_bias = MDS_CHECK_SPLIT;
op_data->op_opc = opc;
RETURN(ERR_PTR(-ESTALE));
}
- result = d_alloc_anon(inode);
+ result = d_obtain_alias(inode);
if (!result) {
iput(inode);
RETURN(ERR_PTR(-ENOMEM));
return 0;
}
+#ifdef HAVE_BLKDEV_PUT_2ARGS
+static int lo_open(struct block_device *bdev, fmode_t mode)
+{
+ struct lloop_device *lo = bdev->bd_disk->private_data;
+#else
static int lo_open(struct inode *inode, struct file *file)
{
struct lloop_device *lo = inode->i_bdev->bd_disk->private_data;
+#endif
cfs_down(&lo->lo_ctl_mutex);
lo->lo_refcnt++;
return 0;
}
+#ifdef HAVE_BLKDEV_PUT_2ARGS
+static int lo_release(struct gendisk *disk, fmode_t mode)
+{
+ struct lloop_device *lo = disk->private_data;
+#else
static int lo_release(struct inode *inode, struct file *file)
{
struct lloop_device *lo = inode->i_bdev->bd_disk->private_data;
+#endif
cfs_down(&lo->lo_ctl_mutex);
--lo->lo_refcnt;
}
/* lloop device node's ioctl function. */
+#ifdef HAVE_BLKDEV_PUT_2ARGS
+static int lo_ioctl(struct block_device *bdev, fmode_t mode,
+ unsigned int cmd, unsigned long arg)
+{
+ struct lloop_device *lo = bdev->bd_disk->private_data;
+#else
static int lo_ioctl(struct inode *inode, struct file *unused,
unsigned int cmd, unsigned long arg)
{
struct lloop_device *lo = inode->i_bdev->bd_disk->private_data;
struct block_device *bdev = inode->i_bdev;
+#endif
int err = 0;
cfs_down(&lloop_mutex);
case LL_IOC_LLOOP_DETACH: {
err = loop_clr_fd(lo, bdev, 2);
if (err == 0)
- blkdev_put(bdev); /* grabbed in LLOOP_ATTACH */
+ ll_blkdev_put(bdev, 0); /* grabbed in LLOOP_ATTACH */
break;
}
err = loop_set_fd(lo, NULL, bdev, file);
if (err) {
fput(file);
- blkdev_put(bdev);
+ ll_blkdev_put(bdev, 0);
}
break;
bdev = lo->lo_device;
err = loop_clr_fd(lo, bdev, 1);
if (err == 0)
- blkdev_put(bdev); /* grabbed in LLOOP_ATTACH */
+ ll_blkdev_put(bdev, 0); /* grabbed in LLOOP_ATTACH */
break;
}
sbi->ll_stats_track_id == current->parent->pid)
lprocfs_counter_add(sbi->ll_stats, op, count);
else if (sbi->ll_stats_track_type == STATS_TRACK_GID &&
- sbi->ll_stats_track_id == current->gid)
+ sbi->ll_stats_track_id == cfs_curproc_gid())
lprocfs_counter_add(sbi->ll_stats, op, count);
}
EXPORT_SYMBOL(ll_stats_ops_tally);
GOTO(err_exit, err = PTR_ERR(op_data));
err = md_create(sbi->ll_md_exp, op_data, tgt, tgt_len, mode,
- current->fsuid, current->fsgid,
+ cfs_curproc_fsuid(), cfs_curproc_fsgid(),
cfs_curproc_cap_pack(), rdev, &request);
ll_finish_md_op_data(op_data);
if (err)
if (!lli->lli_remote_perms)
RETURN(-ENOENT);
- head = lli->lli_remote_perms + remote_perm_hashfunc(current->uid);
+ head = lli->lli_remote_perms + remote_perm_hashfunc(cfs_curproc_uid());
cfs_spin_lock(&lli->lli_lock);
cfs_hlist_for_each_entry(lrp, node, head, lrp_list) {
- if (lrp->lrp_uid != current->uid)
+ if (lrp->lrp_uid != cfs_curproc_uid())
continue;
- if (lrp->lrp_gid != current->gid)
+ if (lrp->lrp_gid != cfs_curproc_gid())
continue;
- if (lrp->lrp_fsuid != current->fsuid)
+ if (lrp->lrp_fsuid != cfs_curproc_fsuid())
continue;
- if (lrp->lrp_fsgid != current->fsgid)
+ if (lrp->lrp_fsgid != cfs_curproc_fsgid())
continue;
found = 1;
break;
RETURN(tot_bytes ? : result);
}
+#ifdef HAVE_KERNEL_WRITE_BEGIN_END
+static int ll_write_begin(struct file *file, struct address_space *mapping,
+ loff_t pos, unsigned len, unsigned flags,
+ struct page **pagep, void **fsdata)
+{
+ pgoff_t index = pos >> PAGE_CACHE_SHIFT;
+ struct page *page;
+ int rc;
+ unsigned from = pos & (PAGE_CACHE_SIZE - 1);
+ ENTRY;
+
+ page = grab_cache_page_write_begin(mapping, index, flags);
+ if (!page)
+ RETURN(-ENOMEM);
+
+ *pagep = page;
+
+ rc = ll_prepare_write(file, page, from, from + len);
+ if (rc) {
+ unlock_page(page);
+ page_cache_release(page);
+ }
+ RETURN(rc);
+}
+
+static int ll_write_end(struct file *file, struct address_space *mapping,
+ loff_t pos, unsigned len, unsigned copied,
+ struct page *page, void *fsdata)
+{
+ unsigned from = pos & (PAGE_CACHE_SIZE - 1);
+ int rc;
+ rc = ll_commit_write(file, page, from, from + copied);
+
+ unlock_page(page);
+ page_cache_release(page);
+ return rc?rc:copied;
+}
+#endif
+
struct address_space_operations ll_aops = {
.readpage = ll_readpage,
// .readpages = ll_readpages,
.writepages = generic_writepages,
.set_page_dirty = ll_set_page_dirty,
.sync_page = NULL,
+#ifdef HAVE_KERNEL_WRITE_BEGIN_END
+ .write_begin = ll_write_begin,
+ .write_end = ll_write_end,
+#else
.prepare_write = ll_prepare_write,
.commit_write = ll_commit_write,
+#endif
.invalidatepage = ll_invalidatepage,
.releasepage = (void *)ll_releasepage,
.bmap = NULL
GOTO(out, rc = -ERANGE);
}
+ if (body->eadatasize == 0)
+ GOTO(out, rc = -ENODATA);
+
/* do not need swab xattr data */
xdata = req_capsule_server_sized_get(&req->rq_pill, &RMF_EADATA,
body->eadatasize);
lmv_proc_dir = lprocfs_srch(obd->obd_proc_entry, "target_obds");
if (lmv_proc_dir) {
struct proc_dir_entry *mdc_symlink;
- char name[MAX_STRING_SIZE + 1];
LASSERT(mdc_obd->obd_type != NULL);
LASSERT(mdc_obd->obd_type->typ_name != NULL);
- name[MAX_STRING_SIZE] = '\0';
- snprintf(name, MAX_STRING_SIZE, "../../../%s/%s",
- mdc_obd->obd_type->typ_name,
- mdc_obd->obd_name);
- mdc_symlink = proc_symlink(mdc_obd->obd_name,
- lmv_proc_dir, name);
+ mdc_symlink = lprocfs_add_symlink(mdc_obd->obd_name,
+ lmv_proc_dir,
+ "../../../%s/%s",
+ mdc_obd->obd_type->typ_name,
+ mdc_obd->obd_name);
if (mdc_symlink == NULL) {
CERROR("Could not register LMV target "
"/proc/fs/lustre/%s/%s/target_obds/%s.",
CDEBUG(D_INODE, "Forward to mds #%x ("DFID")\n",
mds, PFID(&op_data->op_fid1));
- op_data->op_fsuid = current->fsuid;
- op_data->op_fsgid = current->fsgid;
+ op_data->op_fsuid = cfs_curproc_fsuid();
+ op_data->op_fsgid = cfs_curproc_fsgid();
op_data->op_cap = cfs_curproc_cap_pack();
tgt = lmv_get_target(lmv, mds);
RETURN(rc);
}
- op_data->op_fsuid = current->fsuid;
- op_data->op_fsgid = current->fsgid;
+ op_data->op_fsuid = cfs_curproc_fsuid();
+ op_data->op_fsgid = cfs_curproc_fsgid();
op_data->op_cap = cfs_curproc_cap_pack();
src_tgt = lmv_get_target(lmv, mds1);
op_data->op_bias |= MDS_CHECK_SPLIT;
}
- op_data->op_fsuid = current->fsuid;
- op_data->op_fsgid = current->fsgid;
+ op_data->op_fsuid = cfs_curproc_fsuid();
+ op_data->op_fsgid = cfs_curproc_fsgid();
op_data->op_cap = cfs_curproc_cap_pack();
/*
struct obd_connect_data *data)
{
struct lov_obd *lov = &obd->u.lov;
- struct obd_uuid tgt_uuid;
+ struct obd_uuid *tgt_uuid;
struct obd_device *tgt_obd;
static struct obd_uuid lov_osc_uuid = { "LOV_OSC_UUID" };
struct obd_import *imp;
-
#ifdef __KERNEL__
cfs_proc_dir_entry_t *lov_proc_dir;
#endif
if (!lov->lov_tgts[index])
RETURN(-EINVAL);
- tgt_uuid = lov->lov_tgts[index]->ltd_uuid;
+ tgt_uuid = &lov->lov_tgts[index]->ltd_uuid;
tgt_obd = lov->lov_tgts[index]->ltd_obd;
if (!tgt_obd->obd_set_up) {
- CERROR("Target %s not set up\n", obd_uuid2str(&tgt_uuid));
+ CERROR("Target %s not set up\n", obd_uuid2str(tgt_uuid));
RETURN(-EINVAL);
}
rc = obd_register_observer(tgt_obd, obd);
if (rc) {
CERROR("Target %s register_observer error %d\n",
- obd_uuid2str(&tgt_uuid), rc);
+ obd_uuid2str(tgt_uuid), rc);
RETURN(rc);
}
if (imp->imp_invalid) {
CERROR("not connecting OSC %s; administratively "
- "disabled\n", obd_uuid2str(&tgt_uuid));
+ "disabled\n", obd_uuid2str(tgt_uuid));
RETURN(0);
}
&lov_osc_uuid, data, NULL);
if (rc || !lov->lov_tgts[index]->ltd_exp) {
CERROR("Target %s connect error %d\n",
- obd_uuid2str(&tgt_uuid), rc);
+ obd_uuid2str(tgt_uuid), rc);
RETURN(-ENODEV);
}
lov->lov_tgts[index]->ltd_reap = 0;
CDEBUG(D_CONFIG, "Connected tgt idx %d %s (%s) %sactive\n", index,
- obd_uuid2str(&tgt_uuid), tgt_obd->obd_name, activate ? "":"in");
+ obd_uuid2str(tgt_uuid), tgt_obd->obd_name, activate ? "":"in");
#ifdef __KERNEL__
lov_proc_dir = lprocfs_srch(obd->obd_proc_entry, "target_obds");
if (lov_proc_dir) {
struct obd_device *osc_obd = lov->lov_tgts[index]->ltd_exp->exp_obd;
cfs_proc_dir_entry_t *osc_symlink;
- char name[MAX_STRING_SIZE];
LASSERT(osc_obd != NULL);
LASSERT(osc_obd->obd_magic == OBD_DEVICE_MAGIC);
LASSERT(osc_obd->obd_type->typ_name != NULL);
- snprintf(name, MAX_STRING_SIZE, "../../../%s/%s",
- osc_obd->obd_type->typ_name,
- osc_obd->obd_name);
- osc_symlink = lprocfs_add_symlink(osc_obd->obd_name, lov_proc_dir,
- name);
+
+ osc_symlink = lprocfs_add_symlink(osc_obd->obd_name,
+ lov_proc_dir,
+ "../../../%s/%s",
+ osc_obd->obd_type->typ_name,
+ osc_obd->obd_name);
if (osc_symlink == NULL) {
CERROR("could not register LOV target "
- "/proc/fs/lustre/%s/%s/target_obds/%s.",
- obd->obd_type->typ_name, obd->obd_name,
- osc_obd->obd_name);
+ "/proc/fs/lustre/%s/%s/target_obds/%s.",
+ obd->obd_type->typ_name, obd->obd_name,
+ osc_obd->obd_name);
lprocfs_remove(&lov_proc_dir);
}
}
{
struct obd_device *obd = class_exp2obd(exp);
struct lov_obd *lov = &obd->u.lov;
- struct lov_user_md_v3 lumv3;
- struct lov_user_md_v1 *lumv1 = (struct lov_user_md_v1 *)&lumv3;
+ char buffer[sizeof(struct lov_user_md_v3)];
+ struct lov_user_md_v3 *lumv3 = (struct lov_user_md_v3 *)&buffer[0];
+ struct lov_user_md_v1 *lumv1 = (struct lov_user_md_v1 *)&buffer[0];
int lmm_magic;
int stripe_count;
int rc;
ENTRY;
- if (cfs_copy_from_user(&lumv3, lump, sizeof(struct lov_user_md_v1)))
+ if (cfs_copy_from_user(lumv3, lump, sizeof(struct lov_user_md_v1)))
RETURN(-EFAULT);
lmm_magic = lumv1->lmm_magic;
lustre_swab_lov_user_md_v1(lumv1);
lmm_magic = LOV_USER_MAGIC_V1;
} else if (lmm_magic == LOV_USER_MAGIC_V3) {
- if (cfs_copy_from_user(&lumv3, lump, sizeof(lumv3)))
+ if (cfs_copy_from_user(lumv3, lump, sizeof(*lumv3)))
RETURN(-EFAULT);
} else if (lmm_magic == __swab32(LOV_USER_MAGIC_V3)) {
- if (cfs_copy_from_user(&lumv3, lump, sizeof(lumv3)))
+ if (cfs_copy_from_user(lumv3, lump, sizeof(*lumv3)))
RETURN(-EFAULT);
- lustre_swab_lov_user_md_v3(&lumv3);
+ lustre_swab_lov_user_md_v3(lumv3);
lmm_magic = LOV_USER_MAGIC_V3;
} else if (lmm_magic != LOV_USER_MAGIC_V1) {
CDEBUG(D_IOCTL,
if (lmm_magic == LOV_USER_MAGIC_V3) {
struct pool_desc *pool;
- pool = lov_find_pool(lov, lumv3.lmm_pool_name);
+ pool = lov_find_pool(lov, lumv3->lmm_pool_name);
if (pool != NULL) {
- if (lumv3.lmm_stripe_offset !=
- (typeof(lumv3.lmm_stripe_offset))(-1)) {
+ if (lumv3->lmm_stripe_offset !=
+ (typeof(lumv3->lmm_stripe_offset))(-1)) {
rc = lov_check_index_in_pool(
- lumv3.lmm_stripe_offset, pool);
+ lumv3->lmm_stripe_offset, pool);
if (rc < 0) {
lov_pool_putref(pool);
RETURN(-EINVAL);
(*lsmp)->lsm_oinfo[0]->loi_ost_idx = lumv1->lmm_stripe_offset;
(*lsmp)->lsm_stripe_size = lumv1->lmm_stripe_size;
if (lmm_magic == LOV_USER_MAGIC_V3)
- strncpy((*lsmp)->lsm_pool_name, lumv3.lmm_pool_name,
+ strncpy((*lsmp)->lsm_pool_name, lumv3->lmm_pool_name,
LOV_MAXPOOLNAME);
rc = 0;
}
save->ngroups = current_ngroups;
current_ngroups = 0;
} else {
+ struct cred *cred;
task_lock(current);
- save->group_info = current->group_info;
- current->group_info = ginfo;
+ save->group_info = current_cred()->group_info;
+ if ((cred = prepare_creds())) {
+ cred->group_info = ginfo;
+ commit_creds(cred);
+ }
task_unlock(current);
}
}
if (!ginfo) {
current_ngroups = save->ngroups;
} else {
+ struct cred *cred;
task_lock(current);
- current->group_info = save->group_info;
+ if ((cred = prepare_creds())) {
+ cred->group_info = save->group_info;
+ commit_creds(cred);
+ }
task_unlock(current);
}
}
save->pwd = dget(cfs_fs_pwd(current->fs));
save->pwdmnt = mntget(cfs_fs_mnt(current->fs));
save->luc.luc_umask = current->fs->umask;
- save->ngroups = current->group_info->ngroups;
+ save->ngroups = current_cred()->group_info->ngroups;
LASSERT(save->pwd);
LASSERT(save->pwdmnt);
LASSERT(new_ctx->pwdmnt);
if (uc) {
- save->luc.luc_uid = current->uid;
- save->luc.luc_gid = current->gid;
- save->luc.luc_fsuid = current->fsuid;
- save->luc.luc_fsgid = current->fsgid;
- save->luc.luc_cap = current->cap_effective;
-
- current->uid = uc->luc_uid;
- current->gid = uc->luc_gid;
- current->fsuid = uc->luc_fsuid;
- current->fsgid = uc->luc_fsgid;
- current->cap_effective = uc->luc_cap;
+ struct cred *cred;
+ save->luc.luc_uid = current_uid();
+ save->luc.luc_gid = current_gid();
+ save->luc.luc_fsuid = current_fsuid();
+ save->luc.luc_fsgid = current_fsgid();
+ save->luc.luc_cap = current_cap();
+
+ if ((cred = prepare_creds())) {
+ cred->uid = uc->luc_uid;
+ cred->gid = uc->luc_gid;
+ cred->fsuid = uc->luc_fsuid;
+ cred->fsgid = uc->luc_fsgid;
+ cred->cap_effective = uc->luc_cap;
+ commit_creds(cred);
+ }
push_group_info(save,
uc->luc_ginfo ?:
mntput(saved->pwdmnt);
current->fs->umask = saved->luc.luc_umask;
if (uc) {
- current->uid = saved->luc.luc_uid;
- current->gid = saved->luc.luc_gid;
- current->fsuid = saved->luc.luc_fsuid;
- current->fsgid = saved->luc.luc_fsgid;
- current->cap_effective = saved->luc.luc_cap;
+ struct cred *cred;
+ if ((cred = prepare_creds())) {
+ cred->uid = saved->luc.luc_uid;
+ cred->gid = saved->luc.luc_gid;
+ cred->fsuid = saved->luc.luc_fsuid;
+ cred->fsgid = saved->luc.luc_fsgid;
+ cred->cap_effective = saved->luc.luc_cap;
+ commit_creds(cred);
+ }
+
pop_group_info(saved,
uc->luc_ginfo ?:
uc->luc_identity ? uc->luc_identity->mi_ginfo :
int flags)
{
mntget(ctxt->pwdmnt);
- return dentry_open(de, ctxt->pwdmnt, flags);
+ return ll_dentry_open(de, ctxt->pwdmnt, flags, current_cred());
}
EXPORT_SYMBOL(l_dentry_open);
LASSERT (b != NULL);
b->suppgid = suppgid;
- b->uid = current->uid;
- b->gid = current->gid;
- b->fsuid = current->fsuid;
- b->fsgid = current->fsgid;
+ b->uid = cfs_curproc_uid();
+ b->gid = cfs_curproc_gid();
+ b->fsuid = cfs_curproc_fsuid();
+ b->fsgid = cfs_curproc_fsgid();
b->capability = cfs_curproc_cap_pack();
}
/* XXX do something about time, uid, gid */
rec->cr_opcode = REINT_OPEN;
- rec->cr_fsuid = current->fsuid;
- rec->cr_fsgid = current->fsgid;
+ rec->cr_fsuid = cfs_curproc_fsuid();
+ rec->cr_fsgid = cfs_curproc_fsgid();
rec->cr_cap = cfs_curproc_cap_pack();
if (op_data != NULL) {
rec->cr_fid1 = op_data->op_fid1;
struct md_op_data *op_data)
{
rec->sa_opcode = REINT_SETATTR;
- rec->sa_fsuid = current->fsuid;
- rec->sa_fsgid = current->fsgid;
+ rec->sa_fsuid = cfs_curproc_fsuid();
+ rec->sa_fsgid = cfs_curproc_fsgid();
rec->sa_cap = cfs_curproc_cap_pack();
rec->sa_suppgid = -1;
struct mdt_body *b = req_capsule_client_get(&req->rq_pill,
&RMF_MDT_BODY);
- b->fsuid = current->fsuid;
- b->fsgid = current->fsgid;
+ b->fsuid = cfs_curproc_fsuid();
+ b->fsgid = cfs_curproc_fsgid();
b->capability = cfs_curproc_cap_pack();
b->valid = valid;
if (op_data->op_bias & MDS_CHECK_SPLIT)
int flags = extra_lock_flags;
int rc;
struct ldlm_res_id res_id;
- ldlm_policy_data_t policy = { .l_inodebits = { MDS_INODELOCK_LOOKUP } };
+ static const ldlm_policy_data_t lookup_policy =
+ { .l_inodebits = { MDS_INODELOCK_LOOKUP } };
+ static const ldlm_policy_data_t update_policy =
+ { .l_inodebits = { MDS_INODELOCK_UPDATE } };
+ ldlm_policy_data_t const *policy = &lookup_policy;
ENTRY;
LASSERTF(!it || einfo->ei_type == LDLM_IBITS, "lock type %d\n",
if (it)
flags |= LDLM_FL_HAS_INTENT;
if (it && it->it_op & (IT_UNLINK | IT_GETATTR | IT_READDIR))
- policy.l_inodebits.bits = MDS_INODELOCK_UPDATE;
+ policy = &update_policy;
if (reqp)
req = *reqp;
LASSERT(lmm && lmmsize == 0);
LASSERTF(einfo->ei_type == LDLM_FLOCK, "lock type %d\n",
einfo->ei_type);
- policy = *(ldlm_policy_data_t *)lmm;
+ policy = (ldlm_policy_data_t *)lmm;
res_id.name[3] = LDLM_FLOCK;
} else if (it->it_op & IT_OPEN) {
req = mdc_intent_open_pack(exp, it, op_data, lmm, lmmsize,
einfo->ei_cbdata);
- policy.l_inodebits.bits = MDS_INODELOCK_UPDATE;
+ policy = &update_policy;
einfo->ei_cbdata = NULL;
lmm = NULL;
} else if (it->it_op & IT_UNLINK)
mdc_get_rpc_lock(obddev->u.cli.cl_rpc_lock, it);
mdc_enter_request(&obddev->u.cli);
}
- rc = ldlm_cli_enqueue(exp, &req, einfo, &res_id, &policy, &flags, NULL,
+
+ rc = ldlm_cli_enqueue(exp, &req, einfo, &res_id, policy, &flags, NULL,
0, lockh, 0);
if (reqp)
*reqp = req;
* cfs_curproc_fs{u,g}id() should replace
* current->fs{u,g}id for portability.
*/
- rec->sx_fsuid = current->fsuid;
- rec->sx_fsgid = current->fsgid;
+ rec->sx_fsuid = cfs_curproc_fsuid();
+ rec->sx_fsgid = cfs_curproc_fsgid();
rec->sx_cap = cfs_curproc_cap_pack();
rec->sx_suppgid1 = suppgid;
rec->sx_suppgid2 = -1;
}
struct proc_dir_entry *lprocfs_add_symlink(const char *name,
- struct proc_dir_entry *parent, const char *dest)
+ struct proc_dir_entry *parent, const char *format, ...)
{
struct proc_dir_entry *entry;
+ char *dest;
+ va_list ap;
- if (parent == NULL || dest == NULL)
+ if (parent == NULL || format == NULL)
return NULL;
+ OBD_ALLOC_WAIT(dest, MAX_STRING_SIZE + 1);
+ if (dest == NULL)
+ return NULL;
+
+ va_start(ap, format);
+ vsnprintf(dest, MAX_STRING_SIZE, format, ap);
+ va_end(ap);
+
entry = proc_symlink(name, parent, dest);
if (entry == NULL)
CERROR("LprocFS: Could not create symbolic link from %s to %s",
name, dest);
+
+ OBD_FREE(dest, MAX_STRING_SIZE + 1);
return entry;
}
remove_dead = 0;
}
} else {
- vcred.vc_uid = cfs_current()->uid;
- vcred.vc_gid = cfs_current()->gid;
+ vcred.vc_uid = cfs_curproc_uid();
+ vcred.vc_gid = cfs_curproc_gid();
}
return sec->ps_policy->sp_cops->lookup_ctx(sec, &vcred,
void sptlrpc_import_flush_my_ctx(struct obd_import *imp)
{
- import_flush_ctx_common(imp, cfs_current()->uid, 1, 1);
+ import_flush_ctx_common(imp, cfs_curproc_uid(), 1, 1);
}
EXPORT_SYMBOL(sptlrpc_import_flush_my_ctx);
pud = lustre_msg_buf(msg, offset, 0);
- pud->pud_uid = cfs_current()->uid;
- pud->pud_gid = cfs_current()->gid;
- pud->pud_fsuid = cfs_current()->fsuid;
- pud->pud_fsgid = cfs_current()->fsgid;
+ pud->pud_uid = cfs_curproc_uid();
+ pud->pud_gid = cfs_curproc_gid();
+ pud->pud_fsuid = cfs_curproc_fsuid();
+ pud->pud_fsgid = cfs_curproc_fsgid();
pud->pud_cap = cfs_curproc_cap_pack();
pud->pud_ngroups = (msg->lm_buflens[offset] - sizeof(*pud)) / 4;
task_lock(current);
if (pud->pud_ngroups > current_ngroups)
pud->pud_ngroups = current_ngroups;
- memcpy(pud->pud_groups, cfs_current()->group_info->blocks[0],
+ memcpy(pud->pud_groups, current_cred()->group_info->blocks[0],
pud->pud_ngroups * sizeof(__u32));
task_unlock(current);
#endif
local command_status="$TMP/cs"
rsh $HOST ":> $command_status"
rsh $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin;
- cd $RPWD; sh -c \"$@\") ||
+ cd $RPWD; LUSTRE=\"$RLUSTRE\" sh -c \"$@\") ||
echo command failed >$command_status"
[ -n "$($myPDSH $HOST cat $command_status)" ] && return 1 || true
return 0
if $verbose ; then
# print HOSTNAME for myPDSH="no_dsh"
if [[ $myPDSH = no_dsh ]]; then
- $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")" | sed -e "s/^/${HOSTNAME}: /"
+ $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; LUSTRE=\"$RLUSTRE\" sh -c \"$@\")" | sed -e "s/^/${HOSTNAME}: /"
else
- $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")"
+ $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; LUSTRE=\"$RLUSTRE\" sh -c \"$@\")"
fi
else
- $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")" | sed "s/^${HOST}: //"
+ $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; LUSTRE=\"$RLUSTRE\" sh -c \"$@\")" | sed "s/^${HOST}: //"
fi
return ${PIPESTATUS[0]}
}
fi
if $verbose ; then
- $myPDSH $rnodes "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")"
+ $myPDSH $rnodes "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; LUSTRE=\"$RLUSTRE\" sh -c \"$@\")"
else
- $myPDSH $rnodes "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")" | sed -re "s/\w+:\s//g"
+ $myPDSH $rnodes "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; LUSTRE=\"$RLUSTRE\" sh -c \"$@\")" | sed -re "s/\w+:\s//g"
fi
return ${PIPESTATUS[0]}
}
shift
# Add paths to lustre tests for 32 and 64 bit systems.
- local RPATH="$LUSTRE/tests:/usr/lib/lustre/tests:/usr/lib64/lustre/tests:$PATH"
- do_nodes --verbose $list "PATH=$RPATH sh rpc.sh $@ "
+ local RPATH="$RLUSTRE/tests:/usr/lib/lustre/tests:/usr/lib64/lustre/tests:$PATH"
+ do_nodes --verbose $list "PATH=$RPATH sh rpc.sh $@ "
}
wait_clients_import_state () {