ccfde00
diff -up cups-1.3.7/backend/usb-unix.c.usb-paperout cups-1.3.7/backend/usb-unix.c
ccfde00
--- cups-1.3.7/backend/usb-unix.c.usb-paperout	2008-07-15 13:47:33.000000000 +0100
ccfde00
+++ cups-1.3.7/backend/usb-unix.c	2008-07-15 13:47:33.000000000 +0100
ccfde00
@@ -31,6 +31,11 @@
390aca2
 #include "ieee1284.c"
390aca2
 #include <sys/select.h>
2df06f8
 
2df06f8
+#ifdef __linux
2df06f8
+#include <sys/ioctl.h>
2df06f8
+#include <linux/lp.h>
2df06f8
+#endif /* __linux */
2df06f8
+
72e0124
 
390aca2
 /*
390aca2
  * Local functions...
ccfde00
@@ -323,7 +328,19 @@ open_device(const char *uri,		/* I - Dev
390aca2
   if (!strncmp(uri, "usb:/dev/", 9))
390aca2
 #ifdef __linux
390aca2
   {
390aca2
-    return (open(uri + 4, O_RDWR | O_EXCL));
390aca2
+    fd = open(uri + 4, O_RDWR | O_EXCL);
2df06f8
+
390aca2
+    if (fd != -1)
2df06f8
+    {
390aca2
+     /*
390aca2
+      * Tell the driver to return from write() with errno==ENOSPACE
390aca2
+      * on paper-out.
390aca2
+      */
390aca2
+      unsigned int t = 1;
390aca2
+      ioctl (fd, LPABORT, &t);
2df06f8
+    }
2df06f8
+
390aca2
+    return fd;
2df06f8
   }
390aca2
   else if (!strncmp(uri, "usb://", 6))
390aca2
   {
ccfde00
@@ -389,7 +406,14 @@ open_device(const char *uri,		/* I - Dev
390aca2
         if (!strcmp(uri, device_uri))
390aca2
 	{
390aca2
 	 /*
390aca2
-	  * Yes, return this file descriptor...
390aca2
+	  * Yes, tell the driver to return from write() with
390aca2
+	  * errno==ENOSPACE on paper-out.
390aca2
+	  */
390aca2
+	  unsigned int t = 1;
390aca2
+	  ioctl (fd, LPABORT, &t);
2df06f8
+
390aca2
+	 /*
390aca2
+	  * Return this file descriptor...
390aca2
 	  */
2df06f8
 
ccfde00
 	  fprintf(stderr, "DEBUG: Printer using device file \"%s\"...\n",