Blame SOURCES/cups-usb-paperout.patch

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