+void schedule_timeout_and_set_state(long state, int64_t timeout)
+{
+ wait_queue_t l;
+ /* sleep(timeout) here instead? */
+ waitq_timedwait(&l, state, timeout);
+}
+
+void
- 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;
+ 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 ERR_PTR(rc);
+/* Read the environment variable of current process specified by @key. */
+int cfs_get_environ(const char *key, char *value, int *val_len)
+{
+ char *entry;
+ int len;
+
+ entry = getenv(key);
+ if (entry == NULL)
+ return -ENOENT;
+
+ len = strlcpy(value, entry, *val_len);
+ if (len >= *val_len)
+ return -EOVERFLOW;
+
+ return 0;
+}
-cfs_sigset_t cfs_block_sigs(cfs_sigset_t blocks)
+/* Block all signals except for the @sigs. It's only used in
+ * Linux kernel, just a dummy here. */
+sigset_t cfs_block_sigsinv(unsigned long sigs)
- cfs_sigset_t old;
- int rc;
-
- rc = sigprocmask(SIG_SETMASK, &blocks, &old);
- LASSERT (rc == 0);
+ sigset_t old;
+ int rc;
+
+ /* Return old blocked sigs */
+ rc = sigprocmask(SIG_SETMASK, NULL, &old);
+ LASSERT(rc == 0);
- libcfs_debug_msg(NULL, 0, D_EMERG, file, func, line, "LBUG\n");
+ libcfs_debug_msg(msgdata, "LBUG\n");