ubd_user.c 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*
  2. * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com)
  3. * Copyright (C) 2001 Ridgerun,Inc (glonnon@ridgerun.com)
  4. * Licensed under the GPL
  5. */
  6. #include <stddef.h>
  7. #include <unistd.h>
  8. #include <errno.h>
  9. #include <sched.h>
  10. #include <signal.h>
  11. #include <string.h>
  12. #include <netinet/in.h>
  13. #include <sys/time.h>
  14. #include <sys/socket.h>
  15. #include <sys/mman.h>
  16. #include <sys/param.h>
  17. #include "asm/types.h"
  18. #include "user_util.h"
  19. #include "kern_util.h"
  20. #include "user.h"
  21. #include "ubd_user.h"
  22. #include "os.h"
  23. #include "cow.h"
  24. #include <endian.h>
  25. #include <byteswap.h>
  26. void ignore_sigwinch_sig(void)
  27. {
  28. signal(SIGWINCH, SIG_IGN);
  29. }
  30. int start_io_thread(unsigned long sp, int *fd_out)
  31. {
  32. int pid, fds[2], err;
  33. err = os_pipe(fds, 1, 1);
  34. if(err < 0){
  35. printk("start_io_thread - os_pipe failed, err = %d\n", -err);
  36. goto out;
  37. }
  38. kernel_fd = fds[0];
  39. *fd_out = fds[1];
  40. pid = clone(io_thread, (void *) sp, CLONE_FILES | CLONE_VM | SIGCHLD,
  41. NULL);
  42. if(pid < 0){
  43. printk("start_io_thread - clone failed : errno = %d\n", errno);
  44. err = -errno;
  45. goto out_close;
  46. }
  47. return(pid);
  48. out_close:
  49. os_close_file(fds[0]);
  50. os_close_file(fds[1]);
  51. kernel_fd = -1;
  52. *fd_out = -1;
  53. out:
  54. return(err);
  55. }
  56. /*
  57. * Overrides for Emacs so that we follow Linus's tabbing style.
  58. * Emacs will notice this stuff at the end of the file and automatically
  59. * adjust the settings for this buffer only. This must remain at the end
  60. * of the file.
  61. * ---------------------------------------------------------------------------
  62. * Local variables:
  63. * c-file-style: "linux"
  64. * End:
  65. */