Blame SOURCES/cups-usb-paperout.patch

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