libcfs_string.h \
libcfs_time.h \
libcfs_workitem.h \
- libcfsutil.h \
list.h \
types.h \
user-bitops.h \
#include <libcfs/libcfs_private.h>
#include <libcfs/bitmap.h>
#include <libcfs/libcfs_cpu.h>
-#include <libcfs/libcfs_ioctl.h>
+#ifdef __KERNEL__
+# include <libcfs/libcfs_ioctl.h>
+#endif /* __KERNEL__ */
#include <libcfs/libcfs_prim.h>
#include <libcfs/libcfs_time.h>
#ifdef __KERNEL__
#define _LIBCFS_H
-int libcfs_arch_init(void);
-void libcfs_arch_cleanup(void);
-
#endif /* _LIBCFS_H */
* libcfs/include/libcfs/libcfs_ioctl.h
*
* Low-level ioctl data structures. Kernel ioctl functions declared here,
- * and user space functions are in libcfsutil_ioctl.h.
+ * and user space functions are in libcfs/util/ioctl.h.
*
*/
(data).hdr.ioc_len = sizeof(data); \
} while (0)
-
-#ifdef __KERNEL__
-
-struct libcfs_ioctl_handler {
- struct list_head item;
- int (*handle_ioctl)(unsigned int cmd, struct libcfs_ioctl_hdr *hdr);
-};
-
-#define DECLARE_IOCTL_HANDLER(ident, func) \
- static struct libcfs_ioctl_handler ident = { \
- /* .item = */ LIST_HEAD_INIT(ident.item), \
- /* .handle_ioctl = */ func \
- }
-
-#endif
-
/* 'f' ioctls are defined in lustre_ioctl.h and lustre_user.h except for: */
#define LIBCFS_IOC_DEBUG_MASK _IOWR('f', 250, long)
#define IOCTL_LIBCFS_TYPE long
static inline int libcfs_ioctl_packlen(struct libcfs_ioctl_data *data)
{
int len = sizeof(*data);
- len += cfs_size_round(data->ioc_inllen1);
- len += cfs_size_round(data->ioc_inllen2);
+ len += (data->ioc_inllen1 + 7) & ~7;
+ len += (data->ioc_inllen2 + 7) & ~7;
return len;
}
static inline bool libcfs_ioctl_is_invalid(struct libcfs_ioctl_data *data)
{
- if (data->ioc_hdr.ioc_len > (1<<30)) {
- CERROR("LIBCFS ioctl: ioc_len larger than 1<<30\n");
+ if (data->ioc_hdr.ioc_len > (1<<30))
return 1;
- }
- if (data->ioc_inllen1 > (1<<30)) {
- CERROR("LIBCFS ioctl: ioc_inllen1 larger than 1<<30\n");
+
+ if (data->ioc_inllen1 > (1<<30))
return 1;
- }
- if (data->ioc_inllen2 > (1<<30)) {
- CERROR("LIBCFS ioctl: ioc_inllen2 larger than 1<<30\n");
+
+ if (data->ioc_inllen2 > (1<<30))
return 1;
- }
- if (data->ioc_inlbuf1 && data->ioc_inllen1 == 0) {
- CERROR("LIBCFS ioctl: inlbuf1 pointer but 0 length\n");
+
+ if (data->ioc_inlbuf1 && data->ioc_inllen1 == 0)
return 1;
- }
- if (data->ioc_inlbuf2 && data->ioc_inllen2 == 0) {
- CERROR("LIBCFS ioctl: inlbuf2 pointer but 0 length\n");
+
+ if (data->ioc_inlbuf2 && data->ioc_inllen2 == 0)
return 1;
- }
- if (data->ioc_pbuf1 && data->ioc_plen1 == 0) {
- CERROR("LIBCFS ioctl: pbuf1 pointer but 0 length\n");
+
+ if (data->ioc_pbuf1 && data->ioc_plen1 == 0)
return 1;
- }
- if (data->ioc_pbuf2 && data->ioc_plen2 == 0) {
- CERROR("LIBCFS ioctl: pbuf2 pointer but 0 length\n");
+
+ if (data->ioc_pbuf2 && data->ioc_plen2 == 0)
return 1;
- }
- if (data->ioc_plen1 && data->ioc_pbuf1 == NULL) {
- CERROR("LIBCFS ioctl: plen1 nonzero but no pbuf1 pointer\n");
+
+ if (data->ioc_plen1 && data->ioc_pbuf1 == NULL)
return 1;
- }
- if (data->ioc_plen2 && data->ioc_pbuf2 == NULL) {
- CERROR("LIBCFS ioctl: plen2 nonzero but no pbuf2 pointer\n");
+
+ if (data->ioc_plen2 && data->ioc_pbuf2 == NULL)
return 1;
- }
- if ((__u32)libcfs_ioctl_packlen(data) != data->ioc_hdr.ioc_len) {
- CERROR("LIBCFS ioctl: packlen != ioc_len\n");
+
+ if ((__u32)libcfs_ioctl_packlen(data) != data->ioc_hdr.ioc_len)
return 1;
- }
+
if (data->ioc_inllen1 &&
- data->ioc_bulk[data->ioc_inllen1 - 1] != '\0') {
- CERROR("LIBCFS ioctl: inlbuf1 not 0 terminated\n");
+ data->ioc_bulk[data->ioc_inllen1 - 1] != '\0')
return 1;
- }
+
if (data->ioc_inllen2 &&
- data->ioc_bulk[cfs_size_round(data->ioc_inllen1) +
- data->ioc_inllen2 - 1] != '\0') {
- CERROR("LIBCFS ioctl: inlbuf2 not 0 terminated\n");
+ data->ioc_bulk[((data->ioc_inllen1 + 7) & ~7) +
+ data->ioc_inllen2 - 1] != '\0')
return 1;
- }
- return 0;
-}
-
-#ifdef __KERNEL__
-
-extern int libcfs_register_ioctl(struct libcfs_ioctl_handler *hand);
-extern int libcfs_deregister_ioctl(struct libcfs_ioctl_handler *hand);
-extern int libcfs_ioctl_getdata(struct libcfs_ioctl_hdr **hdr_pp,
- struct libcfs_ioctl_hdr __user *uparam);
-static inline int libcfs_ioctl_popdata(struct libcfs_ioctl_hdr *hdr,
- struct libcfs_ioctl_hdr __user *uparam)
-{
- if (copy_to_user(uparam, hdr, hdr->ioc_len))
- return -EFAULT;
- return 0;
-}
-
-static inline void libcfs_ioctl_freedata(struct libcfs_ioctl_hdr *hdr)
-{
- LIBCFS_FREE(hdr, hdr->ioc_len);
+ return 0;
}
-#endif
-
extern int libcfs_ioctl_data_adjust(struct libcfs_ioctl_data *data);
#endif /* __LIBCFS_IOCTL_H__ */
ptr += cfs_size_round(len); \
} while (0)
-/**
- * Lustre Network Driver types.
- */
-enum {
- /* Only add to these values (i.e. don't ever change or redefine them):
- * network addresses depend on them... */
- QSWLND = 1,
- SOCKLND = 2,
- GMLND = 3, /* obsolete, keep it so that libcfs_nid2str works */
- PTLLND = 4,
- O2IBLND = 5,
- CIBLND = 6,
- OPENIBLND = 7,
- IIBLND = 8,
- LOLND = 9,
- RALND = 10,
- VIBLND = 11,
- MXLND = 12,
- GNILND = 13,
- GNIIPLND = 14,
-};
-
extern struct cfs_psdev_ops libcfs_psdev_ops;
extern struct miscdevice libcfs_dev;
extern struct cfs_wi_sched *cfs_sched_rehash;
+++ /dev/null
-/*
- * GPL HEADER START
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 only,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License version 2 for more details (a copy is included
- * in the LICENSE file that accompanied this code).
- *
- * 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.
- *
- * GPL HEADER END
- */
-/*
- * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
- * Use is subject to license terms.
- */
-/*
- * This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
- *
- * libcfs/include/libcfs/libcfsutil.h
- *
- * A library used for userspace utilities.
- *
- */
-
-#ifndef __LIBCFSUTIL_H__
-#define __LIBCFSUTIL_H__
-
-#ifndef LUSTRE_UTILS
-#define LUSTRE_UTILS 1
-#endif
-
-#include <libcfs/libcfs.h>
-
-#include <libcfs/util/platform.h>
-#include <libcfs/util/parser.h>
-#include <libcfs/util/libcfsutil_ioctl.h>
-
-/*
- * Defined by libcfs/libcfs/util/util.c
- */
-int libcfs_tcd_type_max(void);
-
-#endif /* __LIBCFSUTIL_H__ */
#ifndef __KERNEL__
# include <limits.h> /* LONG_MAX */
# include <stdbool.h> /* bool */
+# include <stddef.h> /* size_t */
#endif /* !__KERNEL__ */
#if defined(_ASM_GENERIC_INT_L64_H)
#define get_random_bytes(val, size) (*val) = 0
-/* utility libcfs init/fini entries */
-static inline int libcfs_arch_init(void) {
- return 0;
-}
-static inline void libcfs_arch_cleanup(void) {
-}
-
#endif /* __LIBCFS_USER_PRIM_H__ */
-EXTRA_DIST = parser.h platform.h string.h libcfsutil_ioctl.h
+EXTRA_DIST = ioctl.h parser.h string.h
* This file is part of Lustre, http://www.lustre.org/
* Lustre is a trademark of Sun Microsystems, Inc.
*
- * libcfs/include/libcfs/util/libcfsutil_ioctl.h
+ * libcfs/include/libcfs/util/ioctl.h
*
* Utility functions for calling ioctls.
*
*/
+#ifndef _LIBCFS_IOCTL_H_
+#define _LIBCFS_IOCTL_H_
-/* FIXME - rename these to libcfs_ */
+#include <stdbool.h>
+#include <linux/types.h>
+
+/* Sparse annotation. */
+#define __user
+#include <libcfs/libcfs_ioctl.h>
+
+/* FIXME - rename these to libcfs_ */
int libcfs_ioctl_pack(struct libcfs_ioctl_data *data, char **pbuf, int max);
void libcfs_ioctl_unpack(struct libcfs_ioctl_data *data, char *pbuf);
-typedef int (ioc_handler_t)(int dev_id, unsigned int opc, void *buf);
-void set_ioc_handler(ioc_handler_t *handler);
-int register_ioc_dev(int dev_id, const char * dev_name, int major, int minor);
+int register_ioc_dev(int dev_id, const char *dev_name, int major, int minor);
void unregister_ioc_dev(int dev_id);
-int set_ioctl_dump(char * file);
int l_ioctl(int dev_id, unsigned int opc, void *buf);
-int parse_dump(char * dump_file, ioc_handler_t ioc_func);
-int jt_ioc_dump(int argc, char **argv);
-extern char *dump_filename;
-int dump(int dev_id, unsigned int opc, void *buf);
+#endif
+++ /dev/null
-/*
- * GPL HEADER START
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 only,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License version 2 for more details (a copy is included
- * in the LICENSE file that accompanied this code).
- *
- * 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.
- *
- * GPL HEADER END
- */
-/*
- * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
- * Use is subject to license terms.
- */
-/*
- * This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
- *
- * libcfs/include/libcfs/libcfsutil.h
- *
- * A portability layer for multi-threaded userspace applications.
- *
- */
-
-#ifndef __LUSTRE_UTILS_PLATFORM_H
-#define __LUSTRE_UTILS_PLATFORM_H
-
-
-#ifdef HAVE_LIBREADLINE
-#define READLINE_LIBRARY
-#include <readline/readline.h>
-
-/* completion_matches() is #if 0-ed out in modern glibc */
-
-#ifndef completion_matches
-# define completion_matches rl_completion_matches
-#endif
-extern void using_history(void);
-extern void stifle_history(int);
-extern void add_history(char *);
-#endif /* HAVE_LIBREADLINE */
-
-#include <errno.h>
-#include <string.h>
-#if HAVE_LIBPTHREAD
-#include <sys/ipc.h>
-#include <sys/shm.h>
-#include <pthread.h>
-
-typedef pthread_mutex_t l_mutex_t;
-typedef pthread_cond_t l_cond_t;
-#define l_mutex_init(s) pthread_mutex_init(s, NULL)
-#define l_mutex_lock(s) pthread_mutex_lock(s)
-#define l_mutex_unlock(s) pthread_mutex_unlock(s)
-#define l_cond_init(c) pthread_cond_init(c, NULL)
-#define l_cond_broadcast(c) pthread_cond_broadcast(c)
-#define l_cond_wait(c, s) pthread_cond_wait(c, s)
-#endif
-
-
-#endif
if UTILS
lib_LIBRARIES = libcfsutil.a
-libcfsutil_a_SOURCES = util/parser.c util/l_ioctl.c util/util.c
+libcfsutil_a_SOURCES = util/parser.c util/l_ioctl.c
libcfsutil_a_CPPFLAGS = $(LLCPPFLAGS)
libcfsutil_a_CFLAGS = $(LLCFLAGS) -DLUSTRE_UTILS=1
endif
RETURN(0);
failed:
- libcfs_ioctl_freedata(*hdr_pp);
+ LIBCFS_FREE(*hdr_pp, hdr.ioc_len);
RETURN(err);
}
spin_unlock_irqrestore(¤t->sighand->siglock, flags);
}
-int
-libcfs_arch_init(void)
-{
- return 0;
-}
-
-void
-libcfs_arch_cleanup(void)
-{
- return;
-}
-
-EXPORT_SYMBOL(libcfs_arch_init);
-EXPORT_SYMBOL(libcfs_arch_cleanup);
EXPORT_SYMBOL(cfs_enter_debugger);
EXPORT_SYMBOL(cfs_block_allsigs);
EXPORT_SYMBOL(cfs_block_sigs);
if (err == -EINVAL)
continue;
- if (err == 0)
- err = libcfs_ioctl_popdata(hdr, uparam);
+ if (err == 0) {
+ if (copy_to_user(uparam, hdr, hdr->ioc_len))
+ err = -EFAULT;
+ }
break;
}
up_read(&ioctl_list_sem);
break; }
}
out:
- libcfs_ioctl_freedata(hdr);
+ LIBCFS_FREE(hdr, hdr->ioc_len);
RETURN(err);
}
{
int rc;
- libcfs_arch_init();
-
rc = libcfs_debug_init(5 * 1024 * 1024);
if (rc < 0) {
printk(KERN_ERR "LustreError: libcfs_debug_init: %d\n", rc);
if (rc)
printk(KERN_ERR "LustreError: libcfs_debug_cleanup: %d\n",
rc);
-
- libcfs_arch_cleanup();
}
cfs_module(libcfs, "1.0.0", init_libcfs_module, exit_libcfs_module);
-EXTRA_DIST = parser.c l_ioctl.c nidstrings.c string.c util.c
+EXTRA_DIST = parser.c l_ioctl.c nidstrings.c string.c
#define __USE_FILE_OFFSET64
+#include <errno.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
-#include <libcfs/libcfsutil.h>
-#include <lnet/lnetctl.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <linux/types.h>
-static ioc_handler_t do_ioctl; /* forward ref */
-static ioc_handler_t *current_ioc_handler = &do_ioctl;
+#include <libcfs/util/ioctl.h>
+#include <lnet/lnetctl.h>
struct ioc_dev {
const char * dev_name;
unsigned int opc;
};
-char *dump_filename;
-
-void
-set_ioc_handler (ioc_handler_t *handler)
-{
- if (handler == NULL)
- current_ioc_handler = do_ioctl;
- else
- current_ioc_handler = handler;
-}
-
/* Catamount has no <linux/kdev_t.h>, so just define it here */
#ifndef MKDEV
# define MKDEV(a,b) (((a) << 8) | (b))
#endif
static int
-open_ioc_dev(int dev_id)
+open_ioc_dev(int dev_id)
{
const char * dev_name;
- if (dev_id < 0 ||
+ if (dev_id < 0 ||
dev_id >= sizeof(ioc_dev_list) / sizeof(ioc_dev_list[0]))
return -EINVAL;
}
-static int
-do_ioctl(int dev_id, unsigned int opc, void *buf)
+int l_ioctl(int dev_id, unsigned int opc, void *buf)
{
int fd, rc;
-
+
fd = open_ioc_dev(dev_id);
- if (fd < 0)
+ if (fd < 0)
return fd;
rc = ioctl(fd, opc, buf);
return rc;
}
-static FILE *
-get_dump_file()
-{
- FILE *fp = NULL;
-
- if (!dump_filename) {
- fprintf(stderr, "no dump filename\n");
- } else
- fp = fopen(dump_filename, "a");
- return fp;
-}
-
-/*
- * The dump file should start with a description of which devices are
- * used, but for now it will assume whatever app reads the file will
- * know what to do. */
-int
-dump(int dev_id, unsigned int opc, void *buf)
-{
- FILE *fp;
- struct dump_hdr dump_hdr;
- struct libcfs_ioctl_hdr * ioc_hdr = (struct libcfs_ioctl_hdr *) buf;
- int rc;
-
- printf("dumping opc %x to %s\n", opc, dump_filename);
-
-
- dump_hdr.magic = 0xdeadbeef;
- dump_hdr.dev_id = dev_id;
- dump_hdr.opc = opc;
-
- fp = get_dump_file();
- if (fp == NULL) {
- fprintf(stderr, "%s: %s\n", dump_filename,
- strerror(errno));
- return -EINVAL;
- }
-
- rc = fwrite(&dump_hdr, sizeof(dump_hdr), 1, fp);
- if (rc == 1)
- rc = fwrite(buf, ioc_hdr->ioc_len, 1, fp);
- fclose(fp);
- if (rc != 1) {
- fprintf(stderr, "%s: %s\n", dump_filename,
- strerror(errno));
- return -EINVAL;
- }
-
- return 0;
-}
-
/* register a device to send ioctls to. */
-int
-register_ioc_dev(int dev_id, const char * dev_name, int major, int minor)
+int
+register_ioc_dev(int dev_id, const char *dev_name, int major, int minor)
{
- if (dev_id < 0 ||
+ if (dev_id < 0 ||
dev_id >= sizeof(ioc_dev_list) / sizeof(ioc_dev_list[0]))
return -EINVAL;
ioc_dev_list[dev_id].dev_fd = -1;
ioc_dev_list[dev_id].dev_major = major;
ioc_dev_list[dev_id].dev_minor = minor;
-
+
return dev_id;
}
void
-unregister_ioc_dev(int dev_id)
+unregister_ioc_dev(int dev_id)
{
if (dev_id < 0 ||
dev_id >= sizeof(ioc_dev_list) / sizeof(ioc_dev_list[0]))
ioc_dev_list[dev_id].dev_fd = -1;
}
-/* If this file is set, then all ioctl buffers will be
- appended to the file. */
-int
-set_ioctl_dump(char * file)
-{
- if (dump_filename)
- free(dump_filename);
-
- dump_filename = strdup(file);
- if (dump_filename == NULL)
- abort();
-
- set_ioc_handler(&dump);
- return 0;
-}
-
-int
-l_ioctl(int dev_id, unsigned int opc, void *buf)
-{
- return current_ioc_handler(dev_id, opc, buf);
-}
-
-/* Read an ioctl dump file, and call the ioc_func for each ioctl buffer
- * in the file. For example:
- *
- * parse_dump("lctl.dump", l_ioctl);
- *
- * Note: if using l_ioctl, then you also need to register_ioc_dev() for
- * each device used in the dump.
- */
-int
-parse_dump(char * dump_file, ioc_handler_t ioc_func)
-{
- int line =0;
- char *start, *buf, *end;
- struct stat st;
- int fd;
-
- fd = open(dump_file, O_RDONLY);
- if (fd < 0) {
- fprintf(stderr, "couldn't open %s: %s\n", dump_file,
- strerror(errno));
- exit(1);
- }
-
- if (fstat(fd, &st)) {
- perror("stat fails");
- exit(1);
- }
-
- if (st.st_size < 1) {
- fprintf(stderr, "KML is empty\n");
- exit(1);
- }
-
- start = buf = mmap(NULL, st.st_size, PROT_READ, MAP_PRIVATE , fd, 0);
- end = start + st.st_size;
- close(fd);
- if (start == MAP_FAILED) {
- fprintf(stderr, "can't create file mapping\n");
- exit(1);
- }
-
- while (buf < end) {
- struct dump_hdr *dump_hdr = (struct dump_hdr *) buf;
- struct libcfs_ioctl_hdr * data;
- char tmp[8096];
- int rc;
-
- line++;
-
- data = (struct libcfs_ioctl_hdr *) (buf + sizeof(*dump_hdr));
- if (buf + data->ioc_len > end ) {
- fprintf(stderr, "dump file overflow, %p + %d > %p\n", buf,
- data->ioc_len, end);
- return -1;
- }
-#if 0
- printf ("dump_hdr: %lx data: %lx\n",
- (unsigned long)dump_hdr - (unsigned long)buf, (unsigned long)data - (unsigned long)buf);
-
- printf("%d: opcode %x len: %d ver: %x ", line, dump_hdr->opc,
- data->ioc_len, data->ioc_version);
-#endif
-
- memcpy(tmp, data, data->ioc_len);
-
- rc = ioc_func(dump_hdr->dev_id, dump_hdr->opc, tmp);
- if (rc) {
- printf("failed: %d\n", rc);
- exit(1);
- }
-
- buf += data->ioc_len + sizeof(*dump_hdr);
- }
-
- munmap(start, end - start);
-
- return 0;
-}
-
-int
-jt_ioc_dump(int argc, char **argv)
-{
- if (argc > 2) {
- fprintf(stderr, "usage: %s [hostname]\n", argv[0]);
- return 0;
- }
- printf("setting dumpfile to: %s\n", argv[1]);
-
- set_ioctl_dump(argv[1]);
- return 0;
-}
-
int libcfs_ioctl_pack(struct libcfs_ioctl_data *data, char **pbuf,
int max)
{
memcpy(*pbuf, data, sizeof(*data));
ptr = overlay->ioc_bulk;
- if (data->ioc_inlbuf1 != NULL)
- LOGL(data->ioc_inlbuf1, data->ioc_inllen1, ptr);
- if (data->ioc_inlbuf2 != NULL)
- LOGL(data->ioc_inlbuf2, data->ioc_inllen2, ptr);
+ if (data->ioc_inlbuf1 != NULL) {
+ memcpy((char *)ptr, (const char *)data->ioc_inlbuf1,
+ data->ioc_inllen1);
+ ptr += ((data->ioc_inllen1 + 7) & ~7);
+ }
+ if (data->ioc_inlbuf2 != NULL) {
+ memcpy((char *)ptr, (const char *)data->ioc_inlbuf2,
+ data->ioc_inllen2);
+ ptr += ((data->ioc_inllen2 + 7) & ~7);
+ }
+
if (libcfs_ioctl_is_invalid(overlay))
return 1;
memcpy(data, pbuf, sizeof(*data));
ptr = &overlay->ioc_bulk[0];
- if (data->ioc_inlbuf1 != NULL)
- LOGU(data->ioc_inlbuf1, data->ioc_inllen1, ptr);
- if (data->ioc_inlbuf2 != NULL)
- LOGU(data->ioc_inlbuf2, data->ioc_inllen2, ptr);
+ if (data->ioc_inlbuf1 != NULL) {
+ memcpy((char *)data->ioc_inlbuf1, (const char *)ptr,
+ data->ioc_inllen1);
+ ptr += ((data->ioc_inllen1 + 7) & ~7);
+ }
+ if (data->ioc_inlbuf2 != NULL) {
+ memcpy((char *)data->ioc_inlbuf2, (const char *)ptr,
+ data->ioc_inllen2);
+ ptr += ((data->ioc_inllen2 + 7) & ~7);
+ }
}
#define DEBUG_SUBSYSTEM S_LNET
+#include <assert.h>
+#include <errno.h>
+#include <stdio.h>
+#include <stdbool.h>
+#include <stdlib.h>
+#include <string.h>
+
#include <libcfs/util/string.h>
-#include <libcfs/libcfs.h>
+#include <lnet/types.h>
#include <lnet/nidstr.h>
#ifdef HAVE_GETHOSTBYNAME
# include <netdb.h>
sep = str + strlen(str);
net = LNET_MKNET(SOCKLND, 0);
nf = libcfs_lnd2netstrfns(SOCKLND);
- LASSERT(nf != NULL);
+ assert(nf != NULL);
}
if (!nf->nf_str2addr(str, (int)(sep - str), &addr))
return 1;
failed:
- CWARN("can't parse nidrange: \"%.*s\"\n", tmp.ls_len, tmp.ls_str);
+ fprintf(stderr, "can't parse nidrange: \"%.*s\"\n",
+ tmp.ls_len, tmp.ls_str);
return 0;
}
{
struct cfs_expr_list *el;
- LASSERT(!list_empty(numaddr));
+ assert(!list_empty(numaddr));
el = list_entry(numaddr->next, struct cfs_expr_list, el_link);
return cfs_expr_list_match(addr, el);
static int
libcfs_num_addr_range_print(char *buffer, int count, struct list_head *list)
{
- int i = 0, j = 0;
struct cfs_expr_list *el;
+ int i = 0, j = 0;
list_for_each_entry(el, list, el_link) {
- LASSERT(j++ < 1);
+ assert(j++ < 1);
i += cfs_expr_list_print(buffer + i, count - i, el);
}
return i;
struct cfs_expr_list *el;
list_for_each_entry(el, list, el_link) {
- LASSERT(j++ < 4);
+ assert(j++ < 4);
if (i != 0)
i += snprintf(buffer + i, count - i, ".");
i += cfs_expr_list_print(buffer + i, count - i, el);
i += snprintf(buffer + i, count - i, " ");
if (nr->nr_all != 0) {
- LASSERT(list_empty(&nr->nr_addrranges));
+ assert(list_empty(&nr->nr_addrranges));
i += snprintf(buffer + i, count - i, "*");
i += cfs_print_network(buffer + i, count - i, nr);
} else {
*
*/
+#include <stddef.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <assert.h>
+#include <ctype.h>
+#include <errno.h>
+#include <getopt.h>
+#include <malloc.h>
+#ifdef HAVE_LIBREADLINE
+# include <readline/history.h>
+# include <readline/readline.h>
+#endif /* HAVE_LIBREADLINE */
+#include <string.h>
+#include <unistd.h>
+
+#include <libcfs/util/parser.h>
#include <lustre_ver.h>
-#include <libcfs/libcfsutil.h>
static command_t * top_level; /* Top level of commands, initialized by
* InitParser */
if (*(pos - 1) == ' ') match_tbl = table->pc_sub_cmd;
}
- return completion_matches(text, command_generator);
+ return rl_completion_matches(text, command_generator);
}
#endif
+++ /dev/null
-/*
- * GPL HEADER START
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 only,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License version 2 for more details (a copy is included
- * in the LICENSE file that accompanied this code).
- *
- * 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.
- *
- * GPL HEADER END
- */
-/*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
- * Use is subject to license terms.
- */
-/*
- * This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
- *
- * libcfs/libcfs/util/util.c
- *
- */
-
-#include <libcfs/libcfsutil.h>
-#include "../tracefile.h"
-
-int
-libcfs_tcd_type_max(void)
-{
- return CFS_TCD_TYPE_MAX;
-}
struct lnet_ioctl_net_config *net_config);
int lnet_get_rtr_pool_cfg(int idx, struct lnet_ioctl_pool_cfg *pool_cfg);
+struct libcfs_ioctl_handler {
+ struct list_head item;
+ int (*handle_ioctl)(unsigned int cmd, struct libcfs_ioctl_hdr *hdr);
+};
+
+#define DECLARE_IOCTL_HANDLER(ident, func) \
+ static struct libcfs_ioctl_handler ident = { \
+ /* .item = */ LIST_HEAD_INIT(ident.item), \
+ /* .handle_ioctl = */ func \
+ }
+
+extern int libcfs_register_ioctl(struct libcfs_ioctl_handler *hand);
+extern int libcfs_deregister_ioctl(struct libcfs_ioctl_handler *hand);
+extern int libcfs_ioctl_getdata(struct libcfs_ioctl_hdr **hdr_pp,
+ struct libcfs_ioctl_hdr __user *uparam);
+
void lnet_proc_init(void);
void lnet_proc_fini(void);
int lnet_rtrpools_alloc(int im_a_router);
#define _LNET_NIDSTRINGS_H
#include <lnet/types.h>
+/**
+ * Lustre Network Driver types.
+ */
+enum {
+ /* Only add to these values (i.e. don't ever change or redefine them):
+ * network addresses depend on them... */
+ QSWLND = 1,
+ SOCKLND = 2,
+ GMLND = 3,
+ PTLLND = 4,
+ O2IBLND = 5,
+ CIBLND = 6,
+ OPENIBLND = 7,
+ IIBLND = 8,
+ LOLND = 9,
+ RALND = 10,
+ VIBLND = 11,
+ MXLND = 12,
+ GNILND = 13,
+ GNIIPLND = 14,
+};
+
struct list_head;
#define LNET_NIDSTR_COUNT 1024 /* # of nidstrings */
#define _GNU_SOURCE
#endif
-#include <libcfs/libcfsutil.h>
+#include <libcfs/libcfs.h>
+#include <libcfs/util/ioctl.h>
#include <lnet/lnetctl.h>
static char rawbuf[8192];
static void applymask_all(unsigned int subs_mask, unsigned int debug_mask)
{
- if (!dump_filename) {
- applymask(SUBSYS_DEBUG_CTL_NAME, subs_mask);
- applymask(DEBUG_CTL_NAME, debug_mask);
- } else {
- struct libcfs_debug_ioctl_data data;
-
- data.hdr.ioc_len = sizeof(data);
- data.hdr.ioc_version = 0;
- data.subs = subs_mask;
- data.debug = debug_mask;
-
- dump(OBD_DEV_ID, LIBCFS_IOC_DEBUG_MASK, &data);
- }
+ applymask(SUBSYS_DEBUG_CTL_NAME, subs_mask);
+ applymask(DEBUG_CTL_NAME, debug_mask);
printf("Applied subsystem_debug=%d, debug=%d to /proc/sys/lnet\n",
subs_mask, debug_mask);
}
goto readhdr;
if (hdr->ph_len > 4094 || /* is this header bogus? */
- hdr->ph_type >= libcfs_tcd_type_max() ||
hdr->ph_stack > 65536 ||
hdr->ph_sec < (1 << 30) ||
hdr->ph_usec > 1000000000 ||
* calls the APIs mentioned in 1
*/
+#include <errno.h>
+#include <limits.h>
+#include <netdb.h>
#include <stdio.h>
#include <stdlib.h>
-#include <libcfs/libcfsutil.h>
+#include <string.h>
+#include <sys/ioctl.h>
+#include <libcfs/util/ioctl.h>
#include <lnet/lnetctl.h>
#include <lnet/socklnd.h>
#include <lnet/lnet.h>
* Author:
* Amir Shehata <amir.shehata@intel.com>
*/
-
+#include <getopt.h>
#include <stdio.h>
#include <stdlib.h>
-#include <getopt.h>
+#include <string.h>
+#include <libcfs/util/parser.h>
#include <lnet/lnetctl.h>
-#include <libcfs/libcfsutil.h>
#include "cyaml/cyaml.h"
#include "lnetconfig/liblnetconfig.h"
return rc;
}
- rc = libcfs_arch_init();
- if (rc < 0) {
- cYAML_build_error(-1, -1, "lnetctl", "startup",
- "cannot initialize libcfs", &err_rc);
- cYAML_print_tree2file(stderr, err_rc);
- return rc;
- }
-
Parser_init("lnetctl > ", list);
if (argc > 1) {
rc = Parser_execarg(argc - 1, &argv[1], list);
Parser_commands();
errorout:
- libcfs_arch_cleanup();
return rc;
}
*
* Author: Liang Zhen <liangzhen@clusterfs.com>
*/
-
+#include <errno.h>
#include <getopt.h>
#include <pwd.h>
#include <unistd.h>
-
-#include <libcfs/libcfsutil.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/ioctl.h>
+#include <time.h>
+
+#include <libcfs/list.h>
+#include <libcfs/util/ioctl.h>
+#include <libcfs/util/parser.h>
#include <lnet/lnetctl.h>
#include <lnet/lnetst.h>
#include <lnet/lnet.h>
setlinebuf(stdout);
- rc = libcfs_arch_init();
- if (rc < 0)
- return rc;
-
rc = lst_initialize();
if (rc < 0)
goto errorout;
rc = ptl_initialize(argc, argv);
if (rc < 0)
goto errorout;
-
+
Parser_init("lst > ", lst_cmdlist);
if (argc != 1) {
Parser_commands();
errorout:
- libcfs_arch_cleanup();
return rc;
}
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
*/
-
-#include <libcfs/libcfsutil.h>
+#include <errno.h>
+#include <getopt.h>
+#include <limits.h>
+#include <netdb.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/ioctl.h>
+#include <sys/time.h>
+#include <time.h>
+#include <linux/types.h>
+#include <libcfs/libcfs.h>
+#include <libcfs/util/string.h>
+#include <libcfs/util/ioctl.h>
#include <lnet/lnetctl.h>
#include <lnet/socklnd.h>
#include <lnet/lnet.h>
-#include <getopt.h>
-#include <netdb.h>
unsigned int libcfs_debug;
unsigned int libcfs_printk = D_CANTMASK;
#include <stdlib.h>
#include <stdio.h>
+#include <libcfs/util/parser.h>
#include <lnet/lnetctl.h>
#include "obdctl.h"
-#include <libcfs/libcfsutil.h>
#include <lustre/lustre_idl.h>
static int jt_noop(int argc, char **argv) {
#endif
#include <libcfs/libcfs.h>
-#include <libcfs/libcfsutil.h>
+#include <libcfs/util/ioctl.h>
+#include <libcfs/util/parser.h>
#include <lustre/lustreapi.h>
#include <lustre_ver.h>
#include <glob.h>
#include <libcfs/libcfs.h>
+#include <libcfs/util/parser.h>
#include <lnet/nidstr.h>
#include <lustre_cfg.h>
#include <lustre/lustre_idl.h>
#include "obdctl.h"
#include <lnet/lnetctl.h>
-#include <libcfs/libcfsutil.h>
#include <stdio.h>
static char * lcfg_devname;
#include "obdctl.h"
#include <lustre/lustre_lfsck_user.h>
-#include <libcfs/libcfsutil.h>
#include <lnet/lnetctl.h>
#include <lustre_ioctl.h>
+/* Needs to be last to avoid clashes */
+#include <libcfs/util/ioctl.h>
static struct option long_opt_start[] = {
{"device", required_argument, 0, 'M'},
#include <utime.h>
#include <sys/xattr.h>
-#include <libcfs/libcfsutil.h>
+#include <libcfs/util/parser.h>
#include <lustre/lustreapi.h>
#include <lustre/lustre_idl.h>
#include "lustre_rsync.h"
#include "obdctl.h"
#include <libcfs/libcfs.h>
+#include <libcfs/util/ioctl.h>
+#include <libcfs/util/parser.h>
+
#include <lnet/nidstr.h>
#include <lustre/lustre_idl.h>
#include <lustre_cfg.h>
#include <lustre/lustre_build_version.h>
#include <lnet/lnetctl.h>
-#include <libcfs/libcfsutil.h>
#include <lustre/lustreapi.h>
#define MAX_STRING_SIZE 128
#define MAX_BASE_ID 0xffffffff
#define NIDSTRING_LENGTH 64
struct shared_data {
- l_mutex_t mutex;
- l_cond_t cond;
+ pthread_mutex_t mutex;
+ pthread_cond_t cond;
int stopping;
struct {
__u64 counters[MAX_THREADS];
static inline void shmem_lock(void)
{
- l_mutex_lock(&shared_data->mutex);
+ pthread_mutex_lock(&shared_data->mutex);
}
static inline void shmem_unlock(void)
{
- l_mutex_unlock(&shared_data->mutex);
+ pthread_mutex_unlock(&shared_data->mutex);
}
static inline void shmem_wait(void)
{
- l_cond_wait(&shared_data->cond, &shared_data->mutex);
+ pthread_cond_wait(&shared_data->cond, &shared_data->mutex);
}
static inline void shmem_wakeup_all(void)
{
- l_cond_broadcast(&shared_data->cond);
+ pthread_cond_broadcast(&shared_data->cond);
}
static inline void shmem_reset(int total_threads)