From 69a6ca1782e5451532476b6d51a09fc005ad1491 Mon Sep 17 00:00:00 2001 From: Packit Date: Oct 27 2020 15:27:07 +0000 Subject: Apply patch cups-usb-paperout.patch patch_name: cups-usb-paperout.patch present_in_specfile: true --- diff --git a/backend/usb-unix.c b/backend/usb-unix.c index 004f116..86ccf3e 100644 --- a/backend/usb-unix.c +++ b/backend/usb-unix.c @@ -21,6 +21,11 @@ #include +#ifdef __linux +#include +#include +#endif /* __linux */ + /* * Local functions... @@ -318,7 +323,19 @@ open_device(const char *uri, /* I - Device URI */ if (!strncmp(uri, "usb:/dev/", 9)) #ifdef __linux { - return (open(uri + 4, O_RDWR | O_EXCL)); + fd = open(uri + 4, O_RDWR | O_EXCL); + + if (fd != -1) + { + /* + * Tell the driver to return from write() with errno==ENOSPACE + * on paper-out. + */ + unsigned int t = 1; + ioctl (fd, LPABORT, &t); + } + + return fd; } else if (!strncmp(uri, "usb://", 6)) { @@ -384,7 +401,14 @@ open_device(const char *uri, /* I - Device URI */ if (!strcmp(uri, device_uri)) { /* - * Yes, return this file descriptor... + * Yes, tell the driver to return from write() with + * errno==ENOSPACE on paper-out. + */ + unsigned int t = 1; + ioctl (fd, LPABORT, &t); + + /* + * Return this file descriptor... */ fprintf(stderr, "DEBUG: Printer using device file \"%s\"...\n",