libusb 0.5.0 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (141) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +0 -0
  4. data/.travis.yml +1 -0
  5. data/History.md +8 -0
  6. data/README.md +5 -15
  7. data/Rakefile +8 -1
  8. data/ext/extconf.rb +49 -12
  9. data/ext/{libusb-1.0.19 → libusb-1.0.20}/AUTHORS +12 -1
  10. data/ext/{libusb-1.0.19 → libusb-1.0.20}/COPYING +0 -0
  11. data/ext/{libusb-1.0.19 → libusb-1.0.20}/ChangeLog +18 -2
  12. data/ext/{libusb-1.0.19 → libusb-1.0.20}/INSTALL +0 -0
  13. data/ext/{libusb-1.0.19 → libusb-1.0.20}/Makefile.am +0 -0
  14. data/ext/{libusb-1.0.19 → libusb-1.0.20}/Makefile.in +31 -18
  15. data/ext/{libusb-1.0.19 → libusb-1.0.20}/NEWS +0 -0
  16. data/ext/{libusb-1.0.19 → libusb-1.0.20}/PORTING +0 -0
  17. data/ext/{libusb-1.0.19 → libusb-1.0.20}/README +5 -3
  18. data/ext/{libusb-1.0.19 → libusb-1.0.20}/TODO +0 -0
  19. data/ext/{libusb-1.0.19 → libusb-1.0.20}/Xcode/common.xcconfig +0 -0
  20. data/ext/{libusb-1.0.19 → libusb-1.0.20}/Xcode/config.h +0 -0
  21. data/ext/{libusb-1.0.19 → libusb-1.0.20}/Xcode/debug.xcconfig +0 -0
  22. data/ext/{libusb-1.0.19 → libusb-1.0.20}/Xcode/libusb.xcconfig +0 -0
  23. data/ext/libusb-1.0.20/Xcode/libusb.xcodeproj/project.pbxproj +865 -0
  24. data/ext/{libusb-1.0.19 → libusb-1.0.20}/Xcode/libusb_debug.xcconfig +0 -0
  25. data/ext/{libusb-1.0.19 → libusb-1.0.20}/Xcode/libusb_release.xcconfig +0 -0
  26. data/ext/{libusb-1.0.19 → libusb-1.0.20}/Xcode/release.xcconfig +0 -0
  27. data/ext/{libusb-1.0.19 → libusb-1.0.20}/aclocal.m4 +35 -32
  28. data/ext/{libusb-1.0.19 → libusb-1.0.20}/android/README +0 -0
  29. data/ext/{libusb-1.0.19 → libusb-1.0.20}/android/config.h +0 -0
  30. data/ext/{libusb-1.0.19 → libusb-1.0.20}/android/jni/Android.mk +0 -0
  31. data/ext/{libusb-1.0.19 → libusb-1.0.20}/android/jni/Application.mk +0 -0
  32. data/ext/{libusb-1.0.19 → libusb-1.0.20}/android/jni/examples.mk +0 -0
  33. data/ext/{libusb-1.0.19 → libusb-1.0.20}/android/jni/libusb.mk +0 -0
  34. data/ext/{libusb-1.0.19 → libusb-1.0.20}/android/jni/tests.mk +0 -0
  35. data/ext/{libusb-1.0.19 → libusb-1.0.20}/compile +1 -1
  36. data/ext/{libusb-1.0.19 → libusb-1.0.20}/config.guess +13 -160
  37. data/ext/{libusb-1.0.19 → libusb-1.0.20}/config.h.in +6 -0
  38. data/ext/{libusb-1.0.19 → libusb-1.0.20}/config.sub +26 -12
  39. data/ext/{libusb-1.0.19 → libusb-1.0.20}/configure +244 -20
  40. data/ext/{libusb-1.0.19 → libusb-1.0.20}/configure.ac +27 -4
  41. data/ext/{libusb-1.0.19 → libusb-1.0.20}/depcomp +1 -1
  42. data/ext/{libusb-1.0.19 → libusb-1.0.20}/doc/Makefile.am +0 -0
  43. data/ext/{libusb-1.0.19 → libusb-1.0.20}/doc/Makefile.in +19 -6
  44. data/ext/libusb-1.0.20/doc/doxygen.cfg.in +2334 -0
  45. data/ext/{libusb-1.0.19 → libusb-1.0.20}/examples/Makefile.am +0 -0
  46. data/ext/{libusb-1.0.19 → libusb-1.0.20}/examples/Makefile.in +19 -6
  47. data/ext/{libusb-1.0.19 → libusb-1.0.20}/examples/dpfp.c +0 -0
  48. data/ext/{libusb-1.0.19 → libusb-1.0.20}/examples/dpfp_threaded.c +15 -10
  49. data/ext/{libusb-1.0.19 → libusb-1.0.20}/examples/ezusb.c +0 -0
  50. data/ext/{libusb-1.0.19 → libusb-1.0.20}/examples/ezusb.h +0 -0
  51. data/ext/{libusb-1.0.19 → libusb-1.0.20}/examples/fxload.c +28 -7
  52. data/ext/{libusb-1.0.19 → libusb-1.0.20}/examples/getopt/getopt.c +0 -0
  53. data/ext/{libusb-1.0.19 → libusb-1.0.20}/examples/getopt/getopt.h +0 -0
  54. data/ext/{libusb-1.0.19 → libusb-1.0.20}/examples/getopt/getopt1.c +0 -0
  55. data/ext/{libusb-1.0.19 → libusb-1.0.20}/examples/hotplugtest.c +21 -3
  56. data/ext/{libusb-1.0.19 → libusb-1.0.20}/examples/listdevs.c +0 -0
  57. data/ext/{libusb-1.0.19 → libusb-1.0.20}/examples/sam3u_benchmark.c +0 -0
  58. data/ext/{libusb-1.0.19 → libusb-1.0.20}/examples/xusb.c +2 -1
  59. data/ext/{libusb-1.0.19 → libusb-1.0.20}/install-sh +170 -196
  60. data/ext/{libusb-1.0.19 → libusb-1.0.20}/libusb-1.0.pc.in +0 -0
  61. data/ext/{libusb-1.0.19 → libusb-1.0.20}/libusb/Makefile.am +15 -0
  62. data/ext/{libusb-1.0.19 → libusb-1.0.20}/libusb/Makefile.in +192 -53
  63. data/ext/{libusb-1.0.19 → libusb-1.0.20}/libusb/core.c +218 -100
  64. data/ext/{libusb-1.0.19 → libusb-1.0.20}/libusb/descriptor.c +3 -1
  65. data/ext/{libusb-1.0.19 → libusb-1.0.20}/libusb/hotplug.c +26 -9
  66. data/ext/{libusb-1.0.19 → libusb-1.0.20}/libusb/hotplug.h +8 -0
  67. data/ext/{libusb-1.0.19 → libusb-1.0.20}/libusb/io.c +432 -290
  68. data/ext/{libusb-1.0.19 → libusb-1.0.20}/libusb/libusb-1.0.def +2 -0
  69. data/ext/{libusb-1.0.19 → libusb-1.0.20}/libusb/libusb-1.0.rc +0 -0
  70. data/ext/{libusb-1.0.19 → libusb-1.0.20}/libusb/libusb.h +11 -10
  71. data/ext/{libusb-1.0.19 → libusb-1.0.20}/libusb/libusbi.h +106 -29
  72. data/ext/{libusb-1.0.19 → libusb-1.0.20}/libusb/os/darwin_usb.c +27 -67
  73. data/ext/{libusb-1.0.19 → libusb-1.0.20}/libusb/os/darwin_usb.h +3 -7
  74. data/ext/libusb-1.0.20/libusb/os/haiku/Makefile.am +5 -0
  75. data/ext/libusb-1.0.20/libusb/os/haiku/Makefile.in +810 -0
  76. data/ext/libusb-1.0.20/libusb/os/haiku/aclocal.m4 +1193 -0
  77. data/ext/libusb-1.0.20/libusb/os/haiku/compile +347 -0
  78. data/ext/libusb-1.0.20/libusb/os/haiku/config.guess +1421 -0
  79. data/ext/libusb-1.0.20/libusb/os/haiku/config.sub +1807 -0
  80. data/ext/libusb-1.0.20/libusb/os/haiku/configure +17579 -0
  81. data/ext/libusb-1.0.20/libusb/os/haiku/configure.ac +8 -0
  82. data/ext/libusb-1.0.20/libusb/os/haiku/depcomp +791 -0
  83. data/ext/libusb-1.0.20/libusb/os/haiku/haiku_pollfs.cpp +378 -0
  84. data/ext/libusb-1.0.20/libusb/os/haiku/haiku_usb.h +112 -0
  85. data/ext/libusb-1.0.20/libusb/os/haiku/haiku_usb_backend.cpp +550 -0
  86. data/ext/libusb-1.0.20/libusb/os/haiku/haiku_usb_raw.cpp +255 -0
  87. data/ext/libusb-1.0.20/libusb/os/haiku/haiku_usb_raw.h +180 -0
  88. data/ext/libusb-1.0.20/libusb/os/haiku/install-sh +501 -0
  89. data/ext/{libusb-1.0.19 → libusb-1.0.20/libusb/os/haiku}/ltmain.sh +0 -0
  90. data/ext/{libusb-1.0.19 → libusb-1.0.20/libusb/os/haiku}/m4/libtool.m4 +0 -0
  91. data/ext/{libusb-1.0.19 → libusb-1.0.20/libusb/os/haiku}/m4/ltoptions.m4 +0 -0
  92. data/ext/{libusb-1.0.19 → libusb-1.0.20/libusb/os/haiku}/m4/ltsugar.m4 +0 -0
  93. data/ext/{libusb-1.0.19 → libusb-1.0.20/libusb/os/haiku}/m4/ltversion.m4 +0 -0
  94. data/ext/{libusb-1.0.19 → libusb-1.0.20/libusb/os/haiku}/m4/lt~obsolete.m4 +0 -0
  95. data/ext/{libusb-1.0.19 → libusb-1.0.20/libusb/os/haiku}/missing +1 -1
  96. data/ext/{libusb-1.0.19 → libusb-1.0.20}/libusb/os/linux_netlink.c +4 -4
  97. data/ext/{libusb-1.0.19 → libusb-1.0.20}/libusb/os/linux_udev.c +1 -2
  98. data/ext/{libusb-1.0.19 → libusb-1.0.20}/libusb/os/linux_usbfs.c +46 -49
  99. data/ext/{libusb-1.0.19 → libusb-1.0.20}/libusb/os/linux_usbfs.h +1 -1
  100. data/ext/{libusb-1.0.19 → libusb-1.0.20}/libusb/os/netbsd_usb.c +9 -73
  101. data/ext/{libusb-1.0.19 → libusb-1.0.20}/libusb/os/openbsd_usb.c +9 -73
  102. data/ext/{libusb-1.0.19 → libusb-1.0.20}/libusb/os/poll_posix.c +2 -0
  103. data/ext/{libusb-1.0.19 → libusb-1.0.20}/libusb/os/poll_posix.h +0 -0
  104. data/ext/{libusb-1.0.19 → libusb-1.0.20}/libusb/os/poll_windows.c +3 -1
  105. data/ext/{libusb-1.0.19 → libusb-1.0.20}/libusb/os/poll_windows.h +0 -0
  106. data/ext/{libusb-1.0.19 → libusb-1.0.20}/libusb/os/threads_posix.c +3 -3
  107. data/ext/{libusb-1.0.19 → libusb-1.0.20}/libusb/os/threads_posix.h +0 -0
  108. data/ext/{libusb-1.0.19 → libusb-1.0.20}/libusb/os/threads_windows.c +3 -1
  109. data/ext/{libusb-1.0.19 → libusb-1.0.20}/libusb/os/threads_windows.h +0 -0
  110. data/ext/{libusb-1.0.19 → libusb-1.0.20}/libusb/os/wince_usb.c +87 -250
  111. data/ext/{libusb-1.0.19 → libusb-1.0.20}/libusb/os/wince_usb.h +0 -0
  112. data/ext/{libusb-1.0.19 → libusb-1.0.20}/libusb/os/windows_common.h +1 -1
  113. data/ext/{libusb-1.0.19 → libusb-1.0.20}/libusb/os/windows_usb.c +267 -181
  114. data/ext/{libusb-1.0.19 → libusb-1.0.20}/libusb/os/windows_usb.h +22 -7
  115. data/ext/{libusb-1.0.19 → libusb-1.0.20}/libusb/strerror.c +5 -2
  116. data/ext/{libusb-1.0.19 → libusb-1.0.20}/libusb/sync.c +2 -1
  117. data/ext/{libusb-1.0.19 → libusb-1.0.20}/libusb/version.h +1 -1
  118. data/ext/libusb-1.0.20/libusb/version_nano.h +1 -0
  119. data/ext/libusb-1.0.20/ltmain.sh +9655 -0
  120. data/ext/libusb-1.0.20/m4/libtool.m4 +7992 -0
  121. data/ext/libusb-1.0.20/m4/ltoptions.m4 +384 -0
  122. data/ext/libusb-1.0.20/m4/ltsugar.m4 +123 -0
  123. data/ext/libusb-1.0.20/m4/ltversion.m4 +23 -0
  124. data/ext/libusb-1.0.20/m4/lt~obsolete.m4 +98 -0
  125. data/ext/libusb-1.0.20/missing +215 -0
  126. data/ext/{libusb-1.0.19 → libusb-1.0.20}/tests/Makefile.am +0 -0
  127. data/ext/{libusb-1.0.19 → libusb-1.0.20}/tests/Makefile.in +19 -6
  128. data/ext/{libusb-1.0.19 → libusb-1.0.20}/tests/libusb_testlib.h +0 -0
  129. data/ext/{libusb-1.0.19 → libusb-1.0.20}/tests/stress.c +0 -0
  130. data/ext/{libusb-1.0.19 → libusb-1.0.20}/tests/testlib.c +0 -0
  131. data/lib/libusb.rb +1 -0
  132. data/lib/libusb/call.rb +1 -0
  133. data/lib/libusb/context.rb +5 -2
  134. data/lib/libusb/stdio.rb +25 -0
  135. data/lib/libusb/version_gem.rb +1 -1
  136. data/libusb.gemspec +2 -1
  137. metadata +152 -115
  138. metadata.gz.sig +0 -0
  139. data/ext/libusb-1.0.19/Xcode/libusb.xcodeproj/project.pbxproj +0 -1
  140. data/ext/libusb-1.0.19/doc/doxygen.cfg.in +0 -1288
  141. data/ext/libusb-1.0.19/libusb/version_nano.h +0 -1
@@ -1,7 +1,7 @@
1
- # Makefile.in generated by automake 1.14.1 from Makefile.am.
1
+ # Makefile.in generated by automake 1.15 from Makefile.am.
2
2
  # @configure_input@
3
3
 
4
- # Copyright (C) 1994-2013 Free Software Foundation, Inc.
4
+ # Copyright (C) 1994-2014 Free Software Foundation, Inc.
5
5
 
6
6
  # This Makefile.in is free software; the Free Software Foundation
7
7
  # gives unlimited permission to copy and/or distribute it,
@@ -15,7 +15,17 @@
15
15
  @SET_MAKE@
16
16
 
17
17
  VPATH = @srcdir@
18
- am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
18
+ am__is_gnu_make = { \
19
+ if test -z '$(MAKELEVEL)'; then \
20
+ false; \
21
+ elif test -n '$(MAKE_HOST)'; then \
22
+ true; \
23
+ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
24
+ true; \
25
+ else \
26
+ false; \
27
+ fi; \
28
+ }
19
29
  am__make_running_with_option = \
20
30
  case $${target_option-} in \
21
31
  ?) ;; \
@@ -85,8 +95,6 @@ noinst_PROGRAMS = listdevs$(EXEEXT) xusb$(EXEEXT) fxload$(EXEEXT) \
85
95
  @HAVE_SIGACTION_TRUE@@THREADS_POSIX_TRUE@am__append_2 = dpfp_threaded
86
96
  @HAVE_SIGACTION_TRUE@am__append_3 = sam3u_benchmark
87
97
  subdir = examples
88
- DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
89
- $(top_srcdir)/depcomp
90
98
  ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
91
99
  am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \
92
100
  $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
@@ -94,6 +102,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \
94
102
  $(top_srcdir)/libusb/version.h $(top_srcdir)/configure.ac
95
103
  am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
96
104
  $(ACLOCAL_M4)
105
+ DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
97
106
  mkinstalldirs = $(install_sh) -d
98
107
  CONFIG_HEADER = $(top_builddir)/config.h
99
108
  CONFIG_CLEAN_FILES =
@@ -204,6 +213,7 @@ am__define_uniq_tagged_files = \
204
213
  done | $(am__uniquify_input)`
205
214
  ETAGS = etags
206
215
  CTAGS = ctags
216
+ am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp
207
217
  DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
208
218
  ACLOCAL = @ACLOCAL@
209
219
  AMTAR = @AMTAR@
@@ -255,6 +265,7 @@ NMEDIT = @NMEDIT@
255
265
  OBJDUMP = @OBJDUMP@
256
266
  OBJEXT = @OBJEXT@
257
267
  OS_DARWIN = @OS_DARWIN@
268
+ OS_HAIKU = @OS_HAIKU@
258
269
  OS_LINUX = @OS_LINUX@
259
270
  OS_NETBSD = @OS_NETBSD@
260
271
  OS_OPENBSD = @OS_OPENBSD@
@@ -324,6 +335,7 @@ psdir = @psdir@
324
335
  sbindir = @sbindir@
325
336
  sharedstatedir = @sharedstatedir@
326
337
  srcdir = @srcdir@
338
+ subdirs = @subdirs@
327
339
  sysconfdir = @sysconfdir@
328
340
  target_alias = @target_alias@
329
341
  top_build_prefix = @top_build_prefix@
@@ -351,7 +363,6 @@ $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__confi
351
363
  echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu examples/Makefile'; \
352
364
  $(am__cd) $(top_srcdir) && \
353
365
  $(AUTOMAKE) --gnu examples/Makefile
354
- .PRECIOUS: Makefile
355
366
  Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
356
367
  @case '$?' in \
357
368
  *config.status*) \
@@ -694,6 +705,8 @@ uninstall-am:
694
705
  mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
695
706
  tags tags-am uninstall uninstall-am
696
707
 
708
+ .PRECIOUS: Makefile
709
+
697
710
 
698
711
  # Tell versions [3.59,3.63) of GNU make to not export all variables.
699
712
  # Otherwise a system limit (for SysV at least) may be exceeded.
@@ -23,6 +23,7 @@
23
23
 
24
24
  #include <errno.h>
25
25
  #include <pthread.h>
26
+ #include <semaphore.h>
26
27
  #include <signal.h>
27
28
  #include <string.h>
28
29
  #include <stdio.h>
@@ -64,16 +65,15 @@ static unsigned char irqbuf[INTR_LENGTH];
64
65
  static struct libusb_transfer *img_transfer = NULL;
65
66
  static struct libusb_transfer *irq_transfer = NULL;
66
67
  static int img_idx = 0;
67
- static int do_exit = 0;
68
+ static volatile sig_atomic_t do_exit = 0;
68
69
 
69
70
  static pthread_t poll_thread;
70
- static pthread_cond_t exit_cond = PTHREAD_COND_INITIALIZER;
71
- static pthread_mutex_t exit_cond_lock = PTHREAD_MUTEX_INITIALIZER;
71
+ static sem_t exit_sem;
72
72
 
73
- static void request_exit(int code)
73
+ static void request_exit(sig_atomic_t code)
74
74
  {
75
75
  do_exit = code;
76
- pthread_cond_signal(&exit_cond);
76
+ sem_post(&exit_sem);
77
77
  }
78
78
 
79
79
  static void *poll_thread_main(void *arg)
@@ -446,9 +446,16 @@ int main(void)
446
446
  struct sigaction sigact;
447
447
  int r = 1;
448
448
 
449
+ r = sem_init(&exit_sem, 0, 0);
450
+ if (r) {
451
+ fprintf(stderr, "failed to initialise semaphore error %d", errno);
452
+ exit(1);
453
+ }
454
+
449
455
  r = libusb_init(NULL);
450
456
  if (r < 0) {
451
457
  fprintf(stderr, "failed to initialise libusb\n");
458
+ sem_destroy(&exit_sem);
452
459
  exit(1);
453
460
  }
454
461
 
@@ -500,11 +507,8 @@ int main(void)
500
507
  goto out_deinit;
501
508
  }
502
509
 
503
- while (!do_exit) {
504
- pthread_mutex_lock(&exit_cond_lock);
505
- pthread_cond_wait(&exit_cond, &exit_cond_lock);
506
- pthread_mutex_unlock(&exit_cond_lock);
507
- }
510
+ while (!do_exit)
511
+ sem_wait(&exit_sem);
508
512
 
509
513
  printf("shutting down...\n");
510
514
  pthread_join(poll_thread, NULL);
@@ -540,5 +544,6 @@ out_release:
540
544
  out:
541
545
  libusb_close(devh);
542
546
  libusb_exit(NULL);
547
+ sem_destroy(&exit_sem);
543
548
  return r >= 0 ? r : -r;
544
549
  }
@@ -65,8 +65,9 @@ void logerror(const char *format, ...)
65
65
  }
66
66
 
67
67
  static int print_usage(int error_code) {
68
- fprintf(stderr, "\nUsage: fxload [-v] [-V] [-t type] [-d vid:pid] [-p bus,addr] -i firmware\n");
68
+ fprintf(stderr, "\nUsage: fxload [-v] [-V] [-t type] [-d vid:pid] [-p bus,addr] [-s loader] -i firmware\n");
69
69
  fprintf(stderr, " -i <path> -- Firmware to upload\n");
70
+ fprintf(stderr, " -s <path> -- Second stage loader\n");
70
71
  fprintf(stderr, " -t <type> -- Target type: an21, fx, fx2, fx2lp, fx3\n");
71
72
  fprintf(stderr, " -d <vid:pid> -- Target device, as an USB VID:PID\n");
72
73
  fprintf(stderr, " -p <bus,addr> -- Target device, as a libusb bus number and device address path\n");
@@ -95,7 +96,7 @@ int main(int argc, char*argv[])
95
96
  libusb_device_handle *device = NULL;
96
97
  struct libusb_device_descriptor desc;
97
98
 
98
- while ((opt = getopt(argc, argv, "qvV?hd:p:i:I:t:")) != EOF)
99
+ while ((opt = getopt(argc, argv, "qvV?hd:p:i:I:s:S:t:")) != EOF)
99
100
  switch (opt) {
100
101
 
101
102
  case 'd':
@@ -119,6 +120,11 @@ int main(int argc, char*argv[])
119
120
  path[FIRMWARE] = optarg;
120
121
  break;
121
122
 
123
+ case 's':
124
+ case 'S':
125
+ path[LOADER] = optarg;
126
+ break;
127
+
122
128
  case 'V':
123
129
  puts(FXLOAD_VERSION);
124
130
  return 0;
@@ -224,15 +230,16 @@ int main(int argc, char*argv[])
224
230
  }
225
231
  if (dev == NULL) {
226
232
  libusb_free_device_list(devs, 1);
233
+ libusb_exit(NULL);
227
234
  logerror("could not find a known device - please specify type and/or vid:pid and/or bus,dev\n");
228
235
  return print_usage(-1);
229
236
  }
230
237
  status = libusb_open(dev, &device);
238
+ libusb_free_device_list(devs, 1);
231
239
  if (status < 0) {
232
240
  logerror("libusb_open() failed: %s\n", libusb_error_name(status));
233
241
  goto err;
234
242
  }
235
- libusb_free_device_list(devs, 1);
236
243
  } else if (device_id != NULL) {
237
244
  device = libusb_open_device_with_vid_pid(NULL, (uint16_t)vid, (uint16_t)pid);
238
245
  if (device == NULL) {
@@ -245,6 +252,7 @@ int main(int argc, char*argv[])
245
252
  libusb_set_auto_detach_kernel_driver(device, 1);
246
253
  status = libusb_claim_interface(device, 0);
247
254
  if (status != LIBUSB_SUCCESS) {
255
+ libusb_close(device);
248
256
  logerror("libusb_claim_interface failed: %s\n", libusb_error_name(status));
249
257
  goto err;
250
258
  }
@@ -272,10 +280,23 @@ int main(int argc, char*argv[])
272
280
  logerror("%s: type %s\n", path[i], img_name[img_type[i]]);
273
281
  }
274
282
 
275
- /* single stage, put into internal memory */
276
- if (verbose > 1)
277
- logerror("single stage: load on-chip memory\n");
278
- status = ezusb_load_ram(device, path[FIRMWARE], fx_type, img_type[FIRMWARE], 0);
283
+ if (path[LOADER] == NULL) {
284
+ /* single stage, put into internal memory */
285
+ if (verbose > 1)
286
+ logerror("single stage: load on-chip memory\n");
287
+ status = ezusb_load_ram(device, path[FIRMWARE], fx_type, img_type[FIRMWARE], 0);
288
+ } else {
289
+ /* two-stage, put loader into internal memory */
290
+ if (verbose > 1)
291
+ logerror("1st stage: load 2nd stage loader\n");
292
+ status = ezusb_load_ram(device, path[LOADER], fx_type, img_type[LOADER], 0);
293
+ if (status == 0) {
294
+ /* two-stage, put firmware into internal memory */
295
+ if (verbose > 1)
296
+ logerror("2nd state: load on-chip memory\n");
297
+ status = ezusb_load_ram(device, path[FIRMWARE], fx_type, img_type[FIRMWARE], 1);
298
+ }
299
+ }
279
300
 
280
301
  libusb_release_interface(device, 0);
281
302
  libusb_close(device);
@@ -24,7 +24,7 @@
24
24
  #include "libusb.h"
25
25
 
26
26
  int done = 0;
27
- libusb_device_handle *handle;
27
+ libusb_device_handle *handle = NULL;
28
28
 
29
29
  static int LIBUSB_CALL hotplug_callback(libusb_context *ctx, libusb_device *dev, libusb_hotplug_event event, void *user_data)
30
30
  {
@@ -38,7 +38,15 @@ static int LIBUSB_CALL hotplug_callback(libusb_context *ctx, libusb_device *dev,
38
38
 
39
39
  printf ("Device attached: %04x:%04x\n", desc.idVendor, desc.idProduct);
40
40
 
41
- libusb_open (dev, &handle);
41
+ if (handle) {
42
+ libusb_close (handle);
43
+ handle = NULL;
44
+ }
45
+
46
+ rc = libusb_open (dev, &handle);
47
+ if (LIBUSB_SUCCESS != rc) {
48
+ fprintf (stderr, "Error opening device\n");
49
+ }
42
50
 
43
51
  done++;
44
52
 
@@ -49,9 +57,13 @@ static int LIBUSB_CALL hotplug_callback_detach(libusb_context *ctx, libusb_devic
49
57
  {
50
58
  printf ("Device detached\n");
51
59
 
52
- libusb_close (handle);
60
+ if (handle) {
61
+ libusb_close (handle);
62
+ handle = NULL;
63
+ }
53
64
 
54
65
  done++;
66
+
55
67
  return 0;
56
68
  }
57
69
 
@@ -100,5 +112,11 @@ int main(int argc, char *argv[])
100
112
  printf("libusb_handle_events() failed: %s\n", libusb_error_name(rc));
101
113
  }
102
114
 
115
+ if (handle) {
116
+ libusb_close (handle);
117
+ }
118
+
103
119
  libusb_exit (NULL);
120
+
121
+ return EXIT_SUCCESS;
104
122
  }
@@ -1098,7 +1098,8 @@ int main(int argc, char** argv)
1098
1098
  // but since we can't call on libusb_set_debug() before libusb_init(), we use the env variable method
1099
1099
  old_dbg_str = getenv("LIBUSB_DEBUG");
1100
1100
  if (debug_mode) {
1101
- putenv("LIBUSB_DEBUG=4"); // LIBUSB_LOG_LEVEL_DEBUG
1101
+ if (putenv("LIBUSB_DEBUG=4") != 0) // LIBUSB_LOG_LEVEL_DEBUG
1102
+ printf("Unable to set debug level");
1102
1103
  }
1103
1104
 
1104
1105
  version = libusb_get_version();
@@ -1,7 +1,7 @@
1
1
  #!/bin/sh
2
2
  # install - install a program, script, or datafile
3
3
 
4
- scriptversion=2011-11-20.07; # UTC
4
+ scriptversion=2013-12-25.23; # UTC
5
5
 
6
6
  # This originates from X11R5 (mit/util/scripts/install.sh), which was
7
7
  # later released in X11R6 (xc/config/util/install.sh) with the
@@ -41,19 +41,15 @@ scriptversion=2011-11-20.07; # UTC
41
41
  # This script is compatible with the BSD install script, but was written
42
42
  # from scratch.
43
43
 
44
+ tab=' '
44
45
  nl='
45
46
  '
46
- IFS=" "" $nl"
47
+ IFS=" $tab$nl"
47
48
 
48
- # set DOITPROG to echo to test this script
49
+ # Set DOITPROG to "echo" to test this script.
49
50
 
50
- # Don't use :- since 4.3BSD and earlier shells don't like it.
51
51
  doit=${DOITPROG-}
52
- if test -z "$doit"; then
53
- doit_exec=exec
54
- else
55
- doit_exec=$doit
56
- fi
52
+ doit_exec=${doit:-exec}
57
53
 
58
54
  # Put in absolute file names if you don't have them in your path;
59
55
  # or use environment vars.
@@ -68,17 +64,6 @@ mvprog=${MVPROG-mv}
68
64
  rmprog=${RMPROG-rm}
69
65
  stripprog=${STRIPPROG-strip}
70
66
 
71
- posix_glob='?'
72
- initialize_posix_glob='
73
- test "$posix_glob" != "?" || {
74
- if (set -f) 2>/dev/null; then
75
- posix_glob=
76
- else
77
- posix_glob=:
78
- fi
79
- }
80
- '
81
-
82
67
  posix_mkdir=
83
68
 
84
69
  # Desired mode of installed file.
@@ -97,7 +82,7 @@ dir_arg=
97
82
  dst_arg=
98
83
 
99
84
  copy_on_change=false
100
- no_target_directory=
85
+ is_target_a_directory=possibly
101
86
 
102
87
  usage="\
103
88
  Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
@@ -137,46 +122,57 @@ while test $# -ne 0; do
137
122
  -d) dir_arg=true;;
138
123
 
139
124
  -g) chgrpcmd="$chgrpprog $2"
140
- shift;;
125
+ shift;;
141
126
 
142
127
  --help) echo "$usage"; exit $?;;
143
128
 
144
129
  -m) mode=$2
145
- case $mode in
146
- *' '* | *' '* | *'
147
- '* | *'*'* | *'?'* | *'['*)
148
- echo "$0: invalid mode: $mode" >&2
149
- exit 1;;
150
- esac
151
- shift;;
130
+ case $mode in
131
+ *' '* | *"$tab"* | *"$nl"* | *'*'* | *'?'* | *'['*)
132
+ echo "$0: invalid mode: $mode" >&2
133
+ exit 1;;
134
+ esac
135
+ shift;;
152
136
 
153
137
  -o) chowncmd="$chownprog $2"
154
- shift;;
138
+ shift;;
155
139
 
156
140
  -s) stripcmd=$stripprog;;
157
141
 
158
- -t) dst_arg=$2
159
- # Protect names problematic for 'test' and other utilities.
160
- case $dst_arg in
161
- -* | [=\(\)!]) dst_arg=./$dst_arg;;
162
- esac
163
- shift;;
142
+ -t)
143
+ is_target_a_directory=always
144
+ dst_arg=$2
145
+ # Protect names problematic for 'test' and other utilities.
146
+ case $dst_arg in
147
+ -* | [=\(\)!]) dst_arg=./$dst_arg;;
148
+ esac
149
+ shift;;
164
150
 
165
- -T) no_target_directory=true;;
151
+ -T) is_target_a_directory=never;;
166
152
 
167
153
  --version) echo "$0 $scriptversion"; exit $?;;
168
154
 
169
- --) shift
170
- break;;
155
+ --) shift
156
+ break;;
171
157
 
172
- -*) echo "$0: invalid option: $1" >&2
173
- exit 1;;
158
+ -*) echo "$0: invalid option: $1" >&2
159
+ exit 1;;
174
160
 
175
161
  *) break;;
176
162
  esac
177
163
  shift
178
164
  done
179
165
 
166
+ # We allow the use of options -d and -T together, by making -d
167
+ # take the precedence; this is for compatibility with GNU install.
168
+
169
+ if test -n "$dir_arg"; then
170
+ if test -n "$dst_arg"; then
171
+ echo "$0: target directory not allowed when installing a directory." >&2
172
+ exit 1
173
+ fi
174
+ fi
175
+
180
176
  if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then
181
177
  # When -d is used, all remaining arguments are directories to create.
182
178
  # When -t is used, the destination is already specified.
@@ -207,6 +203,15 @@ if test $# -eq 0; then
207
203
  exit 0
208
204
  fi
209
205
 
206
+ if test -z "$dir_arg"; then
207
+ if test $# -gt 1 || test "$is_target_a_directory" = always; then
208
+ if test ! -d "$dst_arg"; then
209
+ echo "$0: $dst_arg: Is not a directory." >&2
210
+ exit 1
211
+ fi
212
+ fi
213
+ fi
214
+
210
215
  if test -z "$dir_arg"; then
211
216
  do_exit='(exit $ret); exit $ret'
212
217
  trap "ret=129; $do_exit" 1
@@ -223,16 +228,16 @@ if test -z "$dir_arg"; then
223
228
 
224
229
  *[0-7])
225
230
  if test -z "$stripcmd"; then
226
- u_plus_rw=
231
+ u_plus_rw=
227
232
  else
228
- u_plus_rw='% 200'
233
+ u_plus_rw='% 200'
229
234
  fi
230
235
  cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;;
231
236
  *)
232
237
  if test -z "$stripcmd"; then
233
- u_plus_rw=
238
+ u_plus_rw=
234
239
  else
235
- u_plus_rw=,u+rw
240
+ u_plus_rw=,u+rw
236
241
  fi
237
242
  cp_umask=$mode$u_plus_rw;;
238
243
  esac
@@ -269,41 +274,15 @@ do
269
274
  # If destination is a directory, append the input filename; won't work
270
275
  # if double slashes aren't ignored.
271
276
  if test -d "$dst"; then
272
- if test -n "$no_target_directory"; then
273
- echo "$0: $dst_arg: Is a directory" >&2
274
- exit 1
277
+ if test "$is_target_a_directory" = never; then
278
+ echo "$0: $dst_arg: Is a directory" >&2
279
+ exit 1
275
280
  fi
276
281
  dstdir=$dst
277
282
  dst=$dstdir/`basename "$src"`
278
283
  dstdir_status=0
279
284
  else
280
- # Prefer dirname, but fall back on a substitute if dirname fails.
281
- dstdir=`
282
- (dirname "$dst") 2>/dev/null ||
283
- expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
284
- X"$dst" : 'X\(//\)[^/]' \| \
285
- X"$dst" : 'X\(//\)$' \| \
286
- X"$dst" : 'X\(/\)' \| . 2>/dev/null ||
287
- echo X"$dst" |
288
- sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
289
- s//\1/
290
- q
291
- }
292
- /^X\(\/\/\)[^/].*/{
293
- s//\1/
294
- q
295
- }
296
- /^X\(\/\/\)$/{
297
- s//\1/
298
- q
299
- }
300
- /^X\(\/\).*/{
301
- s//\1/
302
- q
303
- }
304
- s/.*/./; q'
305
- `
306
-
285
+ dstdir=`dirname "$dst"`
307
286
  test -d "$dstdir"
308
287
  dstdir_status=$?
309
288
  fi
@@ -314,74 +293,74 @@ do
314
293
  if test $dstdir_status != 0; then
315
294
  case $posix_mkdir in
316
295
  '')
317
- # Create intermediate dirs using mode 755 as modified by the umask.
318
- # This is like FreeBSD 'install' as of 1997-10-28.
319
- umask=`umask`
320
- case $stripcmd.$umask in
321
- # Optimize common cases.
322
- *[2367][2367]) mkdir_umask=$umask;;
323
- .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;;
324
-
325
- *[0-7])
326
- mkdir_umask=`expr $umask + 22 \
327
- - $umask % 100 % 40 + $umask % 20 \
328
- - $umask % 10 % 4 + $umask % 2
329
- `;;
330
- *) mkdir_umask=$umask,go-w;;
331
- esac
332
-
333
- # With -d, create the new directory with the user-specified mode.
334
- # Otherwise, rely on $mkdir_umask.
335
- if test -n "$dir_arg"; then
336
- mkdir_mode=-m$mode
337
- else
338
- mkdir_mode=
339
- fi
340
-
341
- posix_mkdir=false
342
- case $umask in
343
- *[123567][0-7][0-7])
344
- # POSIX mkdir -p sets u+wx bits regardless of umask, which
345
- # is incompatible with FreeBSD 'install' when (umask & 300) != 0.
346
- ;;
347
- *)
348
- tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$
349
- trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0
350
-
351
- if (umask $mkdir_umask &&
352
- exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1
353
- then
354
- if test -z "$dir_arg" || {
355
- # Check for POSIX incompatibilities with -m.
356
- # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or
357
- # other-writable bit of parent directory when it shouldn't.
358
- # FreeBSD 6.1 mkdir -m -p sets mode of existing directory.
359
- ls_ld_tmpdir=`ls -ld "$tmpdir"`
360
- case $ls_ld_tmpdir in
361
- d????-?r-*) different_mode=700;;
362
- d????-?--*) different_mode=755;;
363
- *) false;;
364
- esac &&
365
- $mkdirprog -m$different_mode -p -- "$tmpdir" && {
366
- ls_ld_tmpdir_1=`ls -ld "$tmpdir"`
367
- test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1"
368
- }
369
- }
370
- then posix_mkdir=:
371
- fi
372
- rmdir "$tmpdir/d" "$tmpdir"
373
- else
374
- # Remove any dirs left behind by ancient mkdir implementations.
375
- rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null
376
- fi
377
- trap '' 0;;
378
- esac;;
296
+ # Create intermediate dirs using mode 755 as modified by the umask.
297
+ # This is like FreeBSD 'install' as of 1997-10-28.
298
+ umask=`umask`
299
+ case $stripcmd.$umask in
300
+ # Optimize common cases.
301
+ *[2367][2367]) mkdir_umask=$umask;;
302
+ .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;;
303
+
304
+ *[0-7])
305
+ mkdir_umask=`expr $umask + 22 \
306
+ - $umask % 100 % 40 + $umask % 20 \
307
+ - $umask % 10 % 4 + $umask % 2
308
+ `;;
309
+ *) mkdir_umask=$umask,go-w;;
310
+ esac
311
+
312
+ # With -d, create the new directory with the user-specified mode.
313
+ # Otherwise, rely on $mkdir_umask.
314
+ if test -n "$dir_arg"; then
315
+ mkdir_mode=-m$mode
316
+ else
317
+ mkdir_mode=
318
+ fi
319
+
320
+ posix_mkdir=false
321
+ case $umask in
322
+ *[123567][0-7][0-7])
323
+ # POSIX mkdir -p sets u+wx bits regardless of umask, which
324
+ # is incompatible with FreeBSD 'install' when (umask & 300) != 0.
325
+ ;;
326
+ *)
327
+ tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$
328
+ trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0
329
+
330
+ if (umask $mkdir_umask &&
331
+ exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1
332
+ then
333
+ if test -z "$dir_arg" || {
334
+ # Check for POSIX incompatibilities with -m.
335
+ # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or
336
+ # other-writable bit of parent directory when it shouldn't.
337
+ # FreeBSD 6.1 mkdir -m -p sets mode of existing directory.
338
+ ls_ld_tmpdir=`ls -ld "$tmpdir"`
339
+ case $ls_ld_tmpdir in
340
+ d????-?r-*) different_mode=700;;
341
+ d????-?--*) different_mode=755;;
342
+ *) false;;
343
+ esac &&
344
+ $mkdirprog -m$different_mode -p -- "$tmpdir" && {
345
+ ls_ld_tmpdir_1=`ls -ld "$tmpdir"`
346
+ test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1"
347
+ }
348
+ }
349
+ then posix_mkdir=:
350
+ fi
351
+ rmdir "$tmpdir/d" "$tmpdir"
352
+ else
353
+ # Remove any dirs left behind by ancient mkdir implementations.
354
+ rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null
355
+ fi
356
+ trap '' 0;;
357
+ esac;;
379
358
  esac
380
359
 
381
360
  if
382
361
  $posix_mkdir && (
383
- umask $mkdir_umask &&
384
- $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir"
362
+ umask $mkdir_umask &&
363
+ $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir"
385
364
  )
386
365
  then :
387
366
  else
@@ -391,53 +370,51 @@ do
391
370
  # directory the slow way, step by step, checking for races as we go.
392
371
 
393
372
  case $dstdir in
394
- /*) prefix='/';;
395
- [-=\(\)!]*) prefix='./';;
396
- *) prefix='';;
373
+ /*) prefix='/';;
374
+ [-=\(\)!]*) prefix='./';;
375
+ *) prefix='';;
397
376
  esac
398
377
 
399
- eval "$initialize_posix_glob"
400
-
401
378
  oIFS=$IFS
402
379
  IFS=/
403
- $posix_glob set -f
380
+ set -f
404
381
  set fnord $dstdir
405
382
  shift
406
- $posix_glob set +f
383
+ set +f
407
384
  IFS=$oIFS
408
385
 
409
386
  prefixes=
410
387
 
411
388
  for d
412
389
  do
413
- test X"$d" = X && continue
414
-
415
- prefix=$prefix$d
416
- if test -d "$prefix"; then
417
- prefixes=
418
- else
419
- if $posix_mkdir; then
420
- (umask=$mkdir_umask &&
421
- $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break
422
- # Don't fail if two instances are running concurrently.
423
- test -d "$prefix" || exit 1
424
- else
425
- case $prefix in
426
- *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;;
427
- *) qprefix=$prefix;;
428
- esac
429
- prefixes="$prefixes '$qprefix'"
430
- fi
431
- fi
432
- prefix=$prefix/
390
+ test X"$d" = X && continue
391
+
392
+ prefix=$prefix$d
393
+ if test -d "$prefix"; then
394
+ prefixes=
395
+ else
396
+ if $posix_mkdir; then
397
+ (umask=$mkdir_umask &&
398
+ $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break
399
+ # Don't fail if two instances are running concurrently.
400
+ test -d "$prefix" || exit 1
401
+ else
402
+ case $prefix in
403
+ *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;;
404
+ *) qprefix=$prefix;;
405
+ esac
406
+ prefixes="$prefixes '$qprefix'"
407
+ fi
408
+ fi
409
+ prefix=$prefix/
433
410
  done
434
411
 
435
412
  if test -n "$prefixes"; then
436
- # Don't fail if two instances are running concurrently.
437
- (umask $mkdir_umask &&
438
- eval "\$doit_exec \$mkdirprog $prefixes") ||
439
- test -d "$dstdir" || exit 1
440
- obsolete_mkdir_used=true
413
+ # Don't fail if two instances are running concurrently.
414
+ (umask $mkdir_umask &&
415
+ eval "\$doit_exec \$mkdirprog $prefixes") ||
416
+ test -d "$dstdir" || exit 1
417
+ obsolete_mkdir_used=true
441
418
  fi
442
419
  fi
443
420
  fi
@@ -472,15 +449,12 @@ do
472
449
 
473
450
  # If -C, don't bother to copy if it wouldn't change the file.
474
451
  if $copy_on_change &&
475
- old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` &&
476
- new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` &&
477
-
478
- eval "$initialize_posix_glob" &&
479
- $posix_glob set -f &&
452
+ old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` &&
453
+ new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` &&
454
+ set -f &&
480
455
  set X $old && old=:$2:$4:$5:$6 &&
481
456
  set X $new && new=:$2:$4:$5:$6 &&
482
- $posix_glob set +f &&
483
-
457
+ set +f &&
484
458
  test "$old" = "$new" &&
485
459
  $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1
486
460
  then
@@ -493,24 +467,24 @@ do
493
467
  # to itself, or perhaps because mv is so ancient that it does not
494
468
  # support -f.
495
469
  {
496
- # Now remove or move aside any old file at destination location.
497
- # We try this two ways since rm can't unlink itself on some
498
- # systems and the destination file might be busy for other
499
- # reasons. In this case, the final cleanup might fail but the new
500
- # file should still install successfully.
501
- {
502
- test ! -f "$dst" ||
503
- $doit $rmcmd -f "$dst" 2>/dev/null ||
504
- { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null &&
505
- { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; }
506
- } ||
507
- { echo "$0: cannot unlink or rename $dst" >&2
508
- (exit 1); exit 1
509
- }
510
- } &&
511
-
512
- # Now rename the file to the real destination.
513
- $doit $mvcmd "$dsttmp" "$dst"
470
+ # Now remove or move aside any old file at destination location.
471
+ # We try this two ways since rm can't unlink itself on some
472
+ # systems and the destination file might be busy for other
473
+ # reasons. In this case, the final cleanup might fail but the new
474
+ # file should still install successfully.
475
+ {
476
+ test ! -f "$dst" ||
477
+ $doit $rmcmd -f "$dst" 2>/dev/null ||
478
+ { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null &&
479
+ { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; }
480
+ } ||
481
+ { echo "$0: cannot unlink or rename $dst" >&2
482
+ (exit 1); exit 1
483
+ }
484
+ } &&
485
+
486
+ # Now rename the file to the real destination.
487
+ $doit $mvcmd "$dsttmp" "$dst"
514
488
  }
515
489
  fi || exit 1
516
490