summaryrefslogtreecommitdiffstats
path: root/lib/libalpm/diskspace.c
AgeCommit message (Collapse)AuthorFilesLines
2014-08-04replace strdup with STRDUPAndrew Gregory1-3/+3
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
2014-08-03move _alpm_lstat into util-commonAndrew Gregory1-1/+1
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
2014-01-28Remove ts and sw from vim modeline when noet is setFlorian Pritz1-1/+1
Forcing vim users to view files with a tabstop of 2 seems really unnecessary when noet is set. I find it much easier to read code with ts=4 and I dislike having to override the modeline by hand. Command run: find . -type f -exec sed -i '/vim.* noet/s# ts=2 sw=2##' {} + Signed-off-by: Florian Pritz <bluewind@xinu.at> Signed-off-by: Allan McRae <allan@archlinux.org>
2014-01-10Fix compile warnings on systems without getmntentDan McGee1-0/+3
Signed-off-by: Dan McGee <dan@archlinux.org> Signed-off-by: Allan McRae <allan@archlinux.org>
2014-01-06Update copyright years for 2014Allan McRae1-1/+1
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-11-15Fix whitespace and other formatting issuesJason St. John1-1/+1
This commit: -- replaces space-based indents with tabs per the coding standards -- removes extraneous whitespace (e.g. extra spaces between function args) -- adds missing braces for a one-line if statement Signed-off-by: Jason St. John <jstjohn@purdue.edu>
2013-01-03Update copyright year for 2013Allan McRae1-1/+1
Signed-off-by: Allan McRae <allan@archlinux.org>
2012-07-10diskspace: log errors when opening the mount table failsDave Reisner1-0/+6
Signed-off-by: Dave Reisner <dreisner@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
2012-06-26diskspace: only load filesystem info on demandDave Reisner1-13/+40
Only load filesystem details for the mount points that we're actually going to write to. This reduces our syscall count considerably. In the case of installation, we would actually stat every mountpoint twice (an extra round for download diskspace) which means (on my system) a total of 60 syscalls to write to 3 partitions when installing the kernel package. This change reduces the 60 syscalls down to the expected 3. A slight debug output change is added here to discern between a mountpoint added to our linked list versus when we actually load the fs info. Signed-off-by: Dave Reisner <dreisner@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
2012-06-26diskspace: dedupe code for loading FS usageDave Reisner1-25/+27
add mount_point_load_fsinfo() for platforms using getmntent(). Dan: move the #ifdef slightly so we don't have unused functions on certain platforms (e.g., OS X). Signed-off-by: Dave Reisner <dreisner@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
2012-06-26check proper variable for NULLDave Reisner1-1/+1
Signed-off-by: Dave Reisner <dreisner@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
2012-06-26diskspace: canonicalize path to download dirDave Reisner1-0/+8
With lazy loading in place, it's now quite obvious that we aren't necessarily checking the right mountpoint for necessary download space. Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2012-04-09Fix a signed overflow error on i686 with GCC 4.7.0Dan McGee1-4/+6
Not sure why this one wasn't showing up on x86_64, but this fixes the compile on i686. diskspace.c: In function 'calculate_removed_size': diskspace.c:247:4: error: assuming signed overflow does not occur when negating a division [-Werror=strict-overflow] cc1: all warnings being treated as errors Signed-off-by: Dan McGee <dan@archlinux.org>
2012-02-21Merge branch 'maint'Dan McGee1-1/+13
Conflicts: contrib/pacsysclean.in src/pacman/conf.h
2012-02-20diskspace: ensure we match only full path componentsDan McGee1-1/+13
If one had a mountpoint at '/e' (don't ask), a file being installed to '/etc' would map to it incorrectly. Ensure we do more than just prefix matching on paths by doing some more sanity checks once the simple strncmp() call succeeds. Signed-off-by: Dan McGee <dan@archlinux.org>
2012-02-06Remove last explicit include of config.hDan McGee1-2/+0
Signed-off-by: Dan McGee <dan@archlinux.org>
2012-01-23Merge branch 'maint'Dan McGee1-5/+51
Conflicts: lib/libalpm/diskspace.c src/pacman/util.h
2012-01-23Fix sys/mnttab.h header includeDan McGee1-2/+2
Signed-off-by: Dan McGee <dan@archlinux.org>
2012-01-19Add diskspace checking support for Solaris/IllumosDan McGee1-5/+49
Was able to get my hands on one of these boxes today, so add yet another new way of doing this. I'm glad these calls are so standardized. This was compile tested on Linux and Illumos and seems to still be working in both places. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-12-22include config.h via MakefilesDave Reisner1-2/+0
Ensures that config.h is always ordered correctly (first) in the includes. Also means that new source files get this for free without having to remember to add it. We opt for -imacros over -include as its more portable, and the added constraint by -imacros doesn't bother us for config.h. This also touches the HACKING file to remove the explicit mention of config.h as part of the includes. Signed-off-by: Dave Reisner <dreisner@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
2011-10-17diskspace: create static function mount_point_list_freeDave Reisner1-11/+14
This logic is reused in both diskspace and downloadspace check functions, so pull it out into its own static method. Signed-off-by: Dave Reisner <dreisner@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
2011-10-17diskspace: add _alpm_check_downloadspace()Dave Reisner1-0/+49
This function determines if the given cachedir has at least the given amount of free space on it. This will be later used in the sync code to preemptively halt downloads. Signed-off-by: Dave Reisner <dreisner@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
2011-10-12diskspace: extract check_mountpoint() functionDan McGee1-17/+23
This will be useful when extending disk space checks to free space checking before we download package files. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-09-08diskspace: fix memory leak on root mount not foundDave Reisner1-1/+3
Signed-off-by: Dave Reisner <dreisner@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
2011-09-08Use more correct integer types in diskspace checksDan McGee1-14/+15
This adjusts type usage to match POSIX provided types from <sys/types.h> rather than assuming everything will fit in a long or unsigned long. Use fsblkcnt_t (unsigned) and blkcnt_t (signed) as appropriate. These are affected the same way off_t is on 32 bit platforms, where the types are extende to 64 bits if large file support is enabled. Because most numbers here are block counts, this isn't near as pressing as using a 32-bit variable for file sizes where anything over 2GiB can burn you; we likely can support files at least 512 but mainly 4096 times larger. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-09-03Former transaction callback rename refactorDan McGee1-3/+3
Put all the callback stuff in alpm.h in one spot, and make the following renames for clarity with the new structure: ALPM_TRANS_EVT_* --> ALPM_EVENT_* ALPM_TRANS_CONV_* --> ALPM_QUESTION_* ALPM_TRANS_PROGRESS_* --> ALPM_PROGRESS_* alpm_option_get_convcb() --> alpm_option_get_questioncb() alpm_option_set_convcb() --> alpm_option_set_questioncb() Signed-off-by: Dan McGee <dan@archlinux.org>
2011-09-03Move all callbacks up to the handle levelDan McGee1-3/+3
This was just disgusting before, unnecessary to limit these to only usage in a transaction. Still a lot of more room for cleanup but we'll start by attaching them to the handle rather than the transaction we may or may not even want to use these callbacks. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-08-20Remove alpm_option_get_* usage from backendDan McGee1-1/+1
These are all available directly on the handle without indirection. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-08-18Remove usages of alpm_list_next() in backendDan McGee1-3/+3
Another function call that can be replaced by a single pointer dereference. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-08-15libalpm: fix a remaining old syntax of RET_ERR() macroRémy Oudompheng1-1/+1
It would prevent compilation of pacman on FreeBSD, and possibly other systems. Signed-off-by: Rémy Oudompheng <remy@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
2011-07-21Convert package filelists to an array instead of linked listDan McGee1-8/+16
This accomplishes quite a few things with one rather invasive change. 1. Iteration is much more performant, due to a reduction in pointer chasing and linear item access. 2. Data structures are smaller- we no longer have the overhead of the linked list as the file struts are now laid out consecutively in memory. 3. Memory allocation has been massively reworked. Before, we would allocate three different pieces of memory per file item- the list struct, the file struct, and the copied filename. What this resulted in was massive fragmentation of memory when loading filelists since the memory allocator had to leave holes all over the place. The new situation here now removes the need for any list item allocation; allocates the file structs in contiguous memory (and reallocs as necessary), leaving only the strings as individually allocated. Tests using valgrind (massif) show some pretty significant memory reductions on the worst case `pacman -Ql > /dev/null` (366387 files on my machine): Before: Peak heap: 54,416,024 B Useful heap: 36,840,692 B Extra heap: 17,575,332 B After: Peak heap: 38,004,352 B Useful heap: 28,101,347 B Extra heap: 9,903,005 B Several small helper methods have been introduced, including a list to array conversion helper as well as a filelist merge sort that works directly on arrays. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-07-03Merge remote-tracking branch 'allan/ALPM'Dan McGee1-16/+16
Conflicts: lib/libalpm/be_local.c lib/libalpm/be_package.c lib/libalpm/conflict.c lib/libalpm/diskspace.c lib/libalpm/dload.c lib/libalpm/remove.c
2011-07-03diskspace: remove all libarchive usageDan McGee1-41/+7
Now that the filelists capture mode and size information, we can read the data from there and prevent having to loop through and uncompress every archive to check required diskspace usage. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-07-03Move alpm filelists to a struct objectDan McGee1-3/+4
This allows us to capture size and mode data when building filelists from package files. Future patches will take advantage of this newly available information, and frontends can use it as well. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-07-01Prefix _alpm_errno_t members with ALPMAllan McRae1-6/+6
Signed-off-by: Allan McRae <allan@archlinux.org>
2011-07-01Prefix alpm_transprog_t members with ALPMAllan McRae1-3/+3
Signed-off-by: Allan McRae <allan@archlinux.org>
2011-07-01Prefix alpm_loglevel_t members with ALPMAllan McRae1-11/+11
Signed-off-by: Allan McRae <allan@archlinux.org>
2011-06-28Rename pmtrans_t to alpm_trans_tAllan McRae1-1/+1
Signed-off-by: Allan McRae <allan@archlinux.org>
2011-06-28Rename pmpkg_t to alpm_pkg_tAllan McRae1-4/+4
Signed-off-by: Allan McRae <allan@archlinux.org>
2011-06-28Rename pmhandle_t to alpm_handle_tAllan McRae1-4/+4
Signed-off-by: Allan McRae <allan@archlinux.org>
2011-06-27Fix several -Wshadow warningsDan McGee1-4/+4
Only one of these looked like a real red flag, in find_requiredby(), but it doesn't hurt to fix several of them up anyway. Unfortunately, we can't turn this on universally due to things like the sync(), remove(), etc. builtins which we often use as variable names. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-14Switch all logging to use handle directlyDan McGee1-11/+11
This is the last user of our global handle object. Once again the diff is large but the functional changes are not. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-14Move pm_errno onto the handleDan McGee1-7/+7
This involves some serious changes and a very messy diff, unfortunately. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-09Require handle argument to all alpm_option_(get|set)_*() methodsDan McGee1-1/+1
This requires a lot of line changes, but not many functional changes as more often than not our handle variable is already available in some fashion. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-03Remove global handle from diskspace.cDan McGee1-12/+10
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-03Push down extern handle variable to files that need itDan McGee1-0/+3
This will make the patching process less invasive as we start to remove this variable from all source files. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-04-21syntax: if/while statements should have no trailing spaceDan McGee1-3/+3
This is the standard, and we have had a few of these introduced lately that should not be here. Done with: find -name '*.c' | xargs sed -i -e 's#if (#if(#g' find -name '*.c' | xargs sed -i -e 's#while (#while(#g' Signed-off-by: Dan McGee <dan@archlinux.org>
2011-04-16Merge branch 'maint'Dan McGee1-2/+2
Conflicts: lib/libalpm/alpm.h lib/libalpm/trans.c Signed-off-by: Dan McGee <dan@archlinux.org>
2011-04-06diskspace: add the actually used statfs type in ifdefsRémy Oudompheng1-2/+2
Some systems, like FreeBSD might define both statfs and statvfs: however if statvfs exists whereas getmntinfo() uses a statfs struct, the current ifdefs would select the wrong line of code. Signed-off-by: Rémy Oudompheng <remy@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
2011-03-21Style change: return(x) --> return xDan McGee1-11/+11
This was discussed and more or less agreed upon on the mailing list. A huge checkin, but if we just do it and let people adjust the pain will end soon enough. Rebasing should be relatively straighforward for anyone that sees conflicts; just be sure you use the new return style if possible. The following semantic patch was used to do the change, along with some hand-massaging in order to preserve parenthesis where appropriate: The semantic match that finds this problem is as follows, although some hand-massaging was done in order to keep parenthesis where appropriate: (http://coccinelle.lip6.fr/) // <smpl> @@ expression a; @@ - return(a); + return a; // </smpl> A macros_file was also provided with the following content: Additional steps taken, mainly for ASSERT() macros: $ sed -i -e 's#return(NULL)#return NULL#' lib/libalpm/*.c $ sed -i -e 's#return(-1)#return -1#' lib/libalpm/*.c Signed-off-by: Dan McGee <dan@archlinux.org>