bin/151567: [patch] lp(1) fails on ZFS filesystem
Peter Jeremy
Peter.Jeremy at alcatel-lucent.com
Tue Oct 19 01:00:25 UTC 2010
>Number: 151567
>Category: bin
>Synopsis: [patch] lp(1) fails on ZFS filesystem
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: freebsd-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: sw-bug
>Submitter-Id: current-users
>Arrival-Date: Tue Oct 19 01:00:24 UTC 2010
>Closed-Date:
>Last-Modified:
>Originator: Peter Jeremy
>Release: FreeBSD 8.1-PRERELEASE amd64
>Organization:
Alcatel-Lucent Australia
>Environment:
System: FreeBSD pjdesk.au.alcatel-lucent.com 8.1-PRERELEASE FreeBSD 8.1-PRERELEASE #19: Wed Jul 14 07:24:18 EST 2010 root at pjdesk.au.alcatel-lucent.com:/var/obj/usr/src/sys/pjdesk amd64
The code is identical in -current.
>Description:
Printing from a ZFS filesystem using 'lp' fails and returns an
email reporting "Your printer job was not printed because it was
not linked to the original file".
In order to protect against files being switched when files
are printed using 'lp' or 'lpr -s', the st_dev and st_ino
values for the original file are saved by lpr and verified
by lpd before the file is printed. Unfortunately, lpr prints
both values using '%d' (although both fields are unsigned)
and lpd(8) assumes a string of decimal digits.
ZFS (at least) generates st_dev values greater than 2^31-1,
resulting in negative values being printed - which lpd cannot
parse, leading it to report that the file has been switched.
A similar problem would occur with large inode numbers.
>How-To-Repeat:
Find a file with either st_dev or st_ino greater than 2^31-1
(stat(1) will report both numbers) and print it with 'lpq -s'.
This should generate an email reporting that the file could
not be printed because it was not linked to the original file
>Fix:
Index: lpr/lpr.c
===================================================================
RCS file: /usr/ncvs/src/usr.sbin/lpr/lpr/lpr.c,v
retrieving revision 1.44.32.1
diff -u -r1.44.32.1 lpr.c
--- lpr/lpr.c 3 Aug 2009 08:13:06 -0000 1.44.32.1
+++ lpr/lpr.c 19 Oct 2010 00:16:00 -0000
@@ -386,7 +386,7 @@
continue; /* file unreasonable */
if (sflag && (cp = linked(arg)) != NULL) {
- (void) snprintf(buf, sizeof(buf), "%d %d", statb.st_dev,
+ (void) snprintf(buf, sizeof(buf), "%u %u", statb.st_dev,
statb.st_ino);
card('S', buf);
if (format == 'p')
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the freebsd-bugs
mailing list