new applets lpr,lpq (update)

Denys Vlasenko vda.linux at googlemail.com
Mon Jul 21 22:19:32 UTC 2008


On Tuesday 22 July 2008 00:15, Denys Vlasenko wrote:
> > / # strace -f -v -s 1024  lpr
> > -Ppsprint at lpdserver /mnt/nfs/testpage.ps                                                                                      
> > ioctl(0, SNDCTL_TMR_TIMEBASE or TCGETS, {c_iflags=0x500, c_oflags=0x5,
> > c_cflags=0x1cb1, c_lflags=0x8a3b, c_line=0, c_cc="\x03\x1c\x08\x15\x04
> > \x00\x01\x00\x0
> ...
> ...
> 
> I find it very pleasant to spend 15 minutes unwrapping the strace,
> removing extra spaces and the like. However note that some other
> developers may have less perverted methods of having fun, and may
> resort to simple entertainments like beating the email's author
> with big stick. :)
> 
> Let's take a look.
> 
> 
> # strace -f -v -s 1024 lpr -Ppsprint at lpdserver /mnt/nfs/testpage.ps
> ioctl(0, SNDCTL_TMR_TIMEBASE or TCGETS, {c_iflags=0x500, c_oflags=0x5, c_cflags=0x1cb1, c_lflags=0x8a3b, c_line=0, c_cc="\x03\x1c\x08\x15\x04\x00\x01\x00\x0
> ioctl(1, SNDCTL_TMR_TIMEBASE or TCGETS, {c_iflags=0x500, c_oflags=0x5, c_cflags=0x1cb1, c_lflags=0x8a3b, c_line=0, c_cc="\x03\x1c\x08\x15\x04\x00\x01\x00\x0
> ...
> close(3)                                = 0
> 
> nothing interesting above.
> 
> socket(PF_INET, SOCK_STREAM, IPPROTO_IP) = 3
> setsockopt(3, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0
> connect(3, {sa_family=AF_INET, sin_port=htons(515), sin_addr=inet_addr("192.168.70.12")}, 16) = 0
> 
> We opened a TCP connection to 192.168.70.12:515.
> 
> getpid()                                = 260
> uname({sysname="Linux", nodename="blackfin", release="2.6.22.18-ADI-2008R1-svn", version="#60 Fri Jul 18 13:39:32 CEST 2008", machine="blackfin"}) = 0
> write(3, "\2psprint\n", 9)              = 9
> 
> We say "I want to print to queue 'psprint'".
> 
> read(3, "\0", 1)                        = 1
> 
> Server says "ok"
> 
> open("/mnt/nfs/testpage.ps", O_RDONLY)  = 4
> write(3, "\00254 cfA260blackfin\n", 19) = 19
> 
> We say "here goes the controlfile" (\002)
> "of 54 bytes" (54) "named cfA260blackfin"
> 
> write(3, "Hblackfin\nProot\nJ/mnt/nfs/testpage.ps\nldfA260blackfin\n", 54) = 54
> 
> We send controlfile contents:
> "H<host>\n", "P<user>\n", "J<jobname>\n" "l<datafilename>\n"
> 
> write(3, "\0", 1)                       = 1
> 
> We say "is it ok"?
> 
> read(3, "\0", 1)                        = 1
> 
> server says "ok"
> 
> fstat(4, {st_dev=makedev(0, 15), st_ino=696322, st_mode=S_IFREG|0644, st_nlink=1, st_uid=0, st_gid=0, st_blksize=8192, st_blocks=520, st_size=260183, st_at0
> write(3, "\003260183 dfA260blackfin\n", 23) = 23
> 
> We say "here is a datafile, 260183 bytes, named dfA260blackfin"
> 
> read(4, "%!PS-Adobe-2.0\n%%Title: testpage.fig\n%%Creator: fig2dev Version 3.2 Patchlevel 3d\n%%CreationDate: Mon Dec  3 11:54:07 2001\n%%For: papowell at h116
> write(3, "%!PS-Adobe-2.0\n%%Title: testpage.fig\n%%Creator: fig2dev Version 3.2 Patchlevel 3d\n%%CreationDate: Mon Dec  3 11:54:07 2001\n%%For: papowell at h16
> read(4, "Bold ff 150.00 scf sf\n5700 7800 m\ngs 1 -1 sc (Gold) dup swpop 2 div neg 0 rm  col-1 sh gr\n/Helvetica-Bold ff 150.00 scf sf\n69007800 m\ngs 1 6
> write(3, "Bold ff 150.00 scf sf\n5700 7800 m\ngs 1 -1 sc (Gold) dup swpop 2 div neg 0 rm  col-1 sh gr\n/Helvetica-Bold ff 150.00 scf sf\n69007800 m\ngs 16
> ...
> read(4, "00dfff4e4a4e\n009b004e003d024e003d0e4e029b034e005e009b354e\nrestore grestore\n%\n% End Imported PIC File: LPRngT-L.gif\n%\n/Times-Roman ff 180.00 5
> write(3, "00dfff4e4a4e\n009b004e003d024e003d0e4e029b034e005e009b354e\nrestore grestore\n%\n% End Imported PIC File: LPRngT-L.gif\n%\n/Times-Roman ff 180.005
> 
> we sent the file
> 
> write(3, "\0", 1)                       = 1
> 
> We say "is it ok"?
> 
> read(3, "\0", 1)                        = 1
> 
> server says "ok"
> 
> close(3)                                = 0
> _exit(0)
> 
> we exit.
> 
> What confuses me here is that it looks like server was totally happy
> and actually accepted the job. I suspect you sent a strace of
> successful lpr.

In light of above, and since you say

>PS: Printing from an XScale board using LPRng works.

can you provide strace of successful printing of exactly
the same file which fails to be printed by busybox's lpr?

But _please_, use "strace -o strace.logfile ..." option so that
strace output is not garbled. Also adding -tt option helps
(it adds timestamps to strace output).
--
vda



More information about the busybox mailing list