cefc15d
--- cups-1.2.10/backend/usb-unix.c.usb-paperout	2007-06-26 15:11:14.000000000 +0100
cefc15d
+++ cups-1.2.10/backend/usb-unix.c	2007-06-26 15:16:23.000000000 +0100
cefc15d
@@ -39,6 +39,11 @@
cefc15d
 #include "ieee1284.c"
cefc15d
 #include <sys/select.h>
2df06f8
 
2df06f8
+#ifdef __linux
2df06f8
+#include <sys/ioctl.h>
2df06f8
+#include <linux/lp.h>
2df06f8
+#endif /* __linux */
2df06f8
+
ffa8fef
 
cefc15d
 /*
cefc15d
  * Local functions...
cefc15d
@@ -308,7 +313,19 @@
cefc15d
   if (!strncmp(uri, "usb:/dev/", 9))
cefc15d
 #ifdef __linux
cefc15d
   {
cefc15d
-    return (open(uri + 4, O_RDWR | O_EXCL));
cefc15d
+    fd = open(uri + 4, O_RDWR | O_EXCL);
2df06f8
+
cefc15d
+    if (fd != -1)
2df06f8
+    {
cefc15d
+     /*
cefc15d
+      * Tell the driver to return from write() with errno==ENOSPACE
cefc15d
+      * on paper-out.
cefc15d
+      */
cefc15d
+      unsigned int t = 1;
cefc15d
+      ioctl (fd, LPABORT, &t);
2df06f8
+    }
2df06f8
+
cefc15d
+    return fd;
2df06f8
   }
cefc15d
   else if (!strncmp(uri, "usb://", 6))
cefc15d
   {
cefc15d
@@ -374,7 +391,14 @@
cefc15d
         if (!strcmp(uri, device_uri))
cefc15d
 	{
cefc15d
 	 /*
cefc15d
-	  * Yes, return this file descriptor...
cefc15d
+	  * Yes, tell the driver to return from write() with
cefc15d
+	  * errno==ENOSPACE on paper-out.
cefc15d
+	  */
cefc15d
+	  unsigned int t = 1;
cefc15d
+	  ioctl (fd, LPABORT, &t);
2df06f8
+
cefc15d
+	 /*
cefc15d
+	  * Return this file descriptor...
cefc15d
 	  */
2df06f8
 
cefc15d
 	  fprintf(stderr, "DEBUG: Printer using device file \"%s\"...\n", device);