4743e10
diff -up cups-1.5b1/backend/usb-unix.c.usb-paperout cups-1.5b1/backend/usb-unix.c
4743e10
--- cups-1.5b1/backend/usb-unix.c.usb-paperout	2011-05-24 15:51:39.000000000 +0200
4743e10
+++ cups-1.5b1/backend/usb-unix.c	2011-05-24 15:51:39.000000000 +0200
cb06f24
@@ -30,6 +30,11 @@
cb06f24
 
1162628
 #include <sys/select.h>
72da820
 
72da820
+#ifdef __linux
72da820
+#include <sys/ioctl.h>
72da820
+#include <linux/lp.h>
72da820
+#endif /* __linux */
72da820
+
b66134a
 
1162628
 /*
1162628
  * Local functions...
4743e10
@@ -334,7 +339,19 @@ open_device(const char *uri,		/* I - Dev
1162628
   if (!strncmp(uri, "usb:/dev/", 9))
1162628
 #ifdef __linux
1162628
   {
1162628
-    return (open(uri + 4, O_RDWR | O_EXCL));
1162628
+    fd = open(uri + 4, O_RDWR | O_EXCL);
72da820
+
1162628
+    if (fd != -1)
72da820
+    {
1162628
+     /*
1162628
+      * Tell the driver to return from write() with errno==ENOSPACE
1162628
+      * on paper-out.
1162628
+      */
1162628
+      unsigned int t = 1;
1162628
+      ioctl (fd, LPABORT, &t);
72da820
+    }
72da820
+
1162628
+    return fd;
72da820
   }
1162628
   else if (!strncmp(uri, "usb://", 6))
1162628
   {
4743e10
@@ -400,7 +417,14 @@ open_device(const char *uri,		/* I - Dev
1162628
         if (!strcmp(uri, device_uri))
1162628
 	{
1162628
 	 /*
1162628
-	  * Yes, return this file descriptor...
1162628
+	  * Yes, tell the driver to return from write() with
1162628
+	  * errno==ENOSPACE on paper-out.
1162628
+	  */
1162628
+	  unsigned int t = 1;
1162628
+	  ioctl (fd, LPABORT, &t);
72da820
+
1162628
+	 /*
1162628
+	  * Return this file descriptor...
1162628
 	  */
72da820
 
2467bda
 	  fprintf(stderr, "DEBUG: Printer using device file \"%s\"...\n",