summaryrefslogtreecommitdiff
path: root/rpmio/rpmio.c
AgeCommit message (Collapse)AuthorFilesLines
2012-11-05Fix strncat() boundaries in Fdopen()Dominique Leuenberger1-3/+3
Signed-off-by: Panu Matilainen <pmatilai@redhat.com>
2012-10-30Handle EINTR in Fread() and Fwrite()Panu Matilainen1-2/+6
- Not all systems automatically restart signal-interrupted operations, handle this centrally since its so easy to do. Also related to RhBug:580974.
2012-08-17Revert "Always return NULL from fdFree()"Panu Matilainen1-1/+1
- This reverts commit 4c1f7e335de1724661ce63c53186d161ab71a63f: various things inside and outside of rpm actually do still depend on the old behavior, and leak file descriptors otherwise. As an easy backportable band-aid, revert back to the previous behavior, to which various callers are tuned to fix the regression introduced in rpm 4.10.0. The real fix would be something more like "eliminate fdFree() and make Fclose() honor refcounts".
2012-04-18Always return NULL from fdFree()Panu Matilainen1-1/+1
- Up to now, if the fd had remaining references fdFree() would return the supposedly free'd fd back to us, which is unlike anything else in rpm. Make this consistent with the rest of rpm finally as the last remaining caller requiring the old semantics is gone from the codebase (somewhere between 4.9 and 4.10): always return NULL, as the referenced instance is now gone as far as the caller is concerned.
2012-03-14Fix ufdCopy() for large (> 2GB) filesPanu Matilainen1-22/+16
- Files can be (much) larger than INT32_MAX, change the return type to off_t and fix + simplify the calculations. Fixes the other half of RhBug:790396 and makes ufdCopy() usable for other purposes too.
2011-10-11rpmio: Don't de-ref lzfile which was freed in lzclose()Mukund Sivaraman1-1/+3
2011-09-15Whoops, ftell() and rpmio equivalents should return long not off_tPanu Matilainen1-1/+1
2011-08-19Remove support for ancient bzip2 library versionsPanu Matilainen1-19/+9
- bzip2 1.0 is over ten years old by now, anybody still using versions older than that get what they deserve...
2011-08-19Remove unused FDFOO macrosPanu Matilainen1-10/+0
2011-07-12Whoops, wrong variable passed to io debuggingPanu Matilainen1-1/+1
2011-07-11Cleanup fdRead(), fdWrite() and fdSeek() a bitPanu Matilainen1-21/+5
- Remove unnecessary fluff, these are very simple operations and dont need any temporary variables, re-re-redundant NULL checking etc, its already done at the caller level.
2011-07-11Cosmetics: remove empty comments and suchPanu Matilainen1-31/+3
2011-07-11Dont bother checking for NULL fd on stats collectionPanu Matilainen1-2/+0
- All the places calling these are already checking for NULL fd, no point re-re-re-re-re-checking it
2011-07-11Centralize most of the debug goo as wellPanu Matilainen1-21/+19
2011-07-11Just pass fd pointers around instead of "cookies" cast to fdPanu Matilainen1-62/+36
- There's not a whole lot of point passing our own data structure around in void pointers and re-re-re-re-re-recasting them to fd's again all over the place. Just pass the damn fd to begin with.
2011-07-11Centralize fd digests collectionPanu Matilainen1-16/+6
- Instead of requiring every io type to remember to update digests on their own, do it centrally on Fread() and Fwrite(). - This changes the digest calculation on writes slightly: previously we calculated the digests regardless whether the actual write succeeded or not, now we do this similarly to reads and only update the digests on success.
2011-07-11Centralize fd stats collectionPanu Matilainen1-35/+8
- Instead of requiring every io type to call stats on their own, simply call the stat updates from the main functions Fread() etc
2011-07-11Eliminate unused leftover bytesRemain member from FD_tPanu Matilainen1-35/+2
- This used to be relevant for remote io but now its just unused. - Also remove the "simulate EOF" on NULL fd returns while at it, these seem simply wrong (considering Fread() and Fwrite() behave more like read() and write rather than fread() and fwrite())
2011-07-11Minor cosmetics cleanup to Fseek()Panu Matilainen1-10/+7
2011-07-11Return an error on Fread() / Fwrite() on NULL fdPanu Matilainen1-16/+13
- Merrily returning success on read/write on NULL fd just is not sane. If something breaks because of this then that something needs fixing instead... - Also return code type was mismatching in both, these return ssize_t not int.
2011-07-11Implement Ftell() for zlib versions that support itPanu Matilainen1-1/+23
2011-07-11Use a vector for Ftell() functionality tooPanu Matilainen1-14/+17
2011-07-11Remove pointless fdSeekNot() "not implemented" functionPanu Matilainen1-8/+3
- Fseek() and friends already return -2 for not implemented functions, this is not needed at all
2011-07-08Fix totally broken Fflush() operationPanu Matilainen1-17/+14
- This only ever worked for fpio, for all other types it returns bogons or crashes and burns. - Use the file op vectors to find our fflush function instead of #ifdef/#endif if/else/ifelse jungle. - Notably fdio and ufdio do not have a fflush() equivalent because they dont need one. Use a dummy function to always return success to differentiate from -2 aka "not supported by this io type"
2011-07-08Axe the broken fpio support for goodPanu Matilainen1-70/+5
- The whole thing is extremely hacky and failing to properly take fundamental differences in eg fread() and read() semantics into account (the whole rpmio fd is confused over this: Fread() claims to be fread() clone but reads behave with read() semantics and we dont provide feof() equivalent etc), special cased all over the io code when vectors exist for this purpose etc (not that fpio is the only offender in that regard)... RIP. Nothing should miss this but if we'd ever want to add it back, it'd better be done right at least. - This COULD silently break somebody's code if they rely on the broken special case semantics of fpio mode, but most likely rpm itself was the only thing using fpio (and relying on the behavior) and even then, mostly only to get a FILE stream pointer out of it. Now we'll just silently return a fdio descriptor, as we do for any unrecognized io mode... (another sigh)
2011-07-08zlib is mandatory, fail at configure if missing + remove conditionalsPanu Matilainen1-15/+0
- Unlike bz2 and xz/lz, zlib compression is not tracked by any rpmlib feature and is part of the original package format really, zlib simply must be always present.
2011-07-08Eliminate the uuugly and stupid fdGetFILE() from the APIPanu Matilainen1-1/+1
2011-07-07Remember path (or other description) in fd's, add getterPanu Matilainen1-9/+46
- If opened by path, we obviously want to use that. Otherwise generate a description lazily on first Fdescr() call: on Linux we can grab something relatively meaningful by looking up from /proc (this is why we want to be lazy here...). If that's not available or fails, just generate a string on the current fdno. Actual paths are returned as is, other descriptions are bracketed, (eg "[mumble 123]"). - This makes it possible to give more meaningful error messages in places where we only get an fd from somebody (related to RhBug:522160)
2011-07-07Eliminate fdNew() from the APIPanu Matilainen1-1/+1
- Nobody should be able to create file descriptors which are not attached to a file/descriptor of some kind, the only sane fd constructors are Fopen(), Fdopen() and fdDup(). - The same applies to fdFree() but its a bit more complicated, punting that till later...
2011-05-28Eliminate dead NULL-assignments from rpmio fd close functionsPanu Matilainen1-5/+5
2011-05-03Remove obsolete timedRead() from APIJindrich Novy1-5/+0
2011-03-23Avoid timedRead() usageJindrich Novy1-1/+1
- it is to be removed in the next soname bump
2011-03-23Remove libio support to suppress timedRead()Jindrich Novy1-71/+14
2010-10-22Eliminate use of pgpHashAlgo in rpmio interface argumentsPanu Matilainen1-5/+3
- While its use would seem kinda obvious here, in rpm context this information often comes from header tags which are plain integers and would require conversion/casting to the enum. What matters is the integral value, not it being actual enum.
2010-09-21Error string is const char *, not void pointerPanu Matilainen1-2/+2
2010-09-21Adjust internal io read, write and digest update to take buf as void pointerPanu Matilainen1-22/+22
- This matches ffread() and read() much better, avoiding pile of casts. - By some stroke of genious, glibc cookie interfaces disagree with the other file stream protos by using char * for buf. Argh. Add explicit cast for the schizophrenia.
2010-09-21Change fdstat functions to take fdOpx enum to fix int/enum mismatchesPanu Matilainen1-2/+2
2010-09-08Fix _USE_LIBIO testPanu Matilainen1-4/+4
- Commit 05b2d979e8097d648f91c773f2535a1f6013cb79 caused the _USE_LIBIO test in rpmio.c to always fail as <stdio.h> wasn't included yet at the time of the check, causing silent fallback to not using libio even if actually available. Which in turn revealed funky other little bugs, addressed in commits d960e8c18764f7206ad723963f407e960dfb8ad9 and be3c34dd15814d70a410b6fd646a2be7de14a1b5. Ptooey.
2010-03-29Lose long since unused fdReadable() and fdWritable()Panu Matilainen1-98/+0
- these have been unused since rpm 4.6.0, and can be implemented without access to rpmio internals too if somebody cares...
2010-03-22Further rpmio NULL sanity checksPanu Matilainen1-20/+22
- instead of blowing up with asserts, return error codes / NULLs
2010-03-22Lose FDSANE() macro, check in c2f() and callers insteadPanu Matilainen1-8/+3
2010-03-22Change most of the FDSANE() asserts into good old NULL-checksPanu Matilainen1-28/+22
- blowing up with an assert failure deep inside io "library" is not a very friendly thing to do...
2010-03-22Lose the useless rpmio refcounting debug junkPanu Matilainen1-40/+31
- the rpmio API always had this goo, should've gotten rid of it back in commit dbdbe8010cd944f026a5a4e5d071eb31d29d81c4 but .. oh well
2010-01-05Move <errno.h> include out of system.h to the places that need itPanu Matilainen1-0/+1
2010-01-04Clean up poll() vs select() testsPanu Matilainen1-0/+6
- move the includes out of system.h, not commonly needed - <poll.h> is conditional as we actually provide a fallback through select(), but for <sys/select.h> missing there's no fallback so doesn't make much sense to test for (and both poll.h and sys/select.h are posix anyway...)
2009-10-17Unbreak lzdio/xzdioPanu Matilainen1-7/+11
- revert part of b0d1038190be5cb4b45e2c2c7c84ee7022164ba2 which broke the split-personality lzdio/xzdio
2009-10-16Use a helper function for finding fileno of specific io typePanu Matilainen1-39/+24
- also differentiate between lzdio and xzdio here
2009-10-16Lose unnecessary url type checking from fdSize()Panu Matilainen1-15/+2
- we're only dealing with local files once fd is opened
2009-10-16Lose unused leftover definitionsPanu Matilainen1-14/+0
2009-10-16Eliminate ufdio-specific read, write, seek and closePanu Matilainen1-162/+3
- we dont do network IO anymore so ufdio only differs from fdio by downloading the file on open if necessary, after that it's just fdio