Просмотр исходного кода

Make {stream,fd}_null_copy use [lf]seek, and fall back on the buffer code,
if stream/fd refer to a pipe.

Adam Heath лет назад: 25
Родитель
Сommit
d6d9d77c9f
2 измененных файлов с 19 добавлено и 8 удалено
  1. 5 0
      ChangeLog
  2. 14 8
      include/dpkg.h.in

+ 5 - 0
ChangeLog

@@ -1,3 +1,8 @@
+Wed Dec 20 02:21:43 CST 2000 Adam Heath <doogie@debian.org>
+
+  * include/dpkg.h.in: Make {stream,fd}_null_copy use [lf]seek, and fall
+    back on the buffer code, if stream/fd refer to a pipe.
+
 Wed Dec 20 02:17:56 CST 2000 Adam Heath <doogie@debian.org>
 
   * configure.in, Makefile.conf.in: Move -D_GNU_SOURCE from configure.in

+ 14 - 8
include/dpkg.h.in

@@ -225,14 +225,20 @@ struct buffer_data {
 	buffer_copy_setup((void *)fd, BUFFER_READ_FD, NULL, \
 			  buf, BUFFER_WRITE_VBUF, NULL, \
 			  limit, desc)
-#define fd_null_copy(fd, limit, desc...)\
-	buffer_copy_setup((void *)fd, BUFFER_READ_FD, NULL, \
-			  NULL, BUFFER_WRITE_NULL, NULL, \
-			  limit, desc)
-#define stream_null_copy(file, limit, desc...)\
-	buffer_copy_setup((void *)file, BUFFER_READ_STREAM, NULL, \
-			  NULL, BUFFER_WRITE_NULL, NULL, \
-			  limit, desc)
+#define fd_null_copy(fd, limit, desc...) \
+	if (lseek(fd, limit, SEEK_CUR) == -1) { \
+	    if(errno != ESPIPE) ohshite(desc); \
+	    buffer_copy_setup((void *)fd, BUFFER_READ_FD, NULL, \
+			      0, BUFFER_WRITE_NULL, NULL, \
+			      limit, desc);\
+	}
+#define stream_null_copy(file, limit, desc...) \
+	if (fseek(file, limit, SEEK_CUR) == -1) { \
+	    if(errno != EBADF) ohshite(desc); \
+	    buffer_copy_setup((void *)file, BUFFER_READ_STREAM, NULL, \
+			      0, BUFFER_WRITE_NULL, NULL, \
+			      limit, desc);\
+	}
 #define stream_fd_copy(file, fd, limit, desc...)\
 	buffer_copy_setup((void *)file, BUFFER_READ_STREAM, NULL, \
 			  (void *)fd, BUFFER_WRITE_FD, NULL, \