Blame SOURCES/cups-usb-paperout.patch

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