Discussion:
Bug ? rpm -qlp exits with status 0 on I/O error
Andre Majorel
2007-10-10 15:17:50 UTC
Permalink
rpm -qlp $file silently exits with status 0 if there's an I/O
error on $file. Is this deliberate ? In my opinion,
{ perror($file); exit (1); } would be a more useful behaviour.

# strace rpm -qlp /mnt2/suse/i586/ami-1.2.3-110.i586.rpm
...
open("/mnt2/suse/i586/ami-1.2.3-110.i586.rpm", O_RDONLY|O_LARGEFILE) = 3
fcntl64(3, F_SETFD, FD_CLOEXEC) = 0
mmap2(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0)
= 0xb7f86000
poll([{fd=3, events=POLLIN, revents=POLLIN}], 1, 1000) = 1
read(3, 0xb7f86000, 8192) = -1 EIO (Input/output error)
close(3) = 0
munmap(0xb7f86000, 8192) = 0
exit_group(0) = ?
Process 15257 detached
# echo $?
0
# rpm --version
RPM version 4.4.1
--
André Majorel <URL:http://www.teaser.fr/~amajorel/>
Do not use this account for regular correspondence.
See the URL above for contact information.
Jeff Johnson
2007-10-11 02:13:20 UTC
Permalink
Post by Andre Majorel
rpm -qlp $file silently exits with status 0 if there's an I/O
error on $file. Is this deliberate ? In my opinion,
{ perror($file); exit (1); } would be a more useful behaviour.
Fixed:

$ rpm -qp glibc-2.6.90-12.i686.rpm ; echo $?
glibc-2.6.90-12.i686
0
$ dd if=/dev/zero of=glibc-2.6.90-12.i686.rpm count=1
1+0 records in
1+0 records out
512 bytes (512 B) copied, 0.000139087 s, 3.7 MB/s
$ rpm -qp glibc-2.6.90-12.i686.rpm ; echo $?
1
$ rpm --version
RPM version 5.0.DEVEL

73 de Jeff
Andre Majorel
2007-10-12 15:41:59 UTC
Permalink
Post by Jeff Johnson
Post by Andre Majorel
rpm -qlp $file silently exits with status 0 if there's an I/O
error on $file.
$ rpm -qp glibc-2.6.90-12.i686.rpm ; echo $?
1
$ rpm --version
RPM version 5.0.DEVEL
Thank you.

A diagnostic to stderr would still be welcome. :-)
--
André Majorel <URL:http://www.teaser.fr/~amajorel/>
Do not use this account for regular correspondence.
See the URL above for contact information.
Jeff Johnson
2007-10-12 16:01:11 UTC
Permalink
Post by Andre Majorel
Post by Jeff Johnson
Post by Andre Majorel
rpm -qlp $file silently exits with status 0 if there's an I/O
error on $file.
$ rpm -qp glibc-2.6.90-12.i686.rpm ; echo $?
1
$ rpm --version
RPM version 5.0.DEVEL
Thank you.
A diagnostic to stderr would still be welcome. :-)
Sure would, but then the RFE after that is
Why does rpm report errors twice?

What makes the reporting a bit trickier is that any path that fails
to open as a *.rpm file, will then be opened as a manifest file.

E.g.
echo "glibc-2.6.90-12.i686.rpm" > b
rpm -qp b
is equivalent to
rpm -qp glibc-2.6.90-12.i686.rpm

The error reporting handling w manifest files is rather
different than *.rpm files. Consider what you wish to happen
(extending the previous example)
touch a
rpm -qp a b

Should the empty file "a" be an error or not? My personal
preference would be that
rpm -qp a b
behave like
rpm -qp `cat a b`

The framework to parse manifests/package files just got
integrated on all arg parsing paths in rpm-5.0 in July,
so I'm quite sure that I will eventually hear all the bugs and RFE's.

Likely more than you wanted to know. Apologies.

73 de Jeff

Loading...