Whamcloud - gitweb
LU-6245 libcfs: remove libcfsutil.h 80/14180/7
authorJohn L. Hammond <john.hammond@intel.com>
Wed, 15 Apr 2015 16:54:51 +0000 (12:54 -0400)
committerOleg Drokin <oleg.drokin@intel.com>
Tue, 28 Apr 2015 05:15:05 +0000 (05:15 +0000)
Remove libcfsutil.h, fixup some headers, rename
libcfs/util/libcfsutil_ioctl.h to libcfs/util/ioctl.h, remove
libcfs/util/platform.h, remove libcfs/util/util.c, do some other
stuff. With these changes libcfs.h can be removed from libcfs
userland library.

Signed-off-by: John L. Hammond <john.hammond@intel.com>
Signed-off-by: James Simmons <uja.ornl@gmail.com>
Change-Id: I23c0531cd1c50a652799ad807d506fda35b22b3b
Reviewed-on: http://review.whamcloud.com/14180
Reviewed-by: Dmitry Eremin <dmitry.eremin@intel.com>
Reviewed-by: frank zago <fzago@cray.com>
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: James Simmons <uja.ornl@yahoo.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
32 files changed:
libcfs/include/libcfs/Makefile.am
libcfs/include/libcfs/libcfs.h
libcfs/include/libcfs/libcfs_ioctl.h
libcfs/include/libcfs/libcfs_private.h
libcfs/include/libcfs/libcfsutil.h [deleted file]
libcfs/include/libcfs/types.h
libcfs/include/libcfs/user-prim.h
libcfs/include/libcfs/util/Makefile.am
libcfs/include/libcfs/util/ioctl.h [moved from libcfs/include/libcfs/util/libcfsutil_ioctl.h with 78% similarity]
libcfs/include/libcfs/util/platform.h [deleted file]
libcfs/libcfs/autoMakefile.am
libcfs/libcfs/linux/linux-module.c
libcfs/libcfs/linux/linux-prim.c
libcfs/libcfs/module.c
libcfs/libcfs/util/Makefile.am
libcfs/libcfs/util/l_ioctl.c
libcfs/libcfs/util/nidstrings.c
libcfs/libcfs/util/parser.c
libcfs/libcfs/util/util.c [deleted file]
lnet/include/lnet/lib-lnet.h
lnet/include/lnet/nidstr.h
lnet/utils/debug.c
lnet/utils/lnetconfig/liblnetconfig.c
lnet/utils/lnetctl.c
lnet/utils/lst.c
lnet/utils/portals.c
lustre/utils/lctl.c
lustre/utils/lfs.c
lustre/utils/lustre_cfg.c
lustre/utils/lustre_lfsck.c
lustre/utils/lustre_rsync.c
lustre/utils/obd.c

index 8d73baa..794c204 100644 (file)
@@ -25,7 +25,6 @@ EXTRA_DIST = \
        libcfs_string.h \
        libcfs_time.h \
        libcfs_workitem.h \
-       libcfsutil.h \
        list.h \
        types.h \
        user-bitops.h \
index d32d061..98474d9 100644 (file)
@@ -249,7 +249,9 @@ void cfs_get_random_bytes(void *buf, int size);
 #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__
@@ -276,7 +278,4 @@ static inline void *__container_of(const void *ptr, unsigned long shift)
 
 #define _LIBCFS_H
 
-int libcfs_arch_init(void);
-void libcfs_arch_cleanup(void);
-
 #endif /* _LIBCFS_H */
index 6d8781f..1ed8766 100644 (file)
@@ -36,7 +36,7 @@
  * 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.
  *
  */
 
@@ -101,22 +101,6 @@ do {                                                       \
        (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
@@ -190,89 +174,55 @@ struct libcfs_ioctl_handler {
 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__ */
index 662630d..cfb146d 100644 (file)
@@ -594,28 +594,6 @@ do {                                                            \
         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;
diff --git a/libcfs/include/libcfs/libcfsutil.h b/libcfs/include/libcfs/libcfsutil.h
deleted file mode 100644 (file)
index cd2783f..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * 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__ */
index b4fd790..7e3fe2f 100644 (file)
@@ -33,6 +33,7 @@
 #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)
index eb5bb5a..1752694 100644 (file)
@@ -235,11 +235,4 @@ struct group_info{ };
 
 #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__ */
index d019394..8bde63f 100644 (file)
@@ -1 +1 @@
-EXTRA_DIST = parser.h platform.h string.h libcfsutil_ioctl.h
+EXTRA_DIST = ioctl.h parser.h string.h
similarity index 78%
rename from libcfs/include/libcfs/util/libcfsutil_ioctl.h
rename to libcfs/include/libcfs/util/ioctl.h
index 173935a..5bf447b 100644 (file)
  * 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
diff --git a/libcfs/include/libcfs/util/platform.h b/libcfs/include/libcfs/util/platform.h
deleted file mode 100644 (file)
index 62aaf3f..0000000
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * 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
index 4a04674..b706b52 100644 (file)
@@ -47,7 +47,7 @@ libcfs_a_CFLAGS = $(LLCFLAGS)
 
 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
index 7175e44..970283e 100644 (file)
@@ -96,7 +96,7 @@ int libcfs_ioctl_getdata(struct libcfs_ioctl_hdr **hdr_pp,
 
        RETURN(0);
 failed:
-       libcfs_ioctl_freedata(*hdr_pp);
+       LIBCFS_FREE(*hdr_pp, hdr.ioc_len);
        RETURN(err);
 }
 
index 2f1eec1..0a617df 100644 (file)
@@ -167,20 +167,6 @@ cfs_clear_sigpending(void)
        spin_unlock_irqrestore(&current->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);
index 767bc07..a00679c 100644 (file)
@@ -288,15 +288,17 @@ static int libcfs_ioctl(struct cfs_psdev_file *pfile,
                        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);
 }
 
@@ -316,8 +318,6 @@ static int init_libcfs_module(void)
 {
        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);
@@ -408,8 +408,6 @@ static void exit_libcfs_module(void)
        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);
index baa1f5a..311f4aa 100644 (file)
@@ -1 +1 @@
-EXTRA_DIST = parser.c l_ioctl.c nidstrings.c string.c util.c
+EXTRA_DIST = parser.c l_ioctl.c nidstrings.c string.c
index 76b4f12..4fa4ab1 100644 (file)
 
 #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;
@@ -45,28 +52,17 @@ struct dump_hdr {
         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;
 
@@ -103,13 +99,12 @@ open_ioc_dev(int dev_id)
 }
 
 
-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);
@@ -117,63 +112,12 @@ do_ioctl(int dev_id, unsigned int opc, void *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;
 
@@ -183,12 +127,12 @@ register_ioc_dev(int dev_id, const char * dev_name, int major, int minor)
         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]))
@@ -202,120 +146,6 @@ unregister_ioc_dev(int dev_id)
        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)
 {
@@ -334,10 +164,17 @@ int libcfs_ioctl_pack(struct libcfs_ioctl_data *data, char **pbuf,
        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;
 
@@ -357,8 +194,14 @@ libcfs_ioctl_unpack(struct libcfs_ioctl_data *data, char *pbuf)
        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);
+       }
 }
index 26c4fec..fbc678b 100644 (file)
 
 #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>
@@ -556,7 +563,7 @@ libcfs_str2nid(const char *str)
                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))
@@ -799,7 +806,8 @@ parse_nidrange(struct cfs_lstr *src, struct list_head *nidlist)
 
        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;
 }
 
@@ -896,7 +904,7 @@ libcfs_num_match(__u32 addr, struct list_head *numaddr)
 {
        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);
@@ -933,11 +941,11 @@ int cfs_match_nid(lnet_nid_t nid, struct list_head *nidlist)
 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;
@@ -950,7 +958,7 @@ libcfs_ip_addr_range_print(char *buffer, int count, struct list_head *list)
        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);
@@ -1021,7 +1029,7 @@ int cfs_print_nidlist(char *buffer, int count, struct list_head *nidlist)
                        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 {
index 6ca87e0..ae5e082 100644 (file)
  *
  */
 
+#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                              */
@@ -236,7 +251,7 @@ static char **command_completion(const char *text, int start, int end)
                 if (*(pos - 1) == ' ') match_tbl = table->pc_sub_cmd;
         }
 
-        return completion_matches(text, command_generator);
+       return rl_completion_matches(text, command_generator);
 }
 #endif
 
diff --git a/libcfs/libcfs/util/util.c b/libcfs/libcfs/util/util.c
deleted file mode 100644 (file)
index 6bc351f..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * 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;
-}
index 5676cdb..94aed03 100644 (file)
@@ -481,6 +481,22 @@ int lnet_get_net_config(int idx,
                        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);
index fcfcbfb..a0b3059 100644 (file)
 #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 */
index c5469eb..49456cf 100644 (file)
@@ -43,7 +43,8 @@
 #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];
@@ -191,19 +192,8 @@ static int applymask(char* procpath, int value)
 
 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);
 }
@@ -368,7 +358,6 @@ readhdr:
                        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 ||
index 93d733a..7923ccb 100644 (file)
  *  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>
index 43ed605..831543d 100644 (file)
  * 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"
 
@@ -996,14 +996,6 @@ int main(int argc, char **argv)
                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);
@@ -1013,6 +1005,5 @@ int main(int argc, char **argv)
        Parser_commands();
 
 errorout:
-       libcfs_arch_cleanup();
        return rc;
 }
index 81803db..da14214 100644 (file)
  *
  * 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>
@@ -3299,10 +3307,6 @@ main(int argc, char **argv)
 
         setlinebuf(stdout);
 
-        rc = libcfs_arch_init();
-        if (rc < 0)
-                return rc;
-
         rc = lst_initialize();
         if (rc < 0)
                 goto errorout;
@@ -3310,7 +3314,7 @@ main(int argc, char **argv)
         rc = ptl_initialize(argc, argv);
         if (rc < 0)
                 goto errorout;
-        
+
         Parser_init("lst > ", lst_cmdlist);
 
         if (argc != 1)  {
@@ -3321,6 +3325,5 @@ main(int argc, char **argv)
         Parser_commands();
 
 errorout:
-        libcfs_arch_cleanup();
         return rc;
 }
index 1f314c9..714cb64 100644 (file)
  *   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;
index 58cbae5..9b1d0a3 100644 (file)
@@ -42,9 +42,9 @@
 
 #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) {
index edb5676..699d73e 100644 (file)
@@ -66,7 +66,8 @@
 #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>
 
index 3f02d5b..c9e1c20 100644 (file)
@@ -50,6 +50,7 @@
 #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>
@@ -65,7 +66,6 @@
 
 #include "obdctl.h"
 #include <lnet/lnetctl.h>
-#include <libcfs/libcfsutil.h>
 #include <stdio.h>
 
 static char * lcfg_devname;
index 3237680..4cf35d1 100644 (file)
 #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'},
index 5d28634..e7b3830 100644 (file)
 #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"
index 87b0d5b..0dc4ed9 100644 (file)
@@ -65,6 +65,9 @@
 
 #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>
@@ -72,7 +75,6 @@
 #include <lustre/lustre_build_version.h>
 
 #include <lnet/lnetctl.h>
-#include <libcfs/libcfsutil.h>
 #include <lustre/lustreapi.h>
 
 #define MAX_STRING_SIZE 128
@@ -87,8 +89,8 @@
 #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];
@@ -423,22 +425,22 @@ out:
 
 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)