summaryrefslogtreecommitdiff
path: root/src/filesdb.c
AgeCommit message (Collapse)AuthorFilesLines
2012-06-06dpkg-divert: Do not warn on missing db .list file for never installed packagesGuillem Jover1-1/+2
When the package has never been installed before, and the unpack has not yet finished, the package will be present on the database but the files list file will not, which would produce a bogus warning. Check if the package has ever been configured, before printing the warning. Closes: #673518
2012-04-03Print errors while reading file list files on a new lineGuillem Jover1-1/+0
Closes: #552517
2012-04-03Move pkg_infodb_get_dir() and pkg_infodb_get_file() to infodb-format.cGuillem Jover1-41/+0
These functions have never belonged in the filesdb module, but were put there temporarily for convenience.
2012-04-03Rename pkgadmin*() to pkg_infodb_get_*()Guillem Jover1-8/+9
2012-04-03Change pkgadmindir() to initialize infodir itselfGuillem Jover1-9/+4
This will guarantee there's never a time a call site can get NULL from the function, and detangles it from the in-core filesdb initialization.
2012-04-01Use cmp() == 0 instead of !cmp()Guillem Jover1-1/+2
2012-03-31Rename file iterator variables to iterGuillem Jover1-23/+31
2012-03-31Rename iterfiles*() functions to files_db_iter_*()Guillem Jover1-3/+9
2012-03-30dpkg: Pass filenamenode to pkg_files_add_file() instead of string and flagsGuillem Jover1-4/+8
2012-03-30Fix coding-styleGuillem Jover1-6/+6
2012-03-19dpkg: Update on-disk database to use a multiarch compliant layoutGuillem Jover1-0/+4
The usage of the new layout is conditional to a prior database upgrade that should write a version number greater than 0 in <admindir>/info/format. The file is parsed when needed from pkg_infodb_get_format(). Based-on-patch-by: Raphaël Hertzog <hertzog@debian.org> Patch-sponsored-by: Linaro Limited Signed-off-by: Guillem Jover <guillem@debian.org>
2012-03-16dpkg: Compute and track hashes for newly unpacked fileGuillem Jover1-0/+2
This will be used for checksum generation at unpack time, and for shared file verification.
2012-02-03dpkg: Use pnaw_nonambig instead of pnaw_foreign on .list file open errorGuillem Jover1-1/+1
Regression introduced in commit 0b8652b226a7601dfd71471797d15168a7337242. Spotted-by: Raphaël Hertzog <hertzog@debian.org>
2012-02-01Change debug, progress and error output to use package specifiersGuillem Jover1-8/+10
Replace pkg->set->name with varbuf_add_pkgbin_name(), pkgbin_name() or pkg_name(). This only changes informative output, so no behaviour change should result from this. Based-on-patch-by: Raphaël Hertzog <hertzog@debian.org> Patch-sponsored-by: Linaro Limited Signed-off-by: Guillem Jover <guillem@debian.org>
2012-01-02Use the new atomic file API instead of ad-hoc codeGuillem Jover1-29/+10
[hertzog@debian.org: - Switch dselect method option file. ]
2011-12-05dpkg: Error out if a database .list file is not a regular fileRaphaël Hertzog1-0/+4
LP: #369898 Signed-off-by: Guillem Jover <guillem@debian.org>
2011-12-05dpkg: Initialize all clientdata members in ensure_package_clientdata()Raphaël Hertzog1-0/+1
Although all users of replacingfilesandsaid are previously calling clear_istobes() to make sure it's initialized, doing so when allocating clientdata is safer from an API point of view. Signed-off-by: Guillem Jover <guillem@debian.org>
2011-11-14Replace all pkg_db_count() calls with pkg_db_count_pkg()Raphaël Hertzog1-1/+1
Sponsored-by: Linaro Limited Signed-off-by: Guillem Jover <guillem@debian.org>
2011-10-30Switch pkgadminfile() to get an explicit pkgbin as argumentGuillem Jover1-7/+7
The code does not do anything yet with this new argument, but it will allow it to access the multiarch information, once the on-disk layout is changed.
2011-10-27Switch from pkginfo->name to pkginfo->set->nameGuillem Jover1-14/+23
Remove now unused struct pkginfo name member.
2011-10-13dpkg: Use statfs() to retrieve the infodb filesystem block sizeGuillem Jover1-5/+7
This fixes two related issues when the FIGETBSZ ioctl fails, it avoids a file descriptor leak because we can get the block size before the loop, and avoids a segfault when sorting the package array due to the cliendata possibly being NULL on some of the package entries because we can bail out before performing the actual sorting. We use the Linux specific statfs(2), because it does way less work than statvfs(3) and the surrounding code is already non-portable due to its dependency on FIEMAP. LP: #872734
2011-09-09Do not include trailing slash for directory string literalsGuillem Jover1-0/+1
This makes it more natural to manage the directory names, and avoids some doubled slashes.
2011-05-15dpkg: Change write_filelist_except() to take a mask intead of a boolGuillem Jover1-4/+4
This generalizes the function to exclude any desired file namenode flag and not just fnnf_elide_other_lists. It also gets rid of the bool variable which is generally a bad interface to change function behaviour when it should really be a named flag or a mask.
2011-05-15dpkg: Make fd variable passed to cu_closefd staticGuillem Jover1-1/+1
The push_cleanup() call takes a pointer to the fd variable which resides in the stack. In case of error and stack unwinding due to longjmp, the value of fd might get overwritten by subsequent stack usage. Thus this kind of variables need to be static so that their value cannot change on stack rollback.
2011-05-15libdpkg: Rename cu_closefile to cu_closestreamGuillem Jover1-1/+1
This should make it clear we are referring to a stdio stream, and not the future planned ‘struct file’.
2011-03-14Move pkgadmindir() and pkgadminfile() to the filesdb moduleGuillem Jover1-0/+40
These functions are not really part of the modstatdb module, and by moving them out they get detangled and will make it possible to extend them w/o pulling additional code into binaries not using the functions.
2011-03-02Use varbuf_end_str() instead of ad-hoc varbuf_add_char() callsGuillem Jover1-1/+1
This allows the strings to be terminated, thus printable or accessed through the standard C string functions, and at the same time appendable.
2011-03-02dpkg: Use pkgadminfile() instead of varbuf_pkgadminfile()Guillem Jover1-4/+5
This simplifies the API, and unifies the different call sites, the extremely small performance penalty is irrelevant in these cases.
2011-02-11dpkg: Use varbuf_pkgadminfile() instead of manually building the pathGuillem Jover1-5/+1
2011-01-16libdpkg: Rename varbufaddstr() to varbuf_add_str()Guillem Jover1-5/+5
Make the varbuf API a bit more consistent.
2011-01-16libdpkg: Rename varbufaddc() to varbuf_add_char()Guillem Jover1-2/+2
Make the varbuf API a bit more consistent.
2011-01-16libdpkg: Rename varbufreset() to varbuf_reset()Guillem Jover1-2/+2
Make the varbuf API a bit more consistent.
2011-01-08Use fd_read() instead of fd_buf_copy()Guillem Jover1-2/+3
The latter is doing unneeded work. Switch to use a simpler but equally functional variant.
2010-11-19Cleanup white spacesGuillem Jover1-7/+7
Remove trailing spaces. Remove blank lines not separating different code blocks. Remove blank lines at the end of the file.
2010-11-19Cleanup and improve source code commentsGuillem Jover1-35/+34
Global review, which includes the following changes to try to increase consistency, update and improve the source code comments: - Spelling fixes. - Use American English forms. - Uppercase NULL, NUL and ASCII. - Use “Note: ” instead of the slightly cryptic “NB: ” form. - Write comments as proper sentences, including capitalizations and ending dots. - Move comments before the code, function or variable they refer to. - Move general function comments outside the body. - Convert function and variable description comments to doxygen. - Use one space before dot, exclamation and question marks. - Use ‘’ or “” instead of `' style quoting. - Remove author names from comments, already visible from “git blame”. - Mark strings for translators with “TRANSLATORS: ”. - Remove useless or outdated comments. - Fix comment indentation. - Standardize comment format: /* Short text comment. */ /* Long text, * comment. */ /* * Section text. */
2010-11-19libdpkg: Namespace package database functions with pkg_db_ prefixGuillem Jover1-1/+1
2010-08-26Add gettext messages for plural formsGuillem Jover1-1/+3
Some of the singular forms are not currently used, but we keep them for consistency, and to avoid confusing translators. Closes: #594218
2010-06-25dpkg: Use iterators instead of exposing packageslump directlyGuillem Jover1-0/+56
2010-05-19Use bool instead of int wherever appropriateGuillem Jover1-9/+13
2010-03-12Do an fsync on database directoriesGuillem Jover1-0/+3
After creating, renaming or unlinking database files sync its containing directory, to guarantee the new file entry is correctly listed in the directory. Closes: #567089 Base-on-patch-by: Jean-Baptiste Lallement <jeanbaptiste.lallement@gmail.com>
2010-03-12libdpkg: Create new pkgadmindir() to hide admindir and INFODIRGuillem Jover1-2/+1
The callers should not be concerned about where the package info directory is located, the new functions encapsulates the knowdlegde in the dbmodify module.
2010-03-05dpkg: Use posix_fadvise on non-Linux to speed up .list files loadingStefan Fritsch1-0/+22
When FIEMAP is not available try to use posix_fadvise() to request the preloading of the .list files. A search with dpkg-query went from 28 to 17 seconds, giving around 40% improvement. Closes: #557560 Signed-off-by: Guillem Jover <guillem@debian.org>
2010-03-05dpkg: Use FIEMAP to sort .list files before scanningMorten Hustveit1-4/+88
When running dpkg from a cold cache on a system where <admindir>/info/ lies on a hard disk, a lot of time is spent waiting for seeks between (typically) thousands of files. This patch changes the behavior of ensure_allinstfiles_available(), so that it accesses the packages in the order of their .list files' physical locations on the hard disk, greatly reducing drive head movements. The performance improvement is around 70% on my system: reinstalling a simple package takes 8 seconds instead of 27 seconds. The caches were dropped before each run, and 10 runs were done with consistent results. The performance is identical to the previous patch using FIBMAP, althought this one has the advantage of not needing root privileges. Signed-off-by: Guillem Jover <guillem@debian.org>
2010-02-19dpkg: Make pkg_files_add_file() staticGuillem Jover1-1/+1
2009-12-22Move color member from struct pkginfo to struct perpackagestateGuillem Jover1-0/+1
The only user of this field is in the dependency cycle detection, only found under src/. So move it there where it belongs.
2009-11-08Unify text in license headersGuillem Jover1-5/+5
Add a missing “of the License” after “version 2”. Move “but” and “GNU” at the end of line to the next line. This matches more closely the paragraph found in the license text for the GPL version 2.
2009-11-08Replace FSF address by pointing to the gnu.org URLGuillem Jover1-3/+2
Use the <http://www.gnu.org/licenses/> URL, instead of in most cases the outdated FSF address, which is way more stable, as the latter has changed several times in the past.
2009-10-26Sort order of header includesGuillem Jover1-8/+8
Place first <config.h> and <compat.h>, then all <sys/*.h> sorted by complexity, followed by the rest of the system headers, then <dpkg/*.h> and finally the local "*.h" ones. Move <dpkg/i18n.h> inclusion into libdpkg inclusion block, as the <gettext.h> compatibility header already takes care of including <locale.h> before <libintl.h> on environments were its probamatic. Removed duplicated inclusions.
2009-10-16dpkg: Remove unused variable current in pkg_files_add_file()Guillem Jover1-1/+1
Introduced on commit 4985c686c30b2d0682aab0885d32c36007a7998d by me while manually merging the patch that didn't apply cleanly on master. Reported-by: Sean Finney <seanius@debian.org>
2009-10-14dpkg: Refactor file addition into package files to a new functionDavid Benjamin1-27/+50
Added private function pkg_files_add_file for inserting a file to a package's entries. The function takes a file_tail to avoid an O(n^2) loop when adding to the end of the list. (This is what the original code does, so I have mirrored its behavior.) Signed-off-by: David Benjamin <davidben@mit.edu> Signed-off-by: Guillem Jover <guillem@debian.org>