Blame view

arch/um/drivers/ubd_user.c 1.13 KB
91acb21f0   Jeff Dike   [PATCH] uml: reve...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
  /* 
   * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com)
   * Copyright (C) 2001 Ridgerun,Inc (glonnon@ridgerun.com)
   * Licensed under the GPL
   */
  
  #include <stddef.h>
  #include <unistd.h>
  #include <errno.h>
  #include <sched.h>
  #include <signal.h>
  #include <string.h>
  #include <netinet/in.h>
  #include <sys/time.h>
  #include <sys/socket.h>
  #include <sys/mman.h>
  #include <sys/param.h>
91acb21f0   Jeff Dike   [PATCH] uml: reve...
18
19
  #include <endian.h>
  #include <byteswap.h>
8ea3c06a2   Al Viro   um: clean up the ...
20
  #include "ubd.h"
37185b332   Al Viro   um: get rid of po...
21
  #include <os.h>
8ea3c06a2   Al Viro   um: clean up the ...
22

91acb21f0   Jeff Dike   [PATCH] uml: reve...
23
24
25
26
27
28
29
30
31
32
33
34
35
  int start_io_thread(unsigned long sp, int *fd_out)
  {
  	int pid, fds[2], err;
  
  	err = os_pipe(fds, 1, 1);
  	if(err < 0){
  		printk("start_io_thread - os_pipe failed, err = %d
  ", -err);
  		goto out;
  	}
  
  	kernel_fd = fds[0];
  	*fd_out = fds[1];
89df6bfc0   Eduard-Gabriel Munteanu   uml: DEBUG_SHIRQ ...
36
37
38
39
40
41
  	err = os_set_fd_block(*fd_out, 0);
  	if (err) {
  		printk("start_io_thread - failed to set nonblocking I/O.
  ");
  		goto out_close;
  	}
4dbed85a3   Stanislaw Gruszka   uml: stop gdb fro...
42
  	pid = clone(io_thread, (void *) sp, CLONE_FILES | CLONE_VM, NULL);
91acb21f0   Jeff Dike   [PATCH] uml: reve...
43
  	if(pid < 0){
91acb21f0   Jeff Dike   [PATCH] uml: reve...
44
  		err = -errno;
56bd194bb   Jeff Dike   uml: driver forma...
45
46
  		printk("start_io_thread - clone failed : errno = %d
  ", errno);
91acb21f0   Jeff Dike   [PATCH] uml: reve...
47
48
49
50
51
52
53
54
55
56
57
  		goto out_close;
  	}
  
  	return(pid);
  
   out_close:
  	os_close_file(fds[0]);
  	os_close_file(fds[1]);
  	kernel_fd = -1;
  	*fd_out = -1;
   out:
56bd194bb   Jeff Dike   uml: driver forma...
58
  	return err;
91acb21f0   Jeff Dike   [PATCH] uml: reve...
59
  }