#include <linux/smp_lock.h>
 #include <linux/module.h>
 #include <linux/net.h>
+#include <linux/kthread.h>
 #include <net/ip.h>
 
 #include <linux/smb_fs.h>
 };
 
 static enum smbiod_state smbiod_state = SMBIOD_DEAD;
-static pid_t smbiod_pid;
+static struct task_struct *smbiod_thread;
 static DECLARE_WAIT_QUEUE_HEAD(smbiod_wait);
 static LIST_HEAD(smb_servers);
 static DEFINE_SPINLOCK(servers_lock);
  */
 static int smbiod_start(void)
 {
-       pid_t pid;
+       struct task_struct *tsk;
+       int err = 0;
+
        if (smbiod_state != SMBIOD_DEAD)
                return 0;
        smbiod_state = SMBIOD_STARTING;
        __module_get(THIS_MODULE);
        spin_unlock(&servers_lock);
-       pid = kernel_thread(smbiod, NULL, 0);
-       if (pid < 0)
+       tsk = kthread_run(smbiod, NULL, "smbiod");
+       if (IS_ERR(tsk)) {
+               err = PTR_ERR(tsk);
                module_put(THIS_MODULE);
+       }
 
        spin_lock(&servers_lock);
-       smbiod_state = pid < 0 ? SMBIOD_DEAD : SMBIOD_RUNNING;
-       smbiod_pid = pid;
-       return pid;
+       if (err < 0) {
+               smbiod_state = SMBIOD_DEAD;
+               smbiod_thread = NULL;
+       } else {
+               smbiod_state = SMBIOD_RUNNING;
+               smbiod_thread = tsk;
+       }
+       return err;
 }
 
 /*
  */
 static int smbiod(void *unused)
 {
-       daemonize("smbiod");
-
        allow_signal(SIGKILL);
 
        VERBOSE("SMB Kernel thread starting (%d) ...\n", current->pid);