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