#ifndef __KERNEL__
+#include <libcfs/libcfs.h>
+#include <libcfs/kp30.h>
+
#include <sys/mman.h>
#ifndef __CYGWIN__
#include <stdint.h>
#include <signal.h>
#include <errno.h>
#include <sys/stat.h>
+#ifdef HAVE_SYS_VFS_H
#include <sys/vfs.h>
-
-#include <libcfs/libcfs.h>
-#include <libcfs/kp30.h>
+#endif
/*
* Sleep channel. No-op implementation.
(void)waitq;
}
-void cfs_waitq_broadcast(struct cfs_waitq *waitq, int state)
+void cfs_waitq_broadcast(struct cfs_waitq *waitq)
{
LASSERT(waitq != NULL);
(void)waitq;
}
-void cfs_waitq_wait(struct cfs_waitlink *link)
+void cfs_waitq_wait(struct cfs_waitlink *link, int state)
{
LASSERT(link != NULL);
(void)link;
return 0;
}
+#ifdef HAVE_LIBPTHREAD
+
+/*
+ * Threads
+ */
+
+struct lustre_thread_arg {
+ cfs_thread_t f;
+ void *arg;
+};
+static void *cfs_thread_helper(void *data)
+{
+ struct lustre_thread_arg *targ = data;
+ cfs_thread_t f = targ->f;
+ void *arg = targ->arg;
+
+ free(targ);
+
+ (void)f(arg);
+ return NULL;
+}
+int cfs_create_thread(cfs_thread_t func, void *arg)
+{
+ pthread_t tid;
+ pthread_attr_t tattr;
+ int rc;
+ struct lustre_thread_arg *targ_p = malloc(sizeof(struct lustre_thread_arg));
+
+ if ( targ_p == NULL )
+ return -ENOMEM;
+
+ targ_p->f = func;
+ targ_p->arg = arg;
+
+ pthread_attr_init(&tattr);
+ pthread_attr_setdetachstate(&tattr, PTHREAD_CREATE_DETACHED);
+ rc = pthread_create(&tid, &tattr, cfs_thread_helper, targ_p);
+ pthread_attr_destroy(&tattr);
+ return -rc;
+}
+#endif
+
+uid_t cfs_curproc_uid(void)
+{
+ return getuid();
+}
+
+int cfs_parse_int_tunable(int *value, char *name)
+{
+ char *env = getenv(name);
+ char *end;
+
+ if (env == NULL)
+ return 0;
+
+ *value = strtoull(env, &end, 0);
+ if (*end == 0)
+ return 0;
+
+ CERROR("Can't parse tunable %s=%s\n", name, env);
+ return -EINVAL;
+}
+
/*
* Allocator
*/
cfs_free(addr);
}
-/*
- * This uses user-visible declarations from <linux/kdev_t.h>
- */
-#ifdef __LINUX__
-#include <linux/kdev_t.h>
-#endif
-
void cfs_enter_debugger(void)
{
/*
return;
}
-#ifdef __LINUX__
+#ifdef __linux__
/*
* In glibc (NOT in Linux, so check above is not right), implement
return NULL;
}
-/* __LINUX__ */
+/* __linux__ */
#endif
void lbug_with_loc(char *file, const char *func, const int line)
abort();
}
-
/* !__KERNEL__ */
#endif