Hi,
On Tuesday 28 December 2010 17:01:50 Jeff Johnson wrote:
> The solution here is to use Fopen(), not fdOpen().
I'm testing this in a function but it doesn't work:
FD_t fd;
int rc;
fd = Fopen(headerFile, O_RDONLY);
if (Fileno(fd) < 0) {
return 1;
}
rc = rpmReadPackageFile(ts, fd, headerFile, h);
Fopen() returns always 0 for fd. I've tried with different existing full paths
or rpm and src.rpm files. E.g. my application prints:
Warning: reading
/var/ftp/pub/openmamba/devel/SRPMS.base/54321-1.0.2001.11.16-3mamba.src.rpm
Warning: 54321-1.0.2001.11.16-3mamba.src.rpm: unable to read header (No such
file or directory); skipping.
headerFile in Fopen is the path shown and "No such file or directory" is the
string conversion of errno.
Currently I don't have a lot of ideas about what is wrong with this code, am I
using Fopen and rpmReadPackageFile correctly or do I have to change approach
here as well?
Thanks.
Silvan
>
> > Looking inside rpmio.h I see this:
> >
> > /**
> > */
> > /*...@null@*/ FD_t fdOpen(const char *path, int flags, mode_t mode)
> >
> > /*...@globals errno, fileSystem, internalState @*/
> > /*...@modifies errno, fileSystem, internalState @*/;
> >
> > #define fdOpen(_path, _flags, _mode) fdio->_open((_path), (_flags),
> > (_mode))
> >
> > but fdio->_open is not defined, infact FDIO_s contains:
> >
> > /** \ingroup rpmio
> > */
> > struct FDIO_s {
> >
> > fdio_read_function_t read;
> > fdio_write_function_t write;
> > fdio_seek_function_t seek;
> > fdio_close_function_t close;
> >
> > /*...@null@*/
> >
> > fdio_fopen_function_t _fopen;
> >
> > /*...@null@*/
> >
> > fdio_fdopen_function_t _fdopen;
> >
> > /*...@null@*/
> >
> > fdio_flush_function_t _flush;
> >
> > };
> >
> > Is that a headers problem or is it intended that I should use a different
> > approach?
>
> Different approach. But you can call through the FDIO_s vector to
> _fopen still if necessary, I don't recall any changes there.
>
> The intent is a stdio-like interface, with Fopen instead of fopen, Fread
> instead of fread.
>
> Note that the first argument to Fopen can be a URI too. That "works" for
> full content reads on ftp:// and (mostly, no redirects, no proxies, ...)
> on http:// in rpm-5.2.1.
>
> Try tools/*wget to see what works and what doesn't.
>
> > Thanks for your help!
>
> np. I can/will help with any porting issues.
>
> 73 de Jeff
>
> > Silvan
>
> ______________________________________________________________________
> RPM Package Manager http://rpm5.org
> Developer Communication List [email protected]
--
mambaSoft di Calarco Silvan
Web: http://www.mambasoft.it
mambaSoft Store @ http://www.mambastore.it
openmamba GNU/Linux development @ http://www.openmamba.org
______________________________________________________________________
RPM Package Manager http://rpm5.org
Developer Communication List [email protected]