• Pete Zaitcev's avatar
    usblp: Implement the ENOSPC convention · 7f477358
    Pete Zaitcev authored
    This patch implements a mode when a printer returns ENOSPC when it runs
    out of paper. The default remains the same as before. An application which
    wishes to use this function has to enable it explicitly with an ioctl
    LPABORT.
    
    This is done on a request by our (Fedora) CUPS guy, Tim Waugh. The API is
    similar enough to the lp0's one that CUPS works with both (but see below),
    but it's has some differences.
    
    Most importantly, the abort mode is persistent in case of lp0: once tunelp
    was run your cat fill blow up until you reboot or run tunelp again. For
    usblp, I made it so the abort mode is only in effect as long as device
    is open. This way you can mix and match CUPS and cat(1) freely and nothing
    bad happens even if you run out of paper. It is also safer in the face
    of any unexpected crashes.
    
    It has to be noted that mixing LPABORT and O_NONBLOCK is not advised.
    It probably does not do what you want: instead of returning -ENOSPC
    it will always return -EAGAIN (because it would otherwise block while
    waiting for the paper). Applications which use O_NONBLOCK should continue
    to use LPGETSTATUS like before.
    
    Finally, CUPS actually requires patching to take full advantage of this.
    It has several components; those which invoke LPABORT work, but some of
    them need the ioctl added. This is completely compatible, you can mix
    old CUPS and new kernels or vice versa.
    Signed-off-by: default avatarPete Zaitcev <zaitcev@redhat.com>
    Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
    7f477358
usblp.c 38.7 KB