Whamcloud - gitweb
LU-2850 kernel: 3.8 upstream kills daemonize()
[fs/lustre-release.git] / libcfs / libcfs / winnt / winnt-prim.c
index ea47f5a..1d04567 100644 (file)
@@ -1,6 +1,4 @@
-/* -*- 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.
@@ -28,6 +26,8 @@
 /*
  * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
+ *
+ * Copyright (c) 2011, 2012, Intel Corporation.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
@@ -82,22 +82,22 @@ cfs_thread_proc(
 }
 
 /*
- * cfs_kernel_thread
+ * kthread_run
  *   Create a system thread to execute the routine specified
  *
  * Arguments:
  *   func:  function to be executed in the thread
  *   arg:   argument transferred to func function
- *   flag:  thread creation flags.
+ *   name:  thread name to create
  *
  * Return Value:
- *   int:   0 on success or error codes
+ *   cfs_task_t:   0 on success or error codes
  *
  * Notes:
  *   N/A
  */
 
-int cfs_kernel_thread(int (*func)(void *), void *arg, int flag)
+cfs_task_t kthread_run(int (*func)(void *), void *arg, char *name)
 {
     cfs_handle_t  thread = NULL;
     NTSTATUS      status;
@@ -108,7 +108,7 @@ int cfs_kernel_thread(int (*func)(void *), void *arg, int flag)
     context = cfs_alloc(sizeof(cfs_thread_context_t), CFS_ALLOC_ZERO);
 
     if (!context) {
-        return -ENOMEM;
+       return ERR_PTR(-ENOMEM);
     }
 
     context->func  = func;
@@ -130,7 +130,7 @@ int cfs_kernel_thread(int (*func)(void *), void *arg, int flag)
 
         /* We need translate the nt status to linux error code */
 
-        return cfs_error_code(status);
+       return ERR_PTR(cfs_error_code(status));
     }
 
     //
@@ -139,7 +139,7 @@ int cfs_kernel_thread(int (*func)(void *), void *arg, int flag)
 
     ZwClose(thread);
 
-    return 0;
+       return (cfs_task_t)0;
 }
 
 
@@ -148,7 +148,7 @@ int cfs_kernel_thread(int (*func)(void *), void *arg, int flag)
  */
 
 
-static CFS_DECLARE_RWSEM(cfs_symbol_lock);
+static DECLARE_RWSEM(cfs_symbol_lock);
 CFS_LIST_HEAD(cfs_symbol_list);
 
 int libcfs_is_mp_system = FALSE;
@@ -174,7 +174,7 @@ cfs_symbol_get(const char *name)
     cfs_list_t              *walker;
     struct cfs_symbol       *sym = NULL;
 
-    cfs_down_read(&cfs_symbol_lock);
+       down_read(&cfs_symbol_lock);
     cfs_list_for_each(walker, &cfs_symbol_list) {
         sym = cfs_list_entry (walker, struct cfs_symbol, sym_list);
         if (!strcmp(sym->name, name)) {
@@ -182,7 +182,7 @@ cfs_symbol_get(const char *name)
             break;
         }
     }
-    cfs_up_read(&cfs_symbol_lock);
+       up_read(&cfs_symbol_lock);
 
     if (sym != NULL)
         return sym->value;
@@ -210,7 +210,7 @@ cfs_symbol_put(const char *name)
     cfs_list_t              *walker;
     struct cfs_symbol       *sym = NULL;
 
-    cfs_down_read(&cfs_symbol_lock);
+       down_read(&cfs_symbol_lock);
     cfs_list_for_each(walker, &cfs_symbol_list) {
         sym = cfs_list_entry (walker, struct cfs_symbol, sym_list);
         if (!strcmp(sym->name, name)) {
@@ -219,7 +219,7 @@ cfs_symbol_put(const char *name)
             break;
         }
     }
-    cfs_up_read(&cfs_symbol_lock);
+       up_read(&cfs_symbol_lock);
 
     LASSERT(sym != NULL);
 }
@@ -257,17 +257,17 @@ cfs_symbol_register(const char *name, const void *value)
     new->ref = 0;
     CFS_INIT_LIST_HEAD(&new->sym_list);
 
-    cfs_down_write(&cfs_symbol_lock);
-    cfs_list_for_each(walker, &cfs_symbol_list) {
-        sym = cfs_list_entry (walker, struct cfs_symbol, sym_list);
-        if (!strcmp(sym->name, name)) {
-            cfs_up_write(&cfs_symbol_lock);
-            cfs_free(new);
-            return 0; // alreay registerred
-        }
-    }
-    cfs_list_add_tail(&new->sym_list, &cfs_symbol_list);
-    cfs_up_write(&cfs_symbol_lock);
+       down_write(&cfs_symbol_lock);
+       cfs_list_for_each(walker, &cfs_symbol_list) {
+               sym = cfs_list_entry (walker, struct cfs_symbol, sym_list);
+               if (!strcmp(sym->name, name)) {
+                       up_write(&cfs_symbol_lock);
+                       cfs_free(new);
+                       return 0; /* alreay registerred */
+               }
+       }
+       cfs_list_add_tail(&new->sym_list, &cfs_symbol_list);
+       up_write(&cfs_symbol_lock);
 
     return 0;
 }
@@ -293,7 +293,7 @@ cfs_symbol_unregister(const char *name)
     cfs_list_t              *nxt;
     struct cfs_symbol       *sym = NULL;
 
-    cfs_down_write(&cfs_symbol_lock);
+       down_write(&cfs_symbol_lock);
     cfs_list_for_each_safe(walker, nxt, &cfs_symbol_list) {
         sym = cfs_list_entry (walker, struct cfs_symbol, sym_list);
         if (!strcmp(sym->name, name)) {
@@ -303,7 +303,7 @@ cfs_symbol_unregister(const char *name)
             break;
         }
     }
-    cfs_up_write(&cfs_symbol_lock);
+       up_write(&cfs_symbol_lock);
 }
 
 /*
@@ -326,15 +326,15 @@ cfs_symbol_clean()
     cfs_list_t          *walker;
     struct cfs_symbol   *sym = NULL;
 
-    cfs_down_write(&cfs_symbol_lock);
-    cfs_list_for_each(walker, &cfs_symbol_list) {
-        sym = cfs_list_entry (walker, struct cfs_symbol, sym_list);
-        LASSERT(sym->ref == 0);
-        cfs_list_del (&sym->sym_list);
-        cfs_free(sym);
-    }
-    cfs_up_write(&cfs_symbol_lock);
-    return;
+       down_write(&cfs_symbol_lock);
+       cfs_list_for_each(walker, &cfs_symbol_list) {
+               sym = cfs_list_entry (walker, struct cfs_symbol, sym_list);
+               LASSERT(sym->ref == 0);
+               cfs_list_del (&sym->sym_list);
+               cfs_free(sym);
+       }
+       up_write(&cfs_symbol_lock);
+       return;
 }
 
 
@@ -529,18 +529,9 @@ cfs_time_t cfs_timer_deadline(cfs_timer_t * timer)
     return timer->deadline;
 }
 
-/*
- * daemonize routine stub
- */
-
-void cfs_daemonize(char *str)
+int unshare_fs_struct()
 {
-    return;
-}
-
-int cfs_daemonize_ctxt(char *str) {
-    cfs_daemonize(str);
-    return 0;
+       return 0;
 }
 
 /*
@@ -557,6 +548,13 @@ cfs_sigset_t cfs_block_sigs(sigset_t bit)
         return 0;
 }
 
+/* Block all signals except for the @sigs. It's only used in
+ * Linux kernel, just a dummy here. */
+cfs_sigset_t cfs_block_sigsinv(unsigned long sigs)
+{
+        return 0;
+}
+
 void cfs_restore_sigs(cfs_sigset_t old)
 {
 }
@@ -754,16 +752,16 @@ void cfs_libc_init();
 int
 libcfs_arch_init(void)
 {
-    int         rc;
-
-    cfs_spinlock_t  lock;
-    /* Workground to check the system is MP build or UP build */
-    cfs_spin_lock_init(&lock);
-    cfs_spin_lock(&lock);
-    libcfs_is_mp_system = (int)lock.lock;
-    /* MP build system: it's a real spin, for UP build system, it
-       only raises the IRQL to DISPATCH_LEVEL */
-    cfs_spin_unlock(&lock);
+       int             rc;
+       spinlock_t      lock;
+
+       /* Workground to check the system is MP build or UP build */
+       spin_lock_init(&lock);
+       spin_lock(&lock);
+       libcfs_is_mp_system = (int)lock.lock;
+       /* MP build system: it's a real spin, for UP build system, it
+        * only raises the IRQL to DISPATCH_LEVEL */
+       spin_unlock(&lock);
 
     /* initialize libc routines (confliction between libcnptr.lib
        and kernel ntoskrnl.lib) */