/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
* vim:expandtab:shiftwidth=8:tabstop=8:
*
- * Lustre Light common routines
+ * Lustre Light Super operations
*
* Copyright (c) 2002, 2003 Cluster File Systems, Inc.
*
#include <stdlib.h>
#include <string.h>
#include <assert.h>
-#include <signal.h>
#include <sys/types.h>
#include <sys/queue.h>
-#include <sys/capability.h>
#include <netinet/in.h>
#include <sys/socket.h>
*/
#undef LIST_HEAD
+#include <portals/api-support.h> /* needed for ptpctl.h */
#include <portals/ptlctl.h> /* needed for parse_dump */
#include <procbridge.h>
struct task_struct *current;
/* portals interfaces */
+ptl_handle_ni_t *
+kportal_get_ni (int nal)
+{
+ switch (nal)
+ {
+ case SOCKNAL:
+ return &tcpnal_ni;
+ default:
+ return NULL;
+ }
+}
+
+inline void
+kportal_put_ni (int nal)
+{
+ return;
+}
struct ldlm_namespace;
struct ldlm_res_id;
case TCPNAL:
/* userspace NAL */
case SOCKNAL:
- snprintf(str, PTL_NALFMT_SIZE - 1, "%u:%u.%u.%u.%u",
- (__u32)(nid >> 32), HIPQUAD(nid));
+ sprintf(str, "%u:%d.%d.%d.%d", (__u32)(nid >> 32),
+ HIPQUAD(nid));
break;
case QSWNAL:
case GMNAL:
case IBNAL:
case SCIMACNAL:
- snprintf(str, PTL_NALFMT_SIZE - 1, "%u:%u",
- (__u32)(nid >> 32), (__u32)nid);
+ sprintf(str, "%u:%u", (__u32)(nid >> 32), (__u32)nid);
break;
default:
- snprintf(str, PTL_NALFMT_SIZE - 1, "?%d? %llx",
- nal, (long long)nid);
- break;
+ return NULL;
}
return str;
}
-int in_group_p(gid_t gid)
-{
- int i;
-
- if (gid == current->fsgid)
- return 1;
-
- for (i = 0; i < current->ngroups; i++) {
- if (gid == current->groups[i])
- return 1;
- }
-
- return 0;
-}
-
-static void init_capability(int *res)
-{
- cap_value_t cap_types[] = {
- CAP_CHOWN,
- CAP_DAC_OVERRIDE,
- CAP_DAC_READ_SEARCH,
- CAP_FOWNER,
- CAP_FSETID,
- CAP_KILL,
- CAP_SETGID,
- CAP_SETUID,
- /* following are linux specific, we could simply
- * remove them I think */
- CAP_SETPCAP,
- CAP_LINUX_IMMUTABLE,
- CAP_NET_BIND_SERVICE,
- CAP_NET_BROADCAST,
- CAP_NET_ADMIN,
- CAP_NET_RAW,
- CAP_IPC_LOCK,
- CAP_IPC_OWNER,
- CAP_SYS_MODULE,
- CAP_SYS_RAWIO,
- CAP_SYS_CHROOT,
- CAP_SYS_PTRACE,
- CAP_SYS_PACCT,
- CAP_SYS_ADMIN,
- CAP_SYS_BOOT,
- CAP_SYS_NICE,
- CAP_SYS_RESOURCE,
- CAP_SYS_TIME,
- CAP_SYS_TTY_CONFIG,
- CAP_MKNOD,
- CAP_LEASE,
- };
- cap_t syscap;
- cap_flag_value_t capval;
- int i;
-
- *res = 0;
-
- syscap = cap_get_proc();
- if (!syscap) {
- printf("Liblustre: Warning: failed to get system capability, "
- "set to minimal\n");
- return;
- }
-
- for (i = 0; i < sizeof(cap_types)/sizeof(cap_t); i++) {
- LASSERT(cap_types[i] < 32);
- if (!cap_get_flag(syscap, cap_types[i],
- CAP_EFFECTIVE, &capval)) {
- if (capval == CAP_SET) {
- *res |= 1 << cap_types[i];
- }
- }
- }
-}
-
-static int init_current(char *comm)
-{
+void init_current(char *comm)
+{
current = malloc(sizeof(*current));
- if (!current) {
- CERROR("Not enough memory\n");
- return -ENOMEM;
- }
- current->fs = ¤t->__fs;
+ current->fs = malloc(sizeof(*current->fs));
current->fs->umask = umask(0777);
umask(current->fs->umask);
-
strncpy(current->comm, comm, sizeof(current->comm));
current->pid = getpid();
- current->fsuid = geteuid();
- current->fsgid = getegid();
+ current->fsuid = 0;
+ current->fsgid = 0;
+ current->cap_effective = -1;
memset(¤t->pending, 0, sizeof(current->pending));
-
- current->max_groups = sysconf(_SC_NGROUPS_MAX);
- current->groups = malloc(sizeof(gid_t) * current->max_groups);
- if (!current->groups) {
- CERROR("Not enough memory\n");
- return -ENOMEM;
- }
- current->ngroups = getgroups(current->max_groups, current->groqps);
- if (current->ngroups < 0) {
- perror("Error getgroups");
- return -EINVAL;
- }
-
- init_capability(¤t->cap_effective);
-
- return 0;
}
/* FIXME */
int rc;
ENTRY;
- rc = PtlInit(&max_interfaces);
- if (rc != PTL_OK) {
- CERROR("PtlInit failed: %d\n", rc);
- RETURN (-ENXIO);
+ PtlInit(&max_interfaces);
+ rc = PtlNIInit(procbridge_interface, 0, 0, 0, &tcpnal_ni);
+ if (rc != 0) {
+ CERROR("TCPNAL: PtlNIInit failed: error %d\n", rc);
+ PtlFini();
+ RETURN (rc);
}
- RETURN(0);
+ PtlNIDebug(tcpnal_ni, ~0);
+ RETURN(rc);
}
int
-libcfs_nal_cmd(struct portals_cfg *pcfg)
+kportal_nal_cmd(struct portals_cfg *pcfg)
{
/* handle portals command if we want */
return 0;
extern int class_handle_ioctl(unsigned int cmd, unsigned long arg);
-int lib_ioctl_nalcmd(int dev_id, unsigned int opc, void * ptr)
+int lib_ioctl_nalcmd(int dev_id, int opc, void * ptr)
{
struct portal_ioctl_data *ptldata;
return (0);
}
-int lib_ioctl(int dev_id, unsigned int opc, void * ptr)
+int lib_ioctl(int dev_id, int opc, void * ptr)
{
int rc;
printf("LibLustre: TCPNAL NID: %016llx\n", tcpnal_mynid);
}
- if (init_current("dummy") ||
- init_obdclass() ||
+ init_current("dummy");
+ if (init_obdclass() ||
init_lib_portals() ||
ptlrpc_init() ||
+ ldlm_init() ||
mdc_init() ||
lov_init() ||
osc_init())
CERROR("Can't parse NID %s\n", g_zconf_mdsnid);
RETURN(-EINVAL);
}
-
nal = ptl_name2nal("tcp");
if (nal <= 0) {
CERROR("Can't parse NAL tcp\n");
RETURN(rc);
}
+static void sighandler_USR1(int signum)
+{
+ /* do nothing */
+}
+
/* parse host:/mdsname/profile string */
int ll_parse_mount_target(const char *target, char **mdsnid,
char **mdsname, char **profile)
*/
srand(time(NULL) + getpid());
+ signal(SIGUSR1, sighandler_USR1);
+
lustre_path = getenv(ENV_LUSTRE_MNTPNT);
if (!lustre_path) {
lustre_path = "/mnt/lustre";