summaryrefslogtreecommitdiff
path: root/src/ostree/ot-builtin-fsck.c
Commit message (Collapse)AuthorAgeFilesLines
* tree-wide: Run clang-formatColin Walters2023-05-021-102/+87
| | | | | This is a one-time tree wide reformatting to ensure consistency going forward.
* Strip trailing whitespace on all C filesDan Nicholson2023-02-071-1/+1
| | | | | | | | My editor started following the configuration in .editorconfig and is applying this rule to many files I'm editing. Let's just get this over with and strip everything. This was done like so: git ls-files | grep '\.[ch]$' | xargs sed -ri 's/\s+$//'
* fsck: Use `load_variant_if_exists`Colin Walters2022-06-121-15/+5
| | | | This cleans up error handling here.
* fsck: Move most commit processing into helper functionColin Walters2022-06-121-85/+98
| | | | | The inner loop was way too long; split out most of the heavy lifting around backrefs and tombstones into a helper function.
* fsck: De-indent loopColin Walters2022-06-121-90/+80
| | | | | Could have done this in the previous change, but wanted to avoid excessive diff noise.
* fsck: Don't load all object names into memoryColin Walters2022-06-091-10/+11
| | | | | | | We recently discovered `list_objects()` is inefficient with memory. The more efficient `list_objects_set()` API isn't yet public, but this fsck code actually just skips over non-commit objects, and we already have an API to list just those.
* Rename ostree-cmdprivate to drop out of introspectionColin Walters2022-06-021-1/+1
| | | | | | I was looking at our `.gir` and noticed we had the cmdprivate bits because the pattern for excluding headers is `-private.h`, which didn't match `cmdprivate.h`.
* glib: bump glib requirement to 2.66 and port to GUriDaniel Kolesa2022-03-121-1/+2
| | | | | This removes the old SoupURI copypasta from previous generation of libsoup and opens up a path for a simple libsoup3 port.
* Update FSF license notices to use URL instead of addressJoseph Marrero2021-12-071-3/+1
|
* fsck: Print a success messageColin Walters2021-09-301-0/+3
| | | | | | | | | There's a general Unix philosophy that "silence is golden". However, when one is explicitly invoking an error check it's nice to see explicit success. We already print various statistics, so ending with a happy note has no extra cost.
* tree-wide: [scan-build]: Add some asserts that pointers are non-NULLColin Walters2019-10-161-0/+1
| | | | | More "scan-build doesn't understand GError and our out-param conventions" AKA "these errors would be impossible with Rust's sum type Result<> approach".
* fsck: Fix version in docs, tweak error textColin Walters2019-09-091-1/+1
| | | | | | | I think this error message is clearer. Closes: #1918 Approved by: jlebon
* fsck: Implement a partial commit reason bitmaskJason Wessel2019-09-091-2/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | After the corruption has been fixed with "ostree fsck -a --delete", a second run of the "ostree fsck" command will print X partial commits not verified and exit with a zero. The zero exit code makes it hard to detect if a repair operation needs to be run. When ever fsck creates a partial commit it should add a reason for the partial commit to the state file found in state/<hash>.commitpartial. This will allow a future execution of the fsck to still return an error indicating that the repository is still in the damaged state, awaiting repair. Additional reason codes could be added in the future for why a partial commit exists. Text from: https://github.com/ostreedev/ostree/pull/1880 ==== cgwalters commented: To restate, the core issue is that it's valid to have partial commits for reasons other than fsck pruned bad objects, and libostree doesn't have a way to distinguish. Another option perhaps is to write e.g. fsck-partial into the statefile state/<hash>.commitpartial which would mean "partial, and expected to exist but was pruned by fsck" and fsck would continue to error out until the commit was re-pulled. Right now the partial stamp file is empty, so it'd be fully compatible to write a rationale into it. ==== Signed-off-by: Jason Wessel <jason.wessel@windriver.com> Closes: #1910 Approved by: cgwalters
* Make P2P API public (no longer experimental)Matthew Leeds2018-06-041-6/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently the API that allows P2P operations (e.g. pulling an ostree ref from a LAN or USB source) is hidden behind the configure flag --enable-experimental-api. This commit makes the API public and makes that flag essentially a no-op (leaving it in place in case we want to use it again in the future). The P2P API has been tested over the last several months and proven to work. This means that since we're no longer using the "experimental" feature flag, P2P builds of Flatpak will fail when using versions of OSTree from this commit onwards, until Flatpak is patched in the near future. If you want to build Flatpak < 0.11.8 with P2P enabled and link against OSTree 2018.6, you'll have to patch Flatpak. However, since Flatpak won't yet have a hard dependency on OSTree 2018.6, it needs a new way to determine if the P2P API in OSTree is available, so this commit adds a "p2p" feature flag. This way the feature set is more semantically correct than if we had continued to use the "experimental" feature flag. In addition to making the P2P API public, this commit makes the P2P unit tests run by default, removes the f27-experimental CI instance that's no longer needed, changes a few man pages to reflect the changes, and updates the bash completion script to accept the new commands and options. Closes: #1596 Approved by: cgwalters
* fsck: Add --all to print all corrupted objectAlexander Larsson2018-05-241-0/+7
| | | | | | | | | Stopping on the first error is nice if you just want to know if everything is ok, but if you want to figure out all that is wrong its nice to be able to continue and print all corruptions. Closes: #1591 Approved by: cgwalters
* fsck: Include the commits that contain the corruption in errorsAlexander Larsson2018-05-241-4/+18
| | | | | | | This makes it easier to figure out what the corruption affects. Closes: #1591 Approved by: cgwalters
* fsck: Only print "marking commit partial" onceColin Walters2018-04-231-2/+9
| | | | | | | | Let's only print if the commit isn't already partial; this addresses a spam of "marking commit partial" from fsck. Closes: #1548 Approved by: cgwalters
* fsck: Mark commits with missing or deleted object partialAlexander Larsson2018-04-141-7/+33
| | | | | | | | | | This means we can later use various operations to heal the repository because ostree does not assume all objects are there. This the begining of a fix for https://github.com/ostreedev/ostree/pull/345 Closes: #1533 Approved by: cgwalters
* Add SPDX-License-Identifier to source filesMarcus Folkesson2018-01-301-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | SPDX License List is a list of (common) open source licenses that can be referred to by a “short identifier”. It has several advantages compared to the common "license header texts" usually found in source files. Some of the advantages: * It is precise; there is no ambiguity due to variations in license header text * It is language neutral * It is easy to machine process * It is concise * It is simple and can be used without much cost in interpreted environments like java Script, etc. * An SPDX license identifier is immutable. * It provides simple guidance for developers who want to make sure the license for their code is respected See http://spdx.org for further reading. Signed-off-by: Marcus Folkesson <marcus.folkesson@gmail.com> Closes: #1439 Approved by: cgwalters
* Bump libglnx, use "n items" progress for fsckColin Walters2017-12-151-3/+4
| | | | | | | | | | Sooo much nicer. See also https://github.com/projectatomic/rpm-ostree/pull/1143 Update submodule: libglnx Closes: #1383 Approved by: jlebon
* bin/fsck: Make ref binding verification optionalColin Walters2017-12-141-3/+11
| | | | | | | | | | | | | Today the rpm-ostree test suite uses `refs --create` to save commits. I think this is a legitimate use case, and other people may be doing something similar. On the other hand, I think we should probably be changing the rpm-ostree test suite to create "unbound" commits. But let's be maximially compatible here since we hit a real-world case where something needed to change. Closes: #1379 Approved by: pwithnall
* ostree/fsck: Add --verify-back-refs optionPhilip Withnall2017-12-141-0/+73
| | | | | | | | | | | | | | | | | | This new option verifies that the refs listed in the ref-bindings for each commit all point to that commit (i.e. there aren’t multiple commits listing the same ref in their ref-bindings, and there aren’t any commits with non-empty ref-bindings which aren’t pointed at by a ref). This is useful when generating a new repository from scratch, but not useful when adding new commits to an existing repository (since the old commits will still, correctly, have ref-bindings from when the refs pointed at them). That’s why it has to be enabled explicitly using --verify-back-refs, rather than being on by default. Signed-off-by: Philip Withnall <withnall@endlessm.com> Closes: #1347 Approved by: cgwalters
* ostree/fsck: Handle refspecs from ostree_repo_list_refs()Philip Withnall2017-12-141-3/+10
| | | | | | | | | | | It seems ostree_repo_list_refs() can return refspecs as hash table keys, as well as just ref names. Handle that by parsing them before trying to use them as ref names. Signed-off-by: Philip Withnall <withnall@endlessm.com> Closes: #1347 Approved by: cgwalters
* ostree/fsck: Verify commit bindings for each refPhilip Withnall2017-12-141-0/+4
| | | | | | | | | | | | Since an OSTree client will refuse to pull from a remote which it has locally configured with a collection ID, if the commit on that remote has incorrect or missing bindings, we’d better verify them as part of fsck. Signed-off-by: Philip Withnall <withnall@endlessm.com> Closes: #1347 Approved by: cgwalters
* ostree/fsck: Factor out common commit checking codePhilip Withnall2017-12-141-20/+37
| | | | | | | | | This will make upcoming commits a bit cleaner. Signed-off-by: Philip Withnall <withnall@endlessm.com> Closes: #1347 Approved by: cgwalters
* Add public API for fsck, use it before loading metadataColin Walters2017-12-121-101/+25
| | | | | | | | | | | | | | | | | | | | | | A while ago I did `truncate -s 0 /path/to/repo/00/123.commit`, and expected a checksum error, but I actually got a validation error due to us loading the commit into a variant and trying to parse out the parent checksum, etc. I first started by changing the `load_and_fsck_one_object()` function to checksum before loading, but the problem is that we do a traverse of all objects first. Fixing this is going to require an `OSTREE_REPO_COMMIT_TRAVER_FLAG_FSCK` or something. In the meantime at least though, let's add a public API to fsck a single object which *does* checksum cleanly before parsing the object, and change the `fsck` command to use it. We then change the fsck binary to do this while iterating over the refs and finding the commit object. This way we'll at least get a checksum first for commit objects, even if not dirtree/dirmeta. Closes: #1364 Approved by: jlebon
* ostree: provide command description in a better placeRuixin Bao2017-10-201-1/+1
| | | | | | | | | | | | | | | | | | | This is similar idea as https://github.com/projectatomic/rpm-ostree/pull/916/commits/5c0bf889155573feec108501ce849ac09a0c9567, The duplicated description is now removed, and the description of the command is now displayed beneath the Usage. For example: ostree cat -h will output the following: "Usage: ostree cat [OPTION?] COMMIT PATH... Concatenate contents of files" Closes: #1267 Approved by: cgwalters
* ostree: move flags into command struct, pass down through builtinsRuixin Bao2017-10-201-2/+2
| | | | | | | | | | | | | | | | | | | | This is a similar approach as https://github.com/projectatomic/rpm-ostree/commit/12c34bb2491a07079c911ef26401fee939e5573c. One thing to note is when we parse the admin related functions, we still keep the old admin related flags, and added a new parameter to represent the command struct. This allows us to identify the caller of the function, making it easier for us to possibly deduplicate the subcommand handling in the future. A similar approach is done in rpm-ostree: https://github.com/projectatomic/rpm-ostree/commit/83aeb018c1012c7a43783c09b74ec71bc9c45826 This also makes it easier for us to change the prototype of the function. If we want to add something new in the future, we won't need to touch every prototype. Closes: #1267 Approved by: cgwalters
* tree-wide: Remove Emacs modelinesColin Walters2017-09-211-2/+1
| | | | | | | | | We added a `.dir-locals.el` in commit: 9a77017d87b74c5e2895cdd64ad098018929403f There's no need to have it per-file, with that people might think to add other editors, which is the wrong direction. Closes: #1206 Approved by: jlebon
* lib/repo-refs: Include remote refs when using collectionsMatthew Leeds2017-08-241-0/+1
| | | | | | | | | | | | | | | | | | | | | | When working with collections it can be useful to see remote refs rather than just local and mirrored ones. This commit changes the "ostree refs -c" output to include remote refs, and includes remote refs with collection IDs in summary file generation as well. The former behavior is consistent with how "ostree refs" works, and the latter behavior is useful in facilitating P2P updates even when mirrors haven't been configured. To accomplish this, OstreeRepoListRefsExtFlags was extended with an EXCLUDE_REMOTES flag. This was done rather than an INCLUDE_REMOTES flag so that existing calls to ostree_repo_list_refs_ext continue to have the same behavior. This flag was added to ostree_repo_list_collection_refs (which is an experimental API break). Also, add unit tests for the "refs -c" and summary file behavior, and update relevant tests. Closes: #1069 Approved by: cgwalters
* ostree: Add naggy comments to help keep options in syncMatthew Barnes2017-08-151-0/+5
| | | | | | | | | | /* ATTENTION: * Please remember to update the bash-completion script (bash/ostree) and * man page (man/ostree-$COMMANDNAME.xml) when changing the option list. */ Closes: #1080 Approved by: cgwalters
* tree-wide: Use g_autoptr(Ostree*)Colin Walters2017-08-031-1/+1
| | | | | | | | | | | Part of cleaning up our usage of libglnx; we want to use what's in GLib where we can. Had to change a few .c files to `#include ostree.h` early on to pick up autoptrs for the core types. Closes: #1040 Approved by: jlebon
* ostree/builtins: Add support for collection–refs to a few utilitiesPhilip Withnall2017-06-261-0/+22
| | | | | | | | | | | These utilities were not needed for the initial port to support OstreeCollectionRef, so have been delayed a bit and, in some cases, left as FIXME comments for follow up later. Signed-off-by: Philip Withnall <withnall@endlessm.com> Closes: #924 Approved by: cgwalters
* cmd/fsck: Port to new styleColin Walters2017-06-261-82/+44
| | | | | | | Happened to look at this code too, it's a straightforward port. Closes: #955 Approved by: jlebon
* fsck: Check for refs missing corresponding commitColin Walters2017-05-091-0/+22
| | | | | | | | | Just doing this one quickly since it was easy. Closes: https://github.com/ostreedev/ostree/issues/831 Closes: #841 Approved by: jlebon
* tree-wide: Switch to autoptr for GOptionContextColin Walters2016-12-081-3/+1
| | | | | | | | | | We were leaking in a few places that I noticed in an ASAN run. Also, this was one of the last non-autoptr cleanup sections we have in `out:` cleanup sections, making us a lot closer to a potential full-tree rewrite to `return FALSE`. Closes: #624 Approved by: jlebon
* tree-wide: Use g_hash_table_add() where applicableColin Walters2016-12-061-1/+1
| | | | | | | | Just noticed a few while reading some code, decided to do a quick cleanup. It's shorter and clearer. Closes: #614 Approved by: jlebon
* [ASAN] lib: Squash various leaks in library and commandlineColin Walters2016-11-211-1/+1
| | | | | | | | The pull one is the most likely to affect users. Otherwise mostly just cleaning up `-fsanitize=address`. Closes: #587 Approved by: jlebon
* fsck: create a tombstone when the parent is missingGiuseppe Scrivano2015-11-161-6/+26
| | | | | | | Change the previous logic that a tombstone commit was created when a partialcommit is found. Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
* prune: add --delete-commitGiuseppe Scrivano2015-11-161-12/+2
| | | | Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
* fsck: add argument --add-tombstonesGiuseppe Scrivano2015-11-031-2/+36
| | | | | | It is used to create tombstones for missing commits Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
* Use g_autoptr(GVariant) instead of gs_unref_variantMatthew Barnes2015-05-061-2/+2
|
* Use g_autoptr(GHashTable) instead of gs_unref_hashtableMatthew Barnes2015-05-061-3/+3
|
* Use glnx_unref_object instead of gs_unref_objectMatthew Barnes2015-05-061-1/+1
| | | | | For non-GIO object types, at least until autocleanup support for GObject based types becomes more widespread.
* Use g_autoptr() for GIO object typesMatthew Barnes2015-05-061-2/+2
| | | | | GLib 2.44 supplies all the necessary autocleanup macros for GIO types, and libglnx backports the relevant macros for ostree.
* Use g_autofree instead of gs_freeMatthew Barnes2015-05-061-3/+3
|
* Teach fsck about partial commitsColin Walters2015-05-061-1/+19
| | | | | | | | | | | | | | | | | | | An OSTree user noticed that `ostree fsck` would produce `missing object` errors in the case of interrupted pulls. It's possible to do e.g. `ostree pull --subpath=/usr/share/rpm ...`, which gets you just that portion of the commit. The use case for this was being able to see what changes would appear in an update before actually downloading all of it. (I think this would be better covered by static deltas, but those aren't final yet, and `--subpath` predates it) Further, `.commitpartial` is used as a successor to the `transaction` symlink for more precise knowledge in the case where a pull was interrupted that we needed to resume scanning. So it makes sense for `ostree fsck` to be aware of it.
* fsck: Fix object count outputDan Nicholson2015-03-181-1/+1
| | | | | | | | The object count comes from g_hash_table_size(), so it's not a 0 based index. In order to maintain the mod calculations correctly, just print out index + 1. https://bugzilla.gnome.org/show_bug.cgi?id=746360
* Refactor command-line parsingMatthew Barnes2014-11-241-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Refactor command-line parsing to better utilize GOptionContext. This eliminates most of the manual parsing and global options are now shown in the help output. Here's a sample: $ ostree admin --help Usage: ostree admin [OPTION...] --print-current-dir|COMMAND Builtin "admin" Commands: cleanup config-diff deploy init-fs instutil os-init status switch undeploy upgrade Help Options: -h, --help Show help options Application Options: --sysroot=PATH Create a new OSTree sysroot at PATH -v, --verbose Print debug information during command processing --version Print version information and exit https://bugzilla.gnome.org/show_bug.cgi?id=740295
* fsck: report the correct error when a present file cannot be loadedGiuseppe Scrivano2014-10-221-0/+1
| | | | Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>