Whamcloud - gitweb
Land b_head_libcfs onto HEAD (20080805_1611)
authorrobert.read <robert.read>
Tue, 5 Aug 2008 23:57:09 +0000 (23:57 +0000)
committerrobert.read <robert.read>
Tue, 5 Aug 2008 23:57:09 +0000 (23:57 +0000)
b=16620
i=adilger
i=shadow
i=isaac

First stage of Libcfs cleanup. This landing includes the patches from bugs
16159, 16420, 16445, 16478, and 16479.

42 files changed:
lustre/autoconf/lustre-core.m4
lustre/fid/fid_internal.h
lustre/fld/fld_internal.h
lustre/include/darwin/lustre_types.h [deleted file]
lustre/include/darwin/lustre_user.h
lustre/include/interval_tree.h
lustre/include/liblustre.h
lustre/include/linux/Makefile.am
lustre/include/linux/lustre_types.h [deleted file]
lustre/include/linux/lustre_user.h
lustre/include/lprocfs_status.h
lustre/include/lustre/Makefile.am
lustre/include/lustre/lustre_idl.h
lustre/include/lustre/types.h [deleted file]
lustre/include/lustre_cfg.h
lustre/include/obd_cksum.h
lustre/ldlm/ldlm_lockd.c
lustre/liblustre/Makefile.am
lustre/liblustre/dir.c
lustre/liblustre/genlib.sh
lustre/liblustre/rw.c
lustre/lmv/lmv_obd.c
lustre/lvfs/lvfs_lib.c
lustre/obdclass/lu_object.c
lustre/obdecho/echo.c
lustre/ptlrpc/sec.c
lustre/tests/multiop.c
lustre/tests/openclose.c
lustre/tests/openfile.c
lustre/utils/Makefile.am
lustre/utils/gss/Makefile.am
lustre/utils/gss/lsupport.c
lustre/utils/lctl.c
lustre/utils/lfs.c
lustre/utils/liblustreapi.c
lustre/utils/loadgen.c
lustre/utils/lustre_cfg.c
lustre/utils/obd.c
lustre/utils/obdctl.c
lustre/utils/parser.c [deleted file]
lustre/utils/parser.h [deleted file]
lustre/utils/platform.h [deleted file]

index aab1acc..cc1dc3f 100644 (file)
@@ -1817,7 +1817,7 @@ AC_DEFUN([LC_CONFIGURE],
 [LC_CONFIG_OBD_BUFFER_SIZE
 
 # include/liblustre.h
-AC_CHECK_HEADERS([asm/page.h sys/user.h sys/vfs.h stdint.h blkid/blkid.h])
+AC_CHECK_HEADERS([sys/user.h sys/vfs.h stdint.h blkid/blkid.h])
 
 # liblustre/llite_lib.h
 AC_CHECK_HEADERS([xtio.h file.h])
index 3d0f604..2aec259 100644 (file)
@@ -45,8 +45,6 @@
 
 #include <libcfs/libcfs.h>
 
-#include <linux/types.h>
-
 #ifdef __KERNEL__
 struct seq_thread_info {
         struct req_capsule     *sti_pill;
index 4e7efb0..6f9443f 100644 (file)
@@ -46,7 +46,6 @@
 
 #include <libcfs/libcfs.h>
 
-#include <linux/types.h>
 #include <lustre_req_layout.h>
 #include <lustre_fld.h>
 
diff --git a/lustre/include/darwin/lustre_types.h b/lustre/include/darwin/lustre_types.h
deleted file mode 100644 (file)
index 37f2bac..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
- * vim:expandtab:shiftwidth=8:tabstop=8:
- *
- * 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 [sun.com URL with a
- * copy of GPLv2].
- *
- * 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  2008 Sun Microsystems, Inc. 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.
- */
-
-#ifndef _LUSTRE_DARWIN_TYPES_H
-#define _LUSTRE_DARWIN_TYPES_H
-
-#include <string.h>
-#include <libcfs/libcfs.h>
-
-#endif
index 5cf1241..cdc6fe3 100644 (file)
@@ -41,8 +41,6 @@
 #ifndef _DARWIN_LUSTRE_USER_H
 #define _DARWIN_LUSTRE_USER_H
 
-#include <lustre/types.h>
-
 #ifndef __KERNEL__
 /* for llmount */
 # define _GNU_SOURCE
index 5810eba..0f6d99e 100644 (file)
@@ -42,7 +42,6 @@
 #ifndef _INTERVAL_H__
 #define _INTERVAL_H__
 
-#include <libcfs/types.h>  /* __u8, __u64 etc. */
 #include <libcfs/libcfs.h>   /* LASSERT. */
 
 struct interval_node {
index 9e41974..ac40f53 100644 (file)
 
 #ifdef __KERNEL__
 #error Kernel files should not #include <liblustre.h>
-#else
-/*
- * The userspace implementations of linux/spinlock.h vary; we just
- * include our own for all of them
- */
-#define __LINUX_SPINLOCK_H
 #endif
 
 #include <libcfs/libcfs.h>
 #include <lnet/lnet.h>
-#include <libcfs/user-bitops.h>
-
-#include <sys/mman.h>
-#ifdef HAVE_STDINT_H
-# include <stdint.h>
-#endif
-#ifdef HAVE_ASM_PAGE_H
-# include <asm/page.h>
-#endif
-#ifdef HAVE_SYS_USER_H
-# include <sys/user.h>
-#endif
-#ifdef HAVE_SYS_IOCTL_H
-# include <sys/ioctl.h>
-#endif
-
-#include <stdio.h>
-#include <sys/ioctl.h>
-#include <stdlib.h>
-#include <string.h>
-#include <errno.h>
-#include <sys/stat.h>
-#ifdef HAVE_SYS_VFS_H
-# include <sys/vfs.h>
-#endif
-#include <unistd.h>
-#include <fcntl.h>
-#include <assert.h>
-
-#include <libcfs/libcfs.h>
-#include <libcfs/list.h>
-#include <lnet/lnet.h>
-#include <libcfs/user-bitops.h>
-
-#ifndef _IOWR
-# include "ioctl.h"
-#endif
 
 /* definitions for liblustre */
 
@@ -101,25 +58,6 @@ typedef unsigned short umode_t;
 
 #endif
 
-
-#ifndef ARRAY_SIZE
-#define ARRAY_SIZE(a) ((sizeof (a))/(sizeof ((a)[0])))
-#endif
-
-/* This is because lprocfs_status.h gets included here indirectly.  It would
- * be much better to just avoid lprocfs being included into liblustre entirely
- * but that requires more header surgery than I can handle right now.
- */
-#ifndef smp_processor_id
-#define smp_processor_id() 0
-#endif
-#ifndef num_online_cpus
-#define num_online_cpus() 1
-#endif
-#ifndef num_possible_cpus
-#define num_possible_cpus() 1
-#endif
-
 /* always adopt 2.5 definitions */
 #define KERNEL_VERSION(a,b,c) ((a)*100+(b)*10+c)
 #define LINUX_VERSION_CODE KERNEL_VERSION(2,6,5)
@@ -130,57 +68,16 @@ typedef unsigned short umode_t;
 #endif
 
 
+/*
+ * The inter_module_get implementation is specific to liblustre, so this needs
+ * to stay here for now.
+ */ 
 static inline void inter_module_put(void *a)
 {
         return;
 }
-
 void *inter_module_get(char *arg);
 
-/* cheats for now */
-
-struct work_struct {
-        void (*ws_task)(void *arg);
-        void *ws_arg;
-};
-
-static inline void prepare_work(struct work_struct *q, void (*t)(void *),
-                                void *arg)
-{
-        q->ws_task = t;
-        q->ws_arg = arg;
-        return;
-}
-
-static inline void schedule_work(struct work_struct *q)
-{
-        q->ws_task(q->ws_arg);
-}
-
-
-#define strnlen(a,b) strlen(a)
-static inline void *kmalloc(int size, int prot)
-{
-        return malloc(size);
-}
-#define vmalloc malloc
-#define vfree free
-#define kfree(a) free(a)
-#define GFP_KERNEL 1
-#define GFP_HIGHUSER 1
-#define GFP_ATOMIC 1
-#define GFP_NOFS 1
-#define IS_ERR(a) ((unsigned long)(a) > (unsigned long)-1000L)
-#define PTR_ERR(a) ((long)(a))
-#define ERR_PTR(a) ((void*)((long)(a)))
-
-typedef int (read_proc_t)(char *page, char **start, off_t off,
-                          int count, int *eof, void *data);
-
-struct file; /* forward ref */
-typedef int (write_proc_t)(struct file *file, const char *buffer,
-                           unsigned long count, void *data);
-
 /* bits ops */
 
 /* a long can be more than 32 bits, so use BITS_PER_LONG
@@ -202,56 +99,6 @@ static __inline__ int ext2_test_bit(int nr, void *addr)
         return test_bit(nr, addr);
 }
 
-/* modules */
-
-struct module {
-        int count;
-};
-
-static inline void MODULE_AUTHOR(char *name)
-{
-        printf("%s\n", name);
-}
-#define MODULE_DESCRIPTION(name) MODULE_AUTHOR(name)
-#define MODULE_LICENSE(name) MODULE_AUTHOR(name)
-
-#define THIS_MODULE NULL
-#define __init
-#define __exit
-
-/* devices */
-
-static inline int misc_register(void *foo)
-{
-        return 0;
-}
-
-static inline int misc_deregister(void *foo)
-{
-        return 0;
-}
-
-static inline int request_module(char *name)
-{
-        return (-EINVAL);
-}
-
-#define __MOD_INC_USE_COUNT(m)  do {} while (0)
-#define __MOD_DEC_USE_COUNT(m)  do {} while (0)
-#define MOD_INC_USE_COUNT       do {} while (0)
-#define MOD_DEC_USE_COUNT       do {} while (0)
-static inline void __module_get(struct module *module)
-{
-}
-
-static inline int try_module_get(struct module *module)
-{
-        return 1;
-}
-
-static inline void module_put(struct module *module)
-{
-}
 
 /* module initialization */
 extern int init_obdclass(void);
@@ -272,33 +119,8 @@ extern int echo_client_init(void);
 
 struct rcu_head { };
 
-typedef struct { } spinlock_t;
 typedef __u64 kdev_t;
 
-#define SPIN_LOCK_UNLOCKED (spinlock_t) { }
-#define LASSERT_SPIN_LOCKED(lock) do {} while(0)
-#define LASSERT_SEM_LOCKED(sem) do {} while(0)
-
-static inline void spin_lock(spinlock_t *l) {return;}
-static inline void spin_unlock(spinlock_t *l) {return;}
-static inline void spin_lock_init(spinlock_t *l) {return;}
-static inline void local_irq_save(unsigned long flag) {return;}
-static inline void local_irq_restore(unsigned long flag) {return;}
-static inline int spin_is_locked(spinlock_t *l) {return 1;}
-
-static inline void spin_lock_bh(spinlock_t *l) {}
-static inline void spin_unlock_bh(spinlock_t *l) {}
-static inline void spin_lock_irqsave(spinlock_t *a, unsigned long b) {}
-static inline void spin_unlock_irqrestore(spinlock_t *a, unsigned long b) {}
-
-typedef spinlock_t rwlock_t;
-#define RW_LOCK_UNLOCKED        SPIN_LOCK_UNLOCKED
-#define read_lock(l)            spin_lock(l)
-#define read_unlock(l)          spin_unlock(l)
-#define write_lock(l)           spin_lock(l)
-#define write_unlock(l)         spin_unlock(l)
-#define rwlock_init(l)          spin_lock_init(l)
-
 #define min(x,y) ((x)<(y) ? (x) : (y))
 #define max(x,y) ((x)>(y) ? (x) : (y))
 
@@ -328,114 +150,6 @@ void get_random_bytes(void *ptr, int size);
 /* memory size: used for some client tunables */
 #define num_physpages (256 * 1024) /* 1GB */
 
-static inline int copy_from_user(void *a,void *b, int c)
-{
-        memcpy(a,b,c);
-        return 0;
-}
-
-static inline int copy_to_user(void *a,void *b, int c)
-{
-        memcpy(a,b,c);
-        return 0;
-}
-
-
-/* slabs */
-typedef struct {
-         int size;
-} kmem_cache_t;
-#define SLAB_HWCACHE_ALIGN 0
-static inline kmem_cache_t *
-kmem_cache_create(const char *name, size_t objsize, size_t cdum,
-                  unsigned long d,
-                  void (*e)(void *, kmem_cache_t *, unsigned long),
-                  void (*f)(void *, kmem_cache_t *, unsigned long))
-{
-        kmem_cache_t *c;
-        c = malloc(sizeof(*c));
-        if (!c)
-                return NULL;
-        c->size = objsize;
-        CDEBUG(D_MALLOC, "alloc slab cache %s at %p, objsize %d\n",
-               name, c, (int)objsize);
-        return c;
-};
-
-static inline int kmem_cache_destroy(kmem_cache_t *a)
-{
-        CDEBUG(D_MALLOC, "destroy slab cache %p, objsize %u\n", a, a->size);
-        free(a);
-        return 0;
-}
-
-/* struct page decl moved out from here into portals/include/libcfs/user-prim.h */
-
-/* 2.4 defines */
-#define PAGE_LIST_ENTRY list
-#define PAGE_LIST(page) ((page)->list)
-
-#define kmap(page) (page)->addr
-#define kunmap(a) do {} while (0)
-
-static inline cfs_page_t *alloc_pages(int mask, unsigned long order)
-{
-        cfs_page_t *pg = malloc(sizeof(*pg));
-
-        if (!pg)
-                return NULL;
-#if 0 //#ifdef MAP_ANONYMOUS
-        pg->addr = mmap(0, PAGE_SIZE << order, PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, 0, 0);
-#else
-        pg->addr = malloc(CFS_PAGE_SIZE << order);
-#endif
-
-        if (!pg->addr) {
-                free(pg);
-                return NULL;
-        }
-        return pg;
-}
-#define cfs_alloc_pages(mask, order)  alloc_pages((mask), (order))
-
-#define alloc_page(mask)      alloc_pages((mask), 0)
-#define cfs_alloc_page(mask)  alloc_page(mask)
-
-static inline void __free_pages(cfs_page_t *pg, int what)
-{
-#if 0 //#ifdef MAP_ANONYMOUS
-        munmap(pg->addr, PAGE_SIZE);
-#else
-        free(pg->addr);
-#endif
-        free(pg);
-}
-#define __cfs_free_pages(pg, order)  __free_pages((pg), (order))
-
-#define __free_page(page) __free_pages((page), 0)
-#define free_page(page) __free_page(page)
-#define __cfs_free_page(page)  __cfs_free_pages((page), 0)
-
-static inline cfs_page_t* __grab_cache_page(unsigned long index)
-{
-        cfs_page_t *pg = alloc_pages(0, 0);
-
-        if (pg)
-                pg->index = index;
-        return pg;
-}
-
-#define grab_cache_page(index) __grab_cache_page(index)
-#define page_cache_release(page) __free_pages(page, 0)
-
-/* arithmetic */
-#define do_div(a,b)                     \
-        ({                              \
-                unsigned long remainder;\
-                remainder = (a) % (b);  \
-                (a) = (a) / (b);        \
-                (remainder);            \
-        })
 
 /* VFS stuff */
 #define ATTR_MODE       0x0001
@@ -520,49 +234,6 @@ struct vfsmount {
         void *pwd;
 };
 
-/* semaphores */
-struct rw_semaphore {
-        int count;
-};
-
-/* semaphores */
-struct semaphore {
-        int count;
-};
-
-/* use the macro's argument to avoid unused warnings */
-#define down(a) do { (void)a; } while (0)
-#define mutex_down(a)   down(a)
-#define up(a) do { (void)a; } while (0)
-#define mutex_up(a)     up(a)
-#define down_read(a) do { (void)a; } while (0)
-#define up_read(a) do { (void)a; } while (0)
-#define down_write(a) do { (void)a; } while (0)
-#define up_write(a) do { (void)a; } while (0)
-#define sema_init(a,b) do { (void)a; } while (0)
-#define init_rwsem(a) do { (void)a; } while (0)
-#define DECLARE_MUTEX(name)     \
-        struct semaphore name = { 1 }
-static inline void init_MUTEX (struct semaphore *sem)
-{
-        sema_init(sem, 1);
-}
-static inline void init_MUTEX_LOCKED (struct semaphore *sem)
-{
-        sema_init(sem, 0);
-}
-
-#define init_mutex(s)   init_MUTEX(s)
-
-typedef struct  {
-        struct list_head sleepers;
-} wait_queue_head_t;
-
-typedef struct  {
-        struct list_head sleeping;
-        void *process;
-} wait_queue_t;
-
 struct signal {
         int signal;
 };
@@ -582,6 +253,7 @@ struct task_struct {
         __u32 cap_effective;
 };
 
+
 typedef struct task_struct cfs_task_t;
 #define cfs_current()           current
 #define cfs_curproc_pid()       (current->pid)
@@ -599,21 +271,6 @@ static inline int capable(int cap)
 
 #define set_current_state(foo) do { current->state = foo; } while (0)
 
-#define init_waitqueue_entry(q,p) do { (q)->process = p; } while (0)
-#define add_wait_queue(q,p) do {  list_add(&(q)->sleepers, &(p)->sleeping); } while (0)
-#define del_wait_queue(p) do { list_del(&(p)->sleeping); } while (0)
-#define remove_wait_queue(q,p) do { list_del(&(p)->sleeping); } while (0)
-
-#define DECLARE_WAIT_QUEUE_HEAD(HEAD)                           \
-        wait_queue_head_t HEAD = {                              \
-                .sleepers = CFS_LIST_HEAD_INIT(HEAD.sleepers)   \
-        }
-#define init_waitqueue_head(l) CFS_INIT_LIST_HEAD(&(l)->sleepers)
-#define wake_up(l) do { } while (0)
-#define TASK_INTERRUPTIBLE 0
-#define TASK_UNINTERRUPTIBLE 1
-#define TASK_RUNNING 2
-
 #define wait_event_interruptible(wq, condition)                         \
 ({                                                                      \
         struct l_wait_info lwi;                                         \
@@ -626,14 +283,6 @@ static inline int capable(int cap)
         ret;                                                            \
 })
 
-#define in_interrupt() (0)
-
-#define schedule() do {} while (0)
-static inline int schedule_timeout(signed long t)
-{
-        return 0;
-}
-
 #define lock_kernel() do {} while (0)
 #define unlock_kernel() do {} while (0)
 #define daemonize(l) do {} while (0)
@@ -645,7 +294,6 @@ static inline int schedule_timeout(signed long t)
 #define SIGNAL_MASK_ASSERT()
 #define KERN_INFO
 
-#include <sys/time.h>
 #if HZ != 1
 #error "liblustre's jiffies currently expects HZ to be 1"
 #endif
@@ -658,57 +306,6 @@ static inline int schedule_timeout(signed long t)
         _ret;                                   \
 })
 #define get_jiffies_64()  (__u64)jiffies
-#define time_after(a, b) ((long)(b) - (long)(a) < 0)
-#define time_before(a, b) time_after(b,a)
-#define time_after_eq(a,b)      ((long)(a) - (long)(b) >= 0)
-
-struct timer_list {
-        struct list_head tl_list;
-        void (*function)(unsigned long unused);
-        unsigned long data;
-        long expires;
-};
-
-static inline int timer_pending(struct timer_list *l)
-{
-        if (time_after(l->expires, jiffies))
-                return 1;
-        else
-                return 0;
-}
-
-static inline int init_timer(struct timer_list *l)
-{
-        CFS_INIT_LIST_HEAD(&l->tl_list);
-        return 0;
-}
-
-static inline void mod_timer(struct timer_list *l, int thetime)
-{
-        l->expires = thetime;
-}
-
-static inline void del_timer(struct timer_list *l)
-{
-        free(l);
-}
-
-typedef struct { volatile int counter; } atomic_t;
-
-#define ATOMIC_INIT(i) { (i) }
-
-#define atomic_read(a) ((a)->counter)
-#define atomic_set(a,b) do {(a)->counter = b; } while (0)
-#define atomic_dec_and_test(a) ((--((a)->counter)) == 0)
-#define atomic_dec_and_lock(a,b) ((--((a)->counter)) == 0)
-#define atomic_inc(a)  (((a)->counter)++)
-#define atomic_dec(a)  do { (a)->counter--; } while (0)
-#define atomic_add(b,a)  do {(a)->counter += b;} while (0)
-#define atomic_add_return(n,a) ((a)->counter += n)
-#define atomic_inc_return(a) atomic_add_return(1,a)
-#define atomic_sub(b,a)  do {(a)->counter -= b;} while (0)
-#define atomic_sub_return(n,a) ((a)->counter -= n)
-#define atomic_dec_return(a)  atomic_sub_return(1,a)
 
 #ifndef likely
 #define likely(exp) (exp)
@@ -781,25 +378,6 @@ int     cap_get_flag(cap_t, cap_value_t, cap_flag_t, cap_flag_value_t *);
 static inline void libcfs_run_lbug_upcall(char *file, const char *fn,
                                            const int l){}
 
-/* completion */
-struct completion {
-        unsigned int done;
-        cfs_waitq_t wait;
-};
-
-#define COMPLETION_INITIALIZER(work) \
-        { 0, __WAIT_QUEUE_HEAD_INITIALIZER((work).wait) }
-
-#define DECLARE_COMPLETION(work) \
-        struct completion work = COMPLETION_INITIALIZER(work)
-
-#define INIT_COMPLETION(x)      ((x).done = 0)
-
-static inline void init_completion(struct completion *x)
-{
-        x->done = 0;
-        init_waitqueue_head(&x->wait);
-}
 
 struct liblustre_wait_callback {
         struct list_head    llwc_list;
@@ -958,60 +536,4 @@ static inline void set_fs(mm_segment_t seg)
 #include <lustre_export.h>
 #include <lustre_net.h>
 
-/* Fast hashing routine for a long.
-   (C) 2002 William Lee Irwin III, IBM */
-
-/*
- * Knuth recommends primes in approximately golden ratio to the maximum
- * integer representable by a machine word for multiplicative hashing.
- * Chuck Lever verified the effectiveness of this technique:
- * http://www.citi.umich.edu/techreports/reports/citi-tr-00-1.pdf
- *
- * These primes are chosen to be bit-sparse, that is operations on
- * them can use shifts and additions instead of multiplications for
- * machines where multiplications are slow.
- */
-#if BITS_PER_LONG == 32
-/* 2^31 + 2^29 - 2^25 + 2^22 - 2^19 - 2^16 + 1 */
-#define GOLDEN_RATIO_PRIME 0x9e370001UL
-#elif BITS_PER_LONG == 64
-/*  2^63 + 2^61 - 2^57 + 2^54 - 2^51 - 2^18 + 1 */
-#define GOLDEN_RATIO_PRIME 0x9e37fffffffc0001UL
-#else
-#error Define GOLDEN_RATIO_PRIME for your wordsize.
-#endif
-
-static inline unsigned long hash_long(unsigned long val, unsigned int bits)
-{
-       unsigned long hash = val;
-
-#if BITS_PER_LONG == 64
-       /*  Sigh, gcc can't optimise this alone like it does for 32 bits. */
-       unsigned long n = hash;
-       n <<= 18;
-       hash -= n;
-       n <<= 33;
-       hash -= n;
-       n <<= 3;
-       hash += n;
-       n <<= 3;
-       hash -= n;
-       n <<= 4;
-       hash += n;
-       n <<= 2;
-       hash += n;
-#else
-       /* On some cpus multiply is faster, on others gcc will do shifts */
-       hash *= GOLDEN_RATIO_PRIME;
-#endif
-
-       /* High bits are more random, so use them. */
-       return hash >> (BITS_PER_LONG - bits);
-}
-       
-static inline unsigned long hash_ptr(void *ptr, unsigned int bits)
-{
-       return hash_long((unsigned long)ptr, bits);
-}
-
 #endif
index 8af4946..62ebac9 100644 (file)
 linuxdir = $(includedir)/linux
 
 if UTILS
-linux_HEADERS = lustre_types.h lustre_user.h
+linux_HEADERS = lustre_user.h
 endif
 
 EXTRA_DIST = lprocfs_status.h lustre_acl.h lustre_debug.h lustre_lib.h \
      lustre_dlm.h  lustre_handles.h lustre_net.h obd_class.h obd_support.h \
      lustre_log.h lustre_compat25.h lustre_fsfilt.h lustre_mds.h \
      obd.h lvfs.h lvfs_linux.h lustre_lite.h lustre_quota.h \
-     lustre_user.h lustre_types.h lustre_patchless_compat.h lustre_intent.h \
+     lustre_user.h lustre_patchless_compat.h lustre_intent.h \
      obd_cksum.h
diff --git a/lustre/include/linux/lustre_types.h b/lustre/include/linux/lustre_types.h
deleted file mode 100644 (file)
index 488f4e5..0000000
+++ /dev/null
@@ -1,84 +0,0 @@
-/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
- * vim:expandtab:shiftwidth=8:tabstop=8:
- *
- * 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 [sun.com URL with a
- * copy of GPLv2].
- *
- * 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  2008 Sun Microsystems, Inc. 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.
- */
-
-#ifndef _LUSTRE_LINUX_TYPES_H
-#define _LUSTRE_LINUX_TYPES_H
-
-#ifdef HAVE_ASM_TYPES_H
-#include <asm/types.h>
-#endif
-
-#ifdef __KERNEL__
-# include <linux/types.h>
-# include <linux/fs.h>    /* to check for FMODE_EXEC, dev_t, lest we redefine */
-#else
-#ifdef __CYGWIN__
-# include <sys/types.h>
-#elif defined(_AIX)
-# include <inttypes.h>
-#else
-# include <stdint.h>
-#endif
-#endif
-
-#if !defined(_LINUX_TYPES_H) && !defined(_BLKID_TYPES_H) && \
-        !defined(_EXT2_TYPES_H) && !defined(_I386_TYPES_H) && \
-        !defined(_ASM_IA64_TYPES_H) && !defined(_X86_64_TYPES_H) && \
-        !defined(_PPC_TYPES_H) && !defined(_PPC64_TYPES_H) && \
-        !defined(_ASM_POWERPC_TYPES_H) && !defined(__mips64__) && \
-       !defined(_CRAYNV_TYPES_H)
-        /* yuck, would be nicer with _ASM_TYPES_H */
-
-typedef unsigned short umode_t;
-/*
- * __xx is ok: it doesn't pollute the POSIX namespace. Use these in the
- * header files exported to user space
- */
-
-typedef __signed__ char __s8;
-typedef unsigned char __u8;
-
-typedef __signed__ short __s16;
-typedef unsigned short __u16;
-
-typedef __signed__ int __s32;
-typedef unsigned int __u32;
-
-typedef __signed__ long long __s64;
-typedef unsigned long long __u64;
-#endif
-
-#endif
index 476a1e0..3b3b6cc 100644 (file)
 #ifndef _LINUX_LUSTRE_USER_H
 #define _LINUX_LUSTRE_USER_H
 
-#ifdef HAVE_ASM_TYPES_H
-#include <asm/types.h>
-#else
-#include <lustre/types.h>
-#endif
-
-
 #ifndef __KERNEL__
 # define NEED_QUOTA_DEFS
 # ifdef HAVE_QUOTA_SUPPORT
index 7af1f35..6d7cbfb 100644 (file)
@@ -398,8 +398,8 @@ extern int lprocfs_exp_setup(struct obd_export *exp,
                              lnet_nid_t *peer_nid, int *newnid);
 extern int lprocfs_exp_cleanup(struct obd_export *exp);
 extern int lprocfs_add_simple(struct proc_dir_entry *root,
-                              char *name, read_proc_t *read_proc,
-                              write_proc_t *write_proc, void *data);
+                              char *name, cfs_read_proc_t *read_proc,
+                              cfs_write_proc_t *write_proc, void *data);
 extern struct proc_dir_entry *lprocfs_add_symlink(const char *name,
                         struct proc_dir_entry *parent, const char *dest);
 extern void lprocfs_free_per_client_stats(struct obd_device *obd);
@@ -431,7 +431,8 @@ extern cfs_proc_dir_entry_t *lprocfs_srch(cfs_proc_dir_entry_t *root,
 extern int lprocfs_obd_setup(struct obd_device *obd, struct lprocfs_vars *list);
 extern int lprocfs_obd_cleanup(struct obd_device *obd);
 extern int lprocfs_add_simple(struct proc_dir_entry *root, char *name,
-                              read_proc_t *read_proc, write_proc_t *write_proc,
+                              cfs_read_proc_t *read_proc, 
+                              cfs_write_proc_t *write_proc,
                               void *data);
 extern void lprocfs_free_per_client_stats(struct obd_device *obd);
 extern struct file_operations lprocfs_evict_client_fops;
@@ -649,8 +650,8 @@ static inline int lprocfs_exp_cleanup(struct obd_export *exp)
 { return 0; }
 static inline int lprocfs_add_simple(struct proc_dir_entry *root,
                                      char *name,
-                                     read_proc_t *read_proc,
-                                     write_proc_t *write_proc,
+                                     cfs_read_proc_t *read_proc,
+                                     cfs_write_proc_t *write_proc,
                                      void *data)
 {return 0; }
 static inline struct proc_dir_entry *lprocfs_add_symlink(const char *name,
index be81bed..3405939 100644 (file)
@@ -35,7 +35,7 @@
 #
 
 if UTILS
-pkginclude_HEADERS = lustre_idl.h lustre_user.h liblustreapi.h libiam.h types.h
+pkginclude_HEADERS = lustre_idl.h lustre_user.h liblustreapi.h libiam.h 
 endif
 
-EXTRA_DIST = lustre_idl.h lustre_user.h liblustreapi.h libiam.h types.h
+EXTRA_DIST = lustre_idl.h lustre_user.h liblustreapi.h libiam.h 
index bf58102..7b19bf4 100644 (file)
@@ -86,8 +86,6 @@
 
 #include <libcfs/libcfs.h>
 
-#include <lustre/types.h>
-
 /* Defn's shared with user-space. */
 #include <lustre/lustre_user.h>
 
diff --git a/lustre/include/lustre/types.h b/lustre/include/lustre/types.h
deleted file mode 100644 (file)
index d4420b0..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
- * vim:expandtab:shiftwidth=8:tabstop=8:
- *
- * 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 [sun.com URL with a
- * copy of GPLv2].
- *
- * 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  2008 Sun Microsystems, Inc. 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.
- */
-
-#ifndef _LUSTRE_TYPES_H
-#define _LUSTRE_TYPES_H
-
-#if defined(__linux__)
-#include <linux/lustre_types.h>
-#elif defined(__APPLE__)
-#include <darwin/lustre_types.h>
-#elif defined(__WINNT__)
-#include <winnt/lustre_types.h>
-#else
-#error Unsupported operating system.
-#endif
-
-#endif
index 62c8e56..e1c63e2 100644 (file)
@@ -97,6 +97,11 @@ struct lustre_cfg {
         __u32 lcfg_buflens[0];
 };
 
+enum cfg_record_type {
+        PORTALS_CFG_TYPE = 1,
+        LUSTRE_CFG_TYPE = 123,
+};
+
 #define LUSTRE_CFG_BUFLEN(lcfg, idx)            \
         ((lcfg)->lcfg_bufcount <= (idx)         \
          ? 0                                    \
index 79f6b5e..e56ff82 100644 (file)
@@ -47,7 +47,6 @@
 #error Unsupported operating system.
 #endif
 
-#include <lustre/types.h>
 #include <lustre/lustre_idl.h>
 
 /*
index 79ef1e4..0a0cf14 100644 (file)
@@ -1378,7 +1378,7 @@ static void ldlm_handle_cp_callback(struct ptlrpc_request *req,
         if (OBD_FAIL_CHECK(OBD_FAIL_LDLM_CANCEL_BL_CB_RACE)) {
                 int to = cfs_time_seconds(1);
                 while (to > 0) {
-                        to = schedule_timeout(to);
+                        cfs_schedule_timeout(CFS_TASK_INTERRUPTIBLE, to);
                         if (lock->l_granted_mode == lock->l_req_mode ||
                             lock->l_destroyed)
                                 break;
index 32cf927..21de87c 100644 (file)
@@ -35,7 +35,8 @@ LND_LIBS +=   $(top_builddir)/lnet/ulnds/ptllnd/libptllnd.a
 endif
 
 LNET_LIBS =   $(top_builddir)/lnet/utils/libuptlctl.a \
-              $(top_builddir)/lnet/lnet/liblnet.a
+              $(top_builddir)/lnet/lnet/liblnet.a \
+              $(top_builddir)/libcfs/libcfs/libcfsutil.a
 
 SYSIO_LIBS =  $(SYSIO)/lib/libsysio.a
 
index c924aa4..80b410a 100644 (file)
 
 #undef LIST_HEAD
 
-#ifdef HAVE_ASM_TYPES_H
-#include <asm/types.h>
-#elif defined(HAVE_SYS_TYPES_H)
-#include <sys/types.h>
-#endif
-
 #ifdef HAVE_LINUX_UNISTD_H
 #include <linux/unistd.h>
 #elif defined(HAVE_UNISTD_H)
@@ -137,10 +131,10 @@ static int llu_dir_do_readpage(struct inode *inode, struct page *page)
         return rc;
 }
 
-static struct page *llu_dir_read_page(struct inode *ino, __u32 hash,
+static cfs_page_t *llu_dir_read_page(struct inode *ino, __u32 hash,
                                       int exact, struct ll_dir_chain *chain)
 {
-        struct page *page;
+        cfs_page_t *page;
         int rc;
         ENTRY;
 
@@ -211,7 +205,7 @@ ssize_t llu_iop_filldirentries(struct inode *dir, _SYSIO_OFF_T *basep,
         struct intnl_stat     *st = llu_i2stat(dir);
         loff_t                 pos = *basep;
         struct ll_dir_chain    chain;
-        struct page           *page;
+        cfs_page_t            *page;
         int filled = 0;
         int rc;
         int done;
index 1b41b63..406c235 100755 (executable)
@@ -76,6 +76,7 @@ build_obj_list ../lvfs liblvfs.a
 # lnet components libs
 build_obj_list ../../lnet/utils libuptlctl.a
 build_obj_list ../../libcfs/libcfs libcfs.a
+build_obj_list ../../libcfs/libcfs libcfsutil.a
 if $(echo "$LND_LIBS" | grep "socklnd" >/dev/null) ; then
        build_obj_list ../../lnet/ulnds/socklnd libsocklnd.a
 fi
index 8f0e23a..99ad0cf 100644 (file)
@@ -74,14 +74,14 @@ struct llu_io_group
         int                     lig_npages;
         __u64                   lig_rwcount;
         struct ll_async_page   *lig_llaps;
-        struct page            *lig_pages;
+        cfs_page_t             *lig_pages;
         void                   *lig_llap_cookies;
 };
 
 #define LLU_IO_GROUP_SIZE(x) \
         (sizeof(struct llu_io_group) + \
          (sizeof(struct ll_async_page) + \
-          sizeof(struct page) + \
+          sizeof(cfs_page_t) + \
           llap_cookie_size) * (x))
 
 struct llu_io_session
@@ -417,7 +417,7 @@ struct ll_async_page {
         int             llap_magic;
         void           *llap_cookie;
         int             llap_queued;
-        struct page    *llap_page;
+        cfs_page_t     *llap_page;
         struct inode   *llap_inode;
 };
 
@@ -461,7 +461,7 @@ static void llu_ap_update_obdo(void *data, int cmd, struct obdo *oa,
 static int llu_ap_completion(void *data, int cmd, struct obdo *oa, int rc)
 {
         struct ll_async_page *llap;
-        struct page *page;
+        cfs_page_t *page;
         ENTRY;
 
         llap = LLAP_FROM_COOKIE(data);
@@ -497,7 +497,7 @@ static int llu_queue_pio(int cmd, struct llu_io_group *group,
         struct intnl_stat *st = llu_i2stat(group->lig_inode);
         struct lov_stripe_md *lsm = lli->lli_smd;
         struct obd_export *exp = llu_i2obdexp(group->lig_inode);
-        struct page *pages = &group->lig_pages[group->lig_npages],*page = pages;
+        cfs_page_t *pages = &group->lig_pages[group->lig_npages],*page = pages;
         struct ll_async_page *llap = &group->lig_llaps[group->lig_npages];
         void *llap_cookie = group->lig_llap_cookies +
                 llap_cookie_size * group->lig_npages;
@@ -639,7 +639,7 @@ struct llu_io_group * get_io_group(struct inode *inode, int maxpages,
         group->lig_maxpages = maxpages;
         group->lig_params = params;
         group->lig_llaps = (struct ll_async_page *)(group + 1);
-        group->lig_pages = (struct page *)(&group->lig_llaps[maxpages]);
+        group->lig_pages = (cfs_page_t *)(&group->lig_llaps[maxpages]);
         group->lig_llap_cookies = (void *)(&group->lig_pages[maxpages]);
 
         rc = oig_init(&group->lig_oig);
index c36d26b..14fc9f4 100644 (file)
@@ -52,8 +52,6 @@
 #include <liblustre.h>
 #endif
 
-#include <linux/ext2_fs.h>
-
 #include <lustre/lustre_idl.h>
 #include <lustre_log.h>
 #include <obd_support.h>
index b0de820..18216d5 100644 (file)
@@ -149,10 +149,9 @@ int __obd_fail_timeout_set(__u32 id, __u32 value, int ms, int set)
         if (ret) {
                 CERROR("obd_fail_timeout id %x sleeping for %dms\n",
                        id, ms);
-                set_current_state(TASK_UNINTERRUPTIBLE);
                 cfs_schedule_timeout(CFS_TASK_UNINT,
                                      cfs_time_seconds(ms) / 1000);
-                set_current_state(TASK_RUNNING);
+                set_current_state(CFS_TASK_RUNNING);
                 CERROR("obd_fail_timeout id %x awake\n", id);
         }
         return ret;
index e65ddfa..da0bd7b 100644 (file)
@@ -52,7 +52,7 @@
 /* nr_free_pages() */
 #include <linux/swap.h>
 /* hash_long() */
-#include <linux/hash.h>
+#include <libcfs/libcfs_hash.h>
 #include <obd_support.h>
 #include <lustre_disk.h>
 #include <lustre_fid.h>
index 69ded40..bfd613a 100644 (file)
@@ -523,7 +523,6 @@ static int echo_cleanup(struct obd_device *obd)
 
         /* XXX Bug 3413; wait for a bit to ensure the BL callback has
          * happened before calling ldlm_namespace_free() */
-        set_current_state (TASK_UNINTERRUPTIBLE);
         cfs_schedule_timeout (CFS_TASK_UNINT, cfs_time_seconds(1));
 
         ldlm_namespace_free(obd->obd_namespace, NULL, obd->obd_force);
index 4948ecb..e28dba3 100644 (file)
@@ -483,7 +483,7 @@ int sptlrpc_req_replace_dead_ctx(struct ptlrpc_request *req)
                 CWARN("ctx (%p, fl %lx) doesn't switch, relax a little bit\n",
                       newctx, newctx->cc_flags);
 
-                schedule_timeout(HZ);
+                cfs_schedule_timeout(CFS_TASK_INTERRUPTIBLE, HZ);
         } else {
                 rc = sptlrpc_req_ctx_switch(req, oldctx, newctx);
                 if (rc) {
@@ -809,7 +809,7 @@ int sptlrpc_import_check_ctx(struct obd_import *imp)
         spin_lock_init(&req->rq_lock);
         atomic_set(&req->rq_refcount, 10000);
         CFS_INIT_LIST_HEAD(&req->rq_ctx_chain);
-        init_waitqueue_head(&req->rq_reply_waitq);
+        cfs_waitq_init(&req->rq_reply_waitq);
         req->rq_import = imp;
         req->rq_cli_ctx = ctx;
 
index 8772224..c39ce2a 100755 (executable)
@@ -47,6 +47,7 @@
 #include <signal.h>
 #include <stdlib.h>
 #include <unistd.h>
+#include <libcfs/libcfs.h>
 #include <lustre/liblustreapi.h>
 
 #define T1 "write data before unlink\n"
index ecf8d78..c8087e7 100644 (file)
@@ -50,6 +50,7 @@
 #include <sys/wait.h>
 #include <sys/ioctl.h>
 
+#include <libcfs/libcfs.h>
 #include <lustre/lustre_user.h>
 #ifndef O_DIRECT
 #define O_DIRECT 0
index 821363a..4218b59 100644 (file)
@@ -51,6 +51,7 @@
 #include <string.h>
 #include <stdlib.h>
 #include <unistd.h>
+#include <libcfs/libcfs.h>
 #include <lustre/lustre_user.h>
 
 typedef struct flag_mapping {
index aa02674..19b7d41 100644 (file)
@@ -8,7 +8,7 @@ AM_CFLAGS=$(LLCFLAGS)
 AM_CPPFLAGS=$(LLCPPFLAGS) -DLUSTRE_UTILS=1
 AM_LDFLAGS := -L$(top_builddir)/lnet/utils
 
-LIBPTLCTL := $(top_builddir)/lnet/utils/libptlctl.a
+LIBPTLCTL := $(top_builddir)/lnet/utils/libptlctl.a $(top_builddir)/libcfs/libcfs/libcfsutil.a
 
 sbin_scripts = lrun
 bin_scripts = llstat llobdstat plot-llstat llbackup
@@ -32,11 +32,11 @@ endif # UTILS
 
 lib_LIBRARIES = liblustreapi.a libiam.a
 
-lctl_SOURCES = parser.c obd.c lustre_cfg.c lctl.c parser.h obdctl.h platform.h
+lctl_SOURCES = obd.c lustre_cfg.c lctl.c obdctl.h
 lctl_LDADD := $(LIBREADLINE) $(LIBPTLCTL)
 lctl_DEPENDENCIES := $(LIBPTLCTL)
 
-lfs_SOURCES = lfs.c parser.c obd.c lustre_cfg.c
+lfs_SOURCES = lfs.c obd.c lustre_cfg.c
 lfs_LDADD := $(LIBREADLINE) liblustreapi.a $(LIBPTLCTL)
 lfs_DEPENDENCIES := $(LIBPTLCTL) liblustreapi.a 
 
index 5da8cb2..180b98f 100644 (file)
@@ -6,7 +6,7 @@ AM_CFLAGS=$(LLCFLAGS)
 AM_CPPFLAGS=$(LLCPPFLAGS) -DLUSTRE_UTILS=1
 AM_LDFLAGS := -L$(top_builddir)/libcfs/libcfs
 
-LIBCFS := $(top_builddir)/libcfs/libcfs/libcfs.a
+LIBCFS := $(top_builddir)/libcfs/libcfs/libcfs.a $(top_builddir)/libcfs/libcfs/libcfsutil.a
 
 sbin_PROGRAMS := lsvcgssd l_idmap
 
@@ -73,6 +73,8 @@ l_idmap_SOURCES = \
        \
        lsupport.h
 
+l_idmap_LDADD = $(LIBCFS)
+
 lgss_keyring_SOURCES = \
        lgss_keyring.c \
        context.c \
index d640a56..67747e1 100644 (file)
@@ -336,272 +336,6 @@ int lnet_nid2hostname(lnet_nid_t nid, char *buf, int buflen)
 
 
 /****************************************
- * lnet support routine                 *
- * (from lnet/libcfs/nidstrings.c       *
- ****************************************/
-
-#define LNET_NIDSTR_SIZE   32      /* size of each one (see below for usage) */
-
-static int  libcfs_lo_str2addr(char *str, int nob, uint32_t *addr);
-static void libcfs_ip_addr2str(uint32_t addr, char *str);
-static int  libcfs_ip_str2addr(char *str, int nob, uint32_t *addr);
-static void libcfs_decnum_addr2str(uint32_t addr, char *str);
-static void libcfs_hexnum_addr2str(uint32_t addr, char *str);
-static int  libcfs_num_str2addr(char *str, int nob, uint32_t *addr);
-
-struct netstrfns {
-        int          nf_type;
-        char        *nf_name;
-        char        *nf_modname;
-        void       (*nf_addr2str)(uint32_t addr, char *str);
-        int        (*nf_str2addr)(char *str, int nob, uint32_t *addr);
-};
-
-static struct netstrfns  libcfs_netstrfns[] = {
-        {/* .nf_type      */  LOLND,
-         /* .nf_name      */  "lo",
-         /* .nf_modname   */  "klolnd",
-         /* .nf_addr2str  */  libcfs_decnum_addr2str,
-         /* .nf_str2addr  */  libcfs_lo_str2addr},
-        {/* .nf_type      */  SOCKLND,
-         /* .nf_name      */  "tcp",
-         /* .nf_modname   */  "ksocklnd",
-         /* .nf_addr2str  */  libcfs_ip_addr2str,
-         /* .nf_str2addr  */  libcfs_ip_str2addr},
-        {/* .nf_type      */  O2IBLND,
-         /* .nf_name      */  "o2ib",
-         /* .nf_modname   */  "ko2iblnd",
-         /* .nf_addr2str  */  libcfs_ip_addr2str,
-         /* .nf_str2addr  */  libcfs_ip_str2addr},
-        {/* .nf_type      */  CIBLND,
-         /* .nf_name      */  "cib",
-         /* .nf_modname   */  "kciblnd",
-         /* .nf_addr2str  */  libcfs_ip_addr2str,
-         /* .nf_str2addr  */  libcfs_ip_str2addr},
-        {/* .nf_type      */  OPENIBLND,
-         /* .nf_name      */  "openib",
-         /* .nf_modname   */  "kopeniblnd",
-         /* .nf_addr2str  */  libcfs_ip_addr2str,
-         /* .nf_str2addr  */  libcfs_ip_str2addr},
-        {/* .nf_type      */  IIBLND,
-         /* .nf_name      */  "iib",
-         /* .nf_modname   */  "kiiblnd",
-         /* .nf_addr2str  */  libcfs_ip_addr2str,
-         /* .nf_str2addr  */  libcfs_ip_str2addr},
-        {/* .nf_type      */  VIBLND,
-         /* .nf_name      */  "vib",
-         /* .nf_modname   */  "kviblnd",
-         /* .nf_addr2str  */  libcfs_ip_addr2str,
-         /* .nf_str2addr  */  libcfs_ip_str2addr},
-        {/* .nf_type      */  RALND,
-         /* .nf_name      */  "ra",
-         /* .nf_modname   */  "kralnd",
-         /* .nf_addr2str  */  libcfs_ip_addr2str,
-         /* .nf_str2addr  */  libcfs_ip_str2addr},
-        {/* .nf_type      */  QSWLND,
-         /* .nf_name      */  "elan",
-         /* .nf_modname   */  "kqswlnd",
-         /* .nf_addr2str  */  libcfs_decnum_addr2str,
-         /* .nf_str2addr  */  libcfs_num_str2addr},
-        {/* .nf_type      */  GMLND,
-         /* .nf_name      */  "gm",
-         /* .nf_modname   */  "kgmlnd",
-         /* .nf_addr2str  */  libcfs_hexnum_addr2str,
-         /* .nf_str2addr  */  libcfs_num_str2addr},
-        {/* .nf_type      */  PTLLND,
-         /* .nf_name      */  "ptl",
-         /* .nf_modname   */  "kptllnd",
-         /* .nf_addr2str  */  libcfs_decnum_addr2str,
-         /* .nf_str2addr  */  libcfs_num_str2addr},
-        /* placeholder for net0 alias.  It MUST BE THE LAST ENTRY */
-        {/* .nf_type      */  -1},
-};
-
-const int libcfs_nnetstrfns = sizeof(libcfs_netstrfns)/sizeof(libcfs_netstrfns[0]);
-
-static int
-libcfs_lo_str2addr(char *str, int nob, uint32_t *addr)
-{
-        *addr = 0;
-        return 1;
-}
-
-static void
-libcfs_ip_addr2str(uint32_t addr, char *str)
-{
-        snprintf(str, LNET_NIDSTR_SIZE, "%u.%u.%u.%u",
-                 (addr >> 24) & 0xff, (addr >> 16) & 0xff,
-                 (addr >> 8) & 0xff, addr & 0xff);
-}
-
-/* CAVEAT EMPTOR XscanfX
- * I use "%n" at the end of a sscanf format to detect trailing junk.  However
- * sscanf may return immediately if it sees the terminating '0' in a string, so
- * I initialise the %n variable to the expected length.  If sscanf sets it;
- * fine, if it doesn't, then the scan ended at the end of the string, which is
- * fine too :) */
-
-static int
-libcfs_ip_str2addr(char *str, int nob, uint32_t *addr)
-{
-        int   a;
-        int   b;
-        int   c;
-        int   d;
-        int   n = nob;                          /* XscanfX */
-
-        /* numeric IP? */
-        if (sscanf(str, "%u.%u.%u.%u%n", &a, &b, &c, &d, &n) >= 4 &&
-            n == nob &&
-            (a & ~0xff) == 0 && (b & ~0xff) == 0 &&
-            (c & ~0xff) == 0 && (d & ~0xff) == 0) {
-                *addr = ((a<<24)|(b<<16)|(c<<8)|d);
-                return 1;
-        }
-
-#ifdef HAVE_GETHOSTBYNAME
-        /* known hostname? */
-        if (('a' <= str[0] && str[0] <= 'z') ||
-            ('A' <= str[0] && str[0] <= 'Z')) {
-                char *tmp;
-
-                tmp = malloc(nob + 1);
-                if (tmp != NULL) {
-                        struct hostent *he;
-
-                        memcpy(tmp, str, nob);
-                        tmp[nob] = 0;
-
-                        he = gethostbyname(tmp);
-
-                        free(tmp);
-                        tmp = NULL;
-
-                        if (he != NULL) {
-                                uint32_t ip = *(uint32_t *)he->h_addr;
-
-                                *addr = ntohl(ip);
-                                return 1;
-                        }
-                }
-        }
-#endif
-        return 0;
-}
-
-static void
-libcfs_decnum_addr2str(uint32_t addr, char *str)
-{
-        snprintf(str, LNET_NIDSTR_SIZE, "%u", addr);
-}
-
-static void
-libcfs_hexnum_addr2str(uint32_t addr, char *str)
-{
-        snprintf(str, LNET_NIDSTR_SIZE, "0x%x", addr);
-}
-
-static int
-libcfs_num_str2addr(char *str, int nob, uint32_t *addr)
-{
-        int     n;
-
-        n = nob;
-        if (sscanf(str, "0x%x%n", addr, &n) >= 1 && n == nob)
-                return 1;
-
-        n = nob;
-        if (sscanf(str, "0X%x%n", addr, &n) >= 1 && n == nob)
-                return 1;
-
-        n = nob;
-        if (sscanf(str, "%u%n", addr, &n) >= 1 && n == nob)
-                return 1;
-        
-        return 0;
-}
-
-static struct netstrfns *
-libcfs_lnd2netstrfns(int lnd)
-{
-        int    i;
-
-        if (lnd >= 0)
-                for (i = 0; i < libcfs_nnetstrfns; i++)
-                        if (lnd == libcfs_netstrfns[i].nf_type)
-                                return &libcfs_netstrfns[i];
-
-        return NULL;
-}
-
-static struct netstrfns *
-libcfs_str2net_internal(char *str, uint32_t *net)
-{
-        struct netstrfns *nf;
-        int               nob;
-        int               netnum;
-        int               i;
-
-        for (i = 0; i < libcfs_nnetstrfns; i++) {
-                nf = &libcfs_netstrfns[i];
-                if (nf->nf_type >= 0 &&
-                    !strncmp(str, nf->nf_name, strlen(nf->nf_name)))
-                        break;
-        }
-
-        if (i == libcfs_nnetstrfns)
-                return NULL;
-
-        nob = strlen(nf->nf_name);
-
-        if (strlen(str) == (unsigned int)nob) {
-                netnum = 0;
-        } else {
-                if (nf->nf_type == LOLND) /* net number not allowed */
-                        return NULL;
-
-                str += nob;
-                i = strlen(str);
-                if (sscanf(str, "%u%n", &netnum, &i) < 1 ||
-                    i != (int)strlen(str))
-                        return NULL;
-        }
-
-        *net = LNET_MKNET(nf->nf_type, netnum);
-        return nf;
-}
-
-/* FIXME
- * this is duplication in libcfs, but somehow doesn't make into libcfs.a.
- * remove it when libcfs get fixed.
- */
-lnet_nid_t
-libcfs_str2nid(const char *str)
-{
-        const char       *sep = strchr(str, '@');
-        struct netstrfns *nf;
-        uint32_t          net;
-        uint32_t          addr;
-
-        if (sep != NULL) {
-                nf = libcfs_str2net_internal(sep + 1, &net);
-                if (nf == NULL)
-                        return LNET_NID_ANY;
-        } else {
-                sep = str + strlen(str);
-                net = LNET_MKNET(SOCKLND, 0);
-                nf = libcfs_lnd2netstrfns(SOCKLND);
-                if (!nf)
-                        return LNET_NID_ANY;
-        }
-
-        if (!nf->nf_str2addr(str, sep - str, &addr))
-                return LNET_NID_ANY;
-
-        return LNET_MKNID(net, addr);
-}
-
-/****************************************
  * user mapping database handling       *
  * (very rudiment)                      *
  ****************************************/
index 7837a60..5d13293 100644 (file)
@@ -44,7 +44,7 @@
 #include <stdio.h>
 #include <lnet/lnetctl.h>
 #include "obdctl.h"
-#include "parser.h"
+#include <libcfs/libcfsutil.h>
 
 static int jt_quit(int argc, char **argv) {
         Parser_quit(argc, argv);
index 1c831c9..316dd9c 100644 (file)
@@ -65,7 +65,7 @@
 #include <lustre/liblustreapi.h>
 #include <lustre/lustre_user.h>
 
-#include "parser.h"
+#include <libcfs/libcfsutil.h>
 #include "obdctl.h"
 
 unsigned int libcfs_subsystem_debug = 0;
index 7e87054..9cd923f 100644 (file)
@@ -59,9 +59,6 @@
 #include <sys/types.h>
 #include <sys/syscall.h>
 #include <fnmatch.h>
-#ifdef HAVE_ASM_TYPES_H
-#include <asm/types.h>
-#endif
 #ifdef HAVE_LINUX_UNISTD_H
 #include <linux/unistd.h>
 #else
index 0f5f75b..e49c887 100644 (file)
@@ -58,7 +58,7 @@
 #include <sys/time.h>
 
 #include <lnet/lnetctl.h>
-#include "parser.h"
+#include <libcfs/libcfsutil.h>
 #include "obdctl.h"
 
 static char cmdname[512];
index 16ebdc7..5d4c50a 100644 (file)
@@ -69,7 +69,7 @@
 
 #include "obdctl.h"
 #include <lnet/lnetctl.h>
-#include "parser.h"
+#include <libcfs/libcfsutil.h>
 #include <stdio.h>
 
 static char * lcfg_devname;
index aaf6096..f3f84bb 100644 (file)
 #include <errno.h>
 #include <string.h>
 
-#ifdef HAVE_ASM_PAGE_H
-#include <asm/page.h>           /* needed for PAGE_SIZE - rread */
-#endif
-
 #include <obd_class.h>
 #include <lnet/lnetctl.h>
-#include "parser.h"
-#include "platform.h"
+#include <libcfs/libcfsutil.h>
 #include <stdio.h>
 
 #define MAX_STRING_SIZE 128
index d70ec60..f05f3b3 100644 (file)
@@ -43,7 +43,7 @@
 #include <stdio.h>
 
 #include "obdctl.h"
-#include "parser.h"
+#include <libcfs/libcfsutil.h>
 
 /* the functions that were in here are now in obd.c */
 
diff --git a/lustre/utils/parser.c b/lustre/utils/parser.c
deleted file mode 100644 (file)
index 23fece4..0000000
+++ /dev/null
@@ -1,786 +0,0 @@
-/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
- * vim:expandtab:shiftwidth=8:tabstop=8:
- *
- * 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 [sun.com URL with a
- * copy of GPLv2].
- *
- * 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  2008 Sun Microsystems, Inc. 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.
- */
-#include <stdio.h>
-#include <stdlib.h>
-#include <ctype.h>
-#include <string.h>
-#include <stddef.h>
-#include <unistd.h>
-#include <sys/param.h>
-#include <assert.h>
-
-#include "platform.h"
-#include "parser.h"
-
-static command_t * top_level;           /* Top level of commands, initialized by
-                                    * InitParser                              */
-static char * parser_prompt = NULL;/* Parser prompt, set by InitParser      */
-static int done;                   /* Set to 1 if user types exit or quit   */
-static int ignore_errors;       /* Normally, the parser will quit when
-                                   an error occurs in non-interacive
-                                   mode. Setting this to non-zero will
-                                   force it to keep buggering on. */
-
-
-/* static functions */
-static char *skipwhitespace(char *s);
-static char *skiptowhitespace(char *s);
-static command_t *find_cmd(char *name, command_t cmds[], char **next);
-static int process(char *s, char **next, command_t *lookup, command_t **result,
-                   char **prev);
-static void print_commands(char *str, command_t *table);
-
-static char * skipwhitespace(char * s)
-{
-        char * t;
-        int    len;
-
-        len = (int)strlen(s);
-        for (t = s; t <= s + len && isspace(*t); t++);
-        return(t);
-}
-
-
-static char * skiptowhitespace(char * s)
-{
-        char * t;
-
-        for (t = s; *t && !isspace(*t); t++);
-        return(t);
-}
-
-static int line2args(char *line, char **argv, int maxargs)
-{
-        char *arg;
-        int i = 0;
-
-        arg = strtok(line, " \t");
-        if ( arg ) {
-                argv[i] = arg;
-                i++;
-        } else
-                return 0;
-
-        while( (arg = strtok(NULL, " \t")) && (i <= maxargs)) {
-                argv[i] = arg;
-                i++;
-        }
-        return i;
-}
-
-/* find a command -- return it if unique otherwise print alternatives */
-static command_t *Parser_findargcmd(char *name, command_t cmds[])
-{
-        command_t *cmd;
-
-        for (cmd = cmds; cmd->pc_name; cmd++) {
-                if (strcmp(name, cmd->pc_name) == 0)
-                        return cmd;
-        }
-        return NULL;
-}
-
-void Parser_ignore_errors(int ignore)
-{
-        ignore_errors = ignore;
-}
-
-int Parser_execarg(int argc, char **argv, command_t cmds[])
-{
-        command_t *cmd;
-
-        cmd = Parser_findargcmd(argv[0], cmds);
-        if ( cmd ) {
-                int rc = (cmd->pc_func)(argc, argv);
-                if (rc == CMD_HELP)
-                        fprintf(stderr, "%s\n", cmd->pc_help);
-                return rc;
-        } else {
-               printf("Try interactive use without arguments or use one of:\n");
-                for (cmd = cmds; cmd->pc_name; cmd++)
-                        printf("\"%s\"\n", cmd->pc_name);
-                printf("as argument.\n");
-        }
-        return -1;
-}
-
-/* returns the command_t * (NULL if not found) corresponding to a
-   _partial_ match with the first token in name.  It sets *next to
-   point to the following token. Does not modify *name. */
-static command_t * find_cmd(char * name, command_t cmds[], char ** next)
-{
-        int    i, len;
-
-        if (!cmds || !name )
-                return NULL;
-
-        /* This sets name to point to the first non-white space character,
-           and next to the first whitespace after name, len to the length: do
-           this with strtok*/
-        name = skipwhitespace(name);
-        *next = skiptowhitespace(name);
-        len = *next - name;
-        if (len == 0)
-                return NULL;
-
-        for (i = 0; cmds[i].pc_name; i++) {
-                if (strncasecmp(name, cmds[i].pc_name, len) == 0) {
-                        *next = skipwhitespace(*next);
-                        return(&cmds[i]);
-                }
-        }
-        return NULL;
-}
-
-/* Recursively process a command line string s and find the command
-   corresponding to it. This can be ambiguous, full, incomplete,
-   non-existent. */
-static int process(char *s, char ** next, command_t *lookup,
-                   command_t **result, char **prev)
-{
-        *result = find_cmd(s, lookup, next);
-        *prev = s;
-
-        /* non existent */
-        if (!*result)
-                return CMD_NONE;
-
-        /* found entry: is it ambigous, i.e. not exact command name and
-           more than one command in the list matches.  Note that find_cmd
-           points to the first ambiguous entry */
-        if (strncasecmp(s, (*result)->pc_name, strlen((*result)->pc_name))) {
-                char *another_next;
-                command_t *another_result = find_cmd(s, (*result) + 1,
-                                                     &another_next);
-                int found_another = 0;
-
-                while (another_result) {
-                        if (strncasecmp(s, another_result->pc_name,
-                                        strlen(another_result->pc_name)) == 0){
-                                *result = another_result;
-                                *next = another_next;
-                                goto got_it;
-                        }
-                        another_result = find_cmd(s, another_result + 1,
-                                                  &another_next);
-                        found_another = 1;
-                }
-                if (found_another)
-                        return CMD_AMBIG;
-        }
-
-got_it:
-        /* found a unique command: component or full? */
-        if ( (*result)->pc_func ) {
-                return CMD_COMPLETE;
-        } else {
-                if ( *next == '\0' ) {
-                        return CMD_INCOMPLETE;
-                } else {
-                        return process(*next, next, (*result)->pc_sub_cmd,
-                                       result, prev);
-                }
-        }
-}
-
-#ifdef HAVE_LIBREADLINE
-static command_t * match_tbl;   /* Command completion against this table */
-static char * command_generator(const char * text, int state)
-{
-        static int index,
-                len;
-        char       *name;
-
-        /* Do we have a match table? */
-        if (!match_tbl)
-                return NULL;
-
-        /* If this is the first time called on this word, state is 0 */
-        if (!state) {
-                index = 0;
-                len = (int)strlen(text);
-        }
-
-        /* Return next name in the command list that paritally matches test */
-        while ( (name = (match_tbl + index)->pc_name) ) {
-                index++;
-
-                if (strncasecmp(name, text, len) == 0) {
-                        return(strdup(name));
-                }
-        }
-
-        /* No more matches */
-        return NULL;
-}
-
-/* probably called by readline */
-static char **command_completion(char * text, int start, int end)
-{
-        command_t   * table;
-        char        * pos;
-
-        match_tbl = top_level;
-        
-        for (table = find_cmd(rl_line_buffer, match_tbl, &pos);
-             table; table = find_cmd(pos, match_tbl, &pos)) 
-        {
-
-                if (*(pos - 1) == ' ') match_tbl = table->pc_sub_cmd;
-        }
-
-        return completion_matches(text, command_generator);
-}
-#endif
-
-/* take a string and execute the function or print help */
-int execute_line(char * line)
-{
-        command_t         *cmd, *ambig;
-        char *prev;
-        char *next, *tmp;
-        char *argv[MAXARGS];
-        int         i;
-        int rc = 0;
-
-        switch (process(line, &next, top_level, &cmd, &prev)) {
-        case CMD_AMBIG:
-                fprintf(stderr, "Ambiguous command \'%s\'\nOptions: ", line);
-                while( (ambig = find_cmd(prev, cmd, &tmp)) ) {
-                        fprintf(stderr, "%s ", ambig->pc_name);
-                        cmd = ambig + 1;
-                }
-                fprintf(stderr, "\n");
-                break;
-        case CMD_NONE:
-                fprintf(stderr, "No such command, type help\n");
-                break;
-        case CMD_INCOMPLETE:
-                fprintf(stderr,
-                        "'%s' incomplete command.  Use '%s x' where x is one of:\n",
-                        line, line);
-                fprintf(stderr, "\t");
-                for (i = 0; cmd->pc_sub_cmd[i].pc_name; i++) {
-                        fprintf(stderr, "%s ", cmd->pc_sub_cmd[i].pc_name);
-                }
-                fprintf(stderr, "\n");
-                break;
-        case CMD_COMPLETE:
-                i = line2args(line, argv, MAXARGS);
-                rc = (cmd->pc_func)(i, argv);
-
-                if (rc == CMD_HELP)
-                        fprintf(stderr, "%s\n", cmd->pc_help);
-
-                break;
-        }
-
-        return rc;
-}
-
-int
-noop_fn ()
-{
-        return (0);
-}
-
-/* just in case you're ever in an airplane and discover you
-   forgot to install readline-dev. :) */
-int init_input()
-{
-        int   interactive = isatty (fileno (stdin));
-
-#ifdef HAVE_LIBREADLINE
-        using_history();
-        stifle_history(HISTORY);
-
-        if (!interactive)
-        {
-                rl_prep_term_function = (rl_vintfunc_t *)noop_fn;
-                rl_deprep_term_function = (rl_voidfunc_t *)noop_fn;
-        }
-
-        rl_attempted_completion_function = (CPPFunction *)command_completion;
-        rl_completion_entry_function = (void *)command_generator;
-#endif
-        return interactive;
-}
-
-#ifndef HAVE_LIBREADLINE
-#define add_history(s)
-char * readline(char * prompt)
-{
-        int size = 2048;
-        char *line = malloc(size);
-        char *ptr = line;
-        int c;
-        int eof = 0;
-
-        if (line == NULL)
-                return NULL;
-        if (prompt)
-                printf ("%s", prompt);
-
-        while (1) {
-                if ((c = fgetc(stdin)) != EOF) {
-                        if (c == '\n')
-                                goto out;
-                        *ptr++ = c;
-
-                        if (ptr - line >= size - 1) {
-                                char *tmp;
-
-                                size *= 2;
-                                tmp = malloc(size);
-                                if (tmp == NULL)
-                                        goto outfree;
-                                memcpy(tmp, line, ptr - line);
-                                ptr = tmp + (ptr - line);
-                                free(line);
-                                line = tmp;
-                        }
-                } else {
-                        eof = 1;
-                        if (ferror(stdin) || feof(stdin))
-                                goto outfree;
-                        goto out;
-                }
-        }
-out:
-        *ptr = 0;
-        if (eof && (strlen(line) == 0)) {
-                free(line);
-                line = NULL;
-        }
-        return line;
-outfree:
-        free(line);
-        return NULL;
-}
-#endif
-
-/* this is the command execution machine */
-int Parser_commands(void)
-{
-        char *line, *s;
-        int rc = 0, save_error = 0;
-        int interactive;
-
-        interactive = init_input();
-
-        while(!done) {
-                line = readline(interactive ? parser_prompt : NULL);
-
-                if (!line) break;
-
-                s = skipwhitespace(line);
-
-                if (*s) {
-                        add_history(s);
-                        rc = execute_line(s);
-                }
-                /* stop on error if not-interactive */
-                if (rc != 0 && !interactive) {
-                        if (save_error == 0)
-                                save_error = rc;
-                        if (!ignore_errors)
-                                done = 1;
-                }
-
-                free(line);
-        }
-        if (save_error)
-                rc = save_error;
-        return rc;
-}
-
-
-/* sets the parser prompt */
-void Parser_init(char * prompt, command_t * cmds)
-{
-        done = 0;
-        top_level = cmds;
-        if (parser_prompt) free(parser_prompt);
-        parser_prompt = strdup(prompt);
-}
-
-/* frees the parser prompt */
-void Parser_exit(int argc, char *argv[])
-{
-        done = 1;
-        free(parser_prompt);
-        parser_prompt = NULL;
-}
-
-/* convert a string to an integer */
-int Parser_int(char *s, int *val)
-{
-        int ret;
-
-        if (*s != '0')
-                ret = sscanf(s, "%d", val);
-        else if (*(s+1) != 'x')
-                ret = sscanf(s, "%o", val);
-        else {
-                s++;
-                ret = sscanf(++s, "%x", val);
-        }
-
-        return(ret);
-}
-
-
-void Parser_qhelp(int argc, char *argv[]) {
-
-        printf("Available commands are:\n");
-
-        print_commands(NULL, top_level);
-        printf("For more help type: help command-name\n");
-}
-
-int Parser_help(int argc, char **argv)
-{
-        char line[1024];
-        char *next, *prev, *tmp;
-        command_t *result, *ambig;
-        int i;
-
-        if ( argc == 1 ) {
-                Parser_qhelp(argc, argv);
-                return 0;
-        }
-
-        line[0]='\0';
-        for ( i = 1 ;  i < argc ; i++ ) {
-                strcat(line, argv[i]);
-        }
-
-        switch ( process(line, &next, top_level, &result, &prev) ) {
-        case CMD_COMPLETE:
-                fprintf(stderr, "%s: %s\n",line, result->pc_help);
-                break;
-        case CMD_NONE:
-                fprintf(stderr, "%s: Unknown command.\n", line);
-                break;
-        case CMD_INCOMPLETE:
-                fprintf(stderr,
-                        "'%s' incomplete command.  Use '%s x' where x is one of:\n",
-                        line, line);
-                fprintf(stderr, "\t");
-                for (i = 0; result->pc_sub_cmd[i].pc_name; i++) {
-                        fprintf(stderr, "%s ", result->pc_sub_cmd[i].pc_name);
-                }
-                fprintf(stderr, "\n");
-                break;
-        case CMD_AMBIG:
-                fprintf(stderr, "Ambiguous command \'%s\'\nOptions: ", line);
-                while( (ambig = find_cmd(prev, result, &tmp)) ) {
-                        fprintf(stderr, "%s ", ambig->pc_name);
-                        result = ambig + 1;
-                }
-                fprintf(stderr, "\n");
-                break;
-        }
-        return 0;
-}
-
-
-void Parser_printhelp(char *cmd)
-{
-        char *argv[] = { "help", cmd };
-        Parser_help(2, argv);
-}
-
-
-/*************************************************************************
- * COMMANDS                                                              *
- *************************************************************************/
-static void print_commands(char * str, command_t * table) {
-        command_t * cmds;
-        char         buf[80];
-
-        for (cmds = table; cmds->pc_name; cmds++) {
-                if (cmds->pc_func) {
-                        if (str) printf("\t%s %s\n", str, cmds->pc_name);
-                        else printf("\t%s\n", cmds->pc_name);
-                }
-                if (cmds->pc_sub_cmd) {
-                        if (str) {
-                                sprintf(buf, "%s %s", str, cmds->pc_name);
-                                print_commands(buf, cmds->pc_sub_cmd);
-                        } else {
-                                print_commands(cmds->pc_name, cmds->pc_sub_cmd);
-                        }
-                }
-        }
-}
-
-char *Parser_getstr(const char *prompt, const char *deft, char *res,
-                    size_t len)
-{
-        char *line = NULL;
-        int size = strlen(prompt) + strlen(deft) + 8;
-        char *theprompt;
-        theprompt = malloc(size);
-        assert(theprompt);
-
-        sprintf(theprompt, "%s [%s]: ", prompt, deft);
-
-        line  = readline(theprompt);
-        free(theprompt);
-
-        if ( line == NULL || *line == '\0' ) {
-                strncpy(res, deft, len);
-        } else {
-                strncpy(res, line, len);
-        }
-
-        if ( line ) {
-                free(line);
-                return res;
-        } else {
-                return NULL;
-        }
-}
-
-/* get integer from prompt, loop forever to get it */
-int Parser_getint(const char *prompt, long min, long max, long deft, int base)
-{
-        int rc;
-        long result;
-        char *line;
-        int size = strlen(prompt) + 40;
-        char *theprompt = malloc(size);
-        assert(theprompt);
-        sprintf(theprompt,"%s [%ld, (0x%lx)]: ", prompt, deft, deft);
-
-        fflush(stdout);
-
-        do {
-                line = NULL;
-                line = readline(theprompt);
-                if ( !line ) {
-                        fprintf(stdout, "Please enter an integer.\n");
-                        fflush(stdout);
-                        continue;
-                }
-                if ( *line == '\0' ) {
-                        free(line);
-                        result =  deft;
-                        break;
-                }
-                rc = Parser_arg2int(line, &result, base);
-                free(line);
-                if ( rc != 0 ) {
-                        fprintf(stdout, "Invalid string.\n");
-                        fflush(stdout);
-                } else if ( result > max || result < min ) {
-                        fprintf(stdout, "Error: response must lie between %ld and %ld.\n",
-                                min, max);
-                        fflush(stdout);
-                } else {
-                        break;
-                }
-        } while ( 1 ) ;
-
-        if (theprompt)
-                free(theprompt);
-        return result;
-
-}
-
-/* get boolean (starting with YyNn; loop forever */
-int Parser_getbool(const char *prompt, int deft)
-{
-        int result = 0;
-        char *line;
-        int size = strlen(prompt) + 8;
-        char *theprompt = malloc(size);
-        assert(theprompt);
-
-        fflush(stdout);
-
-        if ( deft != 0 && deft != 1 ) {
-                fprintf(stderr, "Error: Parser_getbool given bad default %d\n",
-                        deft);
-                assert ( 0 );
-        }
-        sprintf(theprompt, "%s [%s]: ", prompt, (deft==0)? "N" : "Y");
-
-        do {
-                line = NULL;
-                line = readline(theprompt);
-                if ( line == NULL ) {
-                        result = deft;
-                        break;
-                }
-                if ( *line == '\0' ) {
-                        result = deft;
-                        break;
-                }
-                if ( *line == 'y' || *line == 'Y' ) {
-                        result = 1;
-                        break;
-                }
-                if ( *line == 'n' || *line == 'N' ) {
-                        result = 0;
-                        break;
-                }
-                if ( line )
-                        free(line);
-                fprintf(stdout, "Invalid string. Must start with yY or nN\n");
-                fflush(stdout);
-        } while ( 1 );
-
-        if ( line )
-                free(line);
-        if ( theprompt )
-                free(theprompt);
-        return result;
-}
-
-/* parse int out of a string or prompt for it */
-long Parser_intarg(const char *inp, const char *prompt, int deft,
-                   int min, int max, int base)
-{
-        long result;
-        int rc;
-
-        rc = Parser_arg2int(inp, &result, base);
-
-        if ( rc == 0 ) {
-                return result;
-        } else {
-                return Parser_getint(prompt, deft, min, max, base);
-        }
-}
-
-/* parse int out of a string or prompt for it */
-char *Parser_strarg(char *inp, const char *prompt, const char *deft,
-                    char *answer, int len)
-{
-        if ( inp == NULL || *inp == '\0' ) {
-                return Parser_getstr(prompt, deft, answer, len);
-        } else
-                return inp;
-}
-
-/* change a string into a number: return 0 on success. No invalid characters
-   allowed. The processing of base and validity follows strtol(3)*/
-int Parser_arg2int(const char *inp, long *result, int base)
-{
-        char *endptr;
-
-        if ( (base !=0) && (base < 2 || base > 36) )
-                return 1;
-
-        *result = strtol(inp, &endptr, base);
-
-        if ( *inp != '\0' && *endptr == '\0' )
-                return 0;
-        else
-                return 1;
-}
-
-/* Convert human readable size string to and int; "1k" -> 1000 */
-int Parser_size (int *sizep, char *str) {
-        int size;
-        char mod[32];
-
-        switch (sscanf (str, "%d%1[gGmMkK]", &size, mod)) {
-        default:
-                return (-1);
-
-        case 1:
-                *sizep = size;
-                return (0);
-
-        case 2:
-                switch (*mod) {
-                case 'g':
-                case 'G':
-                        *sizep = size << 30;
-                        return (0);
-
-                case 'm':
-                case 'M':
-                        *sizep = size << 20;
-                        return (0);
-
-                case 'k':
-                case 'K':
-                        *sizep = size << 10;
-                        return (0);
-
-                default:
-                        *sizep = size;
-                        return (0);
-                }
-        }
-}
-
-/* Convert a string boolean to an int; "enable" -> 1 */
-int Parser_bool (int *b, char *str) {
-        if (!strcasecmp (str, "no") ||
-            !strcasecmp (str, "n") ||
-            !strcasecmp (str, "off") ||
-            !strcasecmp (str, "down") ||
-            !strcasecmp (str, "disable"))
-        {
-                *b = 0;
-                return (0);
-        }
-
-        if (!strcasecmp (str, "yes") ||
-            !strcasecmp (str, "y") ||
-            !strcasecmp (str, "on") ||
-            !strcasecmp (str, "up") ||
-            !strcasecmp (str, "enable"))
-        {
-                *b = 1;
-                return (0);
-        }
-
-        return (-1);
-}
-
-int Parser_quit(int argc, char **argv)
-{
-        argc = argc;
-        argv = argv;
-        done = 1;
-        return 0;
-}
diff --git a/lustre/utils/parser.h b/lustre/utils/parser.h
deleted file mode 100644 (file)
index 9459896..0000000
+++ /dev/null
@@ -1,110 +0,0 @@
-/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
- * vim:expandtab:shiftwidth=8:tabstop=8:
- *
- * 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 [sun.com URL with a
- * copy of GPLv2].
- *
- * 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  2008 Sun Microsystems, Inc. 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.
- */
-
-#ifndef _PARSER_H_
-#define _PARSER_H_
-
-#define HISTORY        100             /* Don't let history grow unbounded    */
-#define MAXARGS 512
-
-#define CMD_COMPLETE   0
-#define CMD_INCOMPLETE 1
-#define CMD_NONE       2
-#define CMD_AMBIG      3
-#define CMD_HELP       4
-
-typedef struct parser_cmd {
-       char    *pc_name;
-       int     (* pc_func)(int, char **);
-       struct parser_cmd * pc_sub_cmd;
-       char *pc_help;
-} command_t;
-
-typedef struct argcmd {
-       char    *ac_name;
-       int      (*ac_func)(int, char **);
-       char     *ac_help;
-} argcmd_t;
-
-typedef struct network {
-       char    *type;
-       char    *server;
-       int     port;
-} network_t;
-
-int  Parser_quit(int argc, char **argv);
-void Parser_init(char *, command_t *); /* Set prompt and load command list */
-int Parser_commands(void);                     /* Start the command parser */
-void Parser_qhelp(int, char **);       /* Quick help routine */
-int Parser_help(int, char **);         /* Detailed help routine */
-void Parser_ignore_errors(int ignore); /* Set the ignore errors flag */
-void Parser_printhelp(char *);         /* Detailed help routine */
-void Parser_exit(int, char **);                /* Shuts down command parser */
-int Parser_execarg(int argc, char **argv, command_t cmds[]);
-int execute_line(char * line);
-
-/* Converts a string to an integer */
-int Parser_int(char *, int *);
-
-/* Prompts for a string, with default values and a maximum length */
-char *Parser_getstr(const char *prompt, const char *deft, char *res, 
-                   size_t len);
-
-/* Prompts for an integer, with minimum, maximum and default values and base */
-int Parser_getint(const char *prompt, long min, long max, long deft,
-                 int base);
-
-/* Prompts for a yes/no, with default */
-int Parser_getbool(const char *prompt, int deft);
-
-/* Extracts an integer from a string, or prompts if it cannot get one */
-long Parser_intarg(const char *inp, const char *prompt, int deft,
-                  int min, int max, int base);
-
-/* Extracts a word from the input, or propmts if it cannot get one */
-char *Parser_strarg(char *inp, const char *prompt, const char *deft,
-                   char *answer, int len);
-
-/* Extracts an integer from a string  with a base */
-int Parser_arg2int(const char *inp, long *result, int base);
-
-/* Convert human readable size string to and int; "1k" -> 1000 */
-int Parser_size(int *sizep, char *str);
-
-/* Convert a string boolean to an int; "enable" -> 1 */
-int Parser_bool(int *b, char *str);
-
-#endif
diff --git a/lustre/utils/platform.h b/lustre/utils/platform.h
deleted file mode 100644 (file)
index 36b9c53..0000000
+++ /dev/null
@@ -1,262 +0,0 @@
-/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
- * vim:expandtab:shiftwidth=8:tabstop=8:
- *
- * 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 [sun.com URL with a
- * copy of GPLv2].
- *
- * 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  2008 Sun Microsystems, Inc. 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.
- */
-#ifndef __LUSTRE_UTILS_PLATFORM_H
-#define __LUSTRE_UTILS_PLATFORM_H
-
-#ifdef __linux__
-
-#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
-
-#elif __APPLE__
-
-#ifdef HAVE_LIBREADLINE
-#define READLINE_LIBRARY
-#include <readline/readline.h>
-typedef VFunction       rl_vintfunc_t;
-typedef VFunction       rl_voidfunc_t;
-#endif /* HAVE_LIBREADLINE */
-
-#include <stdlib.h>
-#include <errno.h>
-#include <sys/types.h>
-#include <fcntl.h>
-#include <stdio.h>
-#include <sys/shm.h>
-#include <sys/semaphore.h>
-
-/*
- * POSIX compliant inter-process synchronization aren't supported well
- * in Darwin, pthread_mutex_t and pthread_cond_t can only work as
- * inter-thread synchronization, they wouldn't work even being put in
- * shared memory for multi-process. PTHREAD_PROCESS_SHARED is not 
- * supported by Darwin also (pthread_mutexattr_setpshared() with the 
- * PTHREAD_PROCESS_SHARED attribute will return EINVAL). 
- *
- * The only inter-process sychronization mechanism can be used in Darwin
- * is POSIX NAMED semaphores and file lock, here we use NAMED semaphore
- * to implement mutex and condition. 
- *
- * XXX Liang:
- * They are just proto-type now, more tests are needed. 
- */
-#define L_LOCK_DEBUG           (0)             
-
-#define L_SEM_NAMESIZE         32
-
-typedef struct {
-       sem_t           *s_sem;
-#if L_LOCK_DEBUG
-       char            s_name[L_SEM_NAMESIZE];
-#endif
-} l_sem_t;
-
-typedef l_sem_t         l_mutex_t;
-
-typedef struct {
-       l_mutex_t       c_guard;
-       int             c_count;
-       l_sem_t         c_waiter;
-} l_cond_t;
-
-static inline int l_sem_init(l_sem_t *sem, int val)
-{
-       char *s_name;
-#if L_LOCK_DEBUG
-       s_name = sem->s_name;
-#else
-       char buf[L_SEM_NAMESIZE];
-       s_name = buf;
-#endif
-       /* get an unique name for named semaphore */
-       snprintf(s_name, L_SEM_NAMESIZE, "%d-%p", (int)getpid(), sem);
-       sem->s_sem = sem_open(s_name, O_CREAT, 0600, val);
-       if ((int)sem->s_sem == SEM_FAILED) {
-               fprintf(stderr, "lock %s creating fail: %d, %d!\n",
-                               s_name, (int)sem->s_sem, errno);
-               return -1;
-       } else {
-#if L_LOCK_DEBUG
-               printf("open lock: %s\n", s_name);
-#endif
-       }
-       return 0;
-}
-
-static inline void l_sem_done(l_sem_t *sem)
-{
-#if L_LOCK_DEBUG
-       printf("close lock: %s.\n", sem->s_name);
-#endif
-       sem_close(sem->s_sem);
-}
-
-static inline void l_sem_down(l_sem_t *sem)
-{
-#if L_LOCK_DEBUG
-       printf("sem down :%s\n", sem->s_name);
-#endif
-       sem_wait(sem->s_sem);
-}
-
-static inline void l_sem_up(l_sem_t *sem)
-{
-#if L_LOCK_DEBUG
-       printf("sem up  :%s\n", sem->s_name);
-#endif
-       sem_post(sem->s_sem);
-}
-
-static inline void l_mutex_init(l_mutex_t *mutex)
-{
-       l_sem_init((l_sem_t *)mutex, 1);
-}
-
-static inline void l_mutex_init_locked(l_mutex_t *mutex)
-{
-       l_sem_init((l_sem_t *)mutex, 0);
-}
-
-static inline void l_mutex_done(l_mutex_t *mutex)
-{
-       l_sem_done((l_sem_t *)mutex);
-}
-
-static inline void l_mutex_lock(l_mutex_t *mutex)
-{
-#if L_LOCK_DEBUG
-       printf("lock mutex  :%s\n", mutex->s_name);
-#endif
-       sem_wait(mutex->s_sem);
-}
-
-static inline void l_mutex_unlock(l_mutex_t *mutex)
-{
-#if L_LOCK_DEBUG
-       printf("unlock mutex: %s\n", mutex->s_name);
-#endif
-       sem_post(mutex->s_sem);
-}
-
-static inline void l_cond_init(l_cond_t *cond)
-{
-       l_mutex_init(&cond->c_guard);
-       l_sem_init(&cond->c_waiter, 0);
-       cond->c_count = 0;
-}
-
-static inline void l_cond_done(l_cond_t *cond)
-{
-       if (cond->c_count != 0)
-               fprintf(stderr, "your waiter list is not empty: %d!\n", cond->c_count);
-       l_mutex_done(&cond->c_guard);
-       l_sem_done(&cond->c_waiter);
-}
-
-static inline void l_cond_wait(l_cond_t *cond, l_mutex_t *lock)
-{
-       l_mutex_lock(&cond->c_guard);
-       cond->c_count --;
-       l_mutex_unlock(&cond->c_guard);
-       l_mutex_unlock(lock);
-       l_sem_down(&cond->c_waiter);
-       l_mutex_lock(lock);
-}
-
-static inline void l_cond_broadcast(l_cond_t *cond)
-{
-       l_mutex_lock(&cond->c_guard);
-       while (cond->c_count < 0) {
-               l_sem_up(&cond->c_waiter);
-               cond->c_count ++;
-       }
-       l_mutex_unlock(&cond->c_guard);
-}
-
-#else /* other platform */
-
-#ifdef HAVE_LIBREADLINE
-#define READLINE_LIBRARY
-#include <readline/readline.h>
-#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 /* HAVE_LIBPTHREAD */
-
-#endif /* __linux__  */
-
-#endif