]> Kevux Git Server - kevux-tools/commit
Bugfix: Handle deleting on access denied errors.
authorKevin Day <Kevin@kevux.org>
Sun, 15 Jun 2025 16:02:14 +0000 (11:02 -0500)
committerKevin Day <Kevin@kevux.org>
Sun, 15 Jun 2025 23:25:01 +0000 (18:25 -0500)
commit7bc20fea47d1ba6691e8142f3e2307e34802cdfd
tree3e2c6efa740fa4dfe1e9d8467f2dda8ba5d13299
parentedcfdda80c9141de4c65f15f4c7871806bbfa007
Bugfix: Handle deleting on access denied errors.

Detect the read, write, and execute permissions.
Print the unable to read, write, and execute status for each path when in simulate mode.

Add additional strings as needed.
Address an alphabet ordering mistake in the strings.

The preprocess now happens outside of the process function.
This better allows for calling the preprocess in the "before" state of the recursion and the process happens during the "action" state of the recursion.
This also allows for completely avoiding a second preprocess call for depth 0 recursive paths.

The operate flag is now handled on a per depth basis.
This requires a new array of flags for each depth.

The `normal` part of `kt_remove_flag_recurse_*_d` now use the work `active` instead of `normal`.
This makes reading and understanding the code easier given the more direct meaning of the word.

With the preprocess logic now outside of the process logic, the `top` and `parent` recurse states from `kt_remove_flag_recurse_*_d` no longer need to be part of the preprocess.
They are not used anywhere else so remove them.

Make the code simpler by just using an `uint64_t` rather than an `uint32_t` for the operate flag.
This also avoids the need for casting when adding it to the recurse code value.

Update the `remove-config.h`.
I noticed that the sorting is working differently from system to system.
I had to manually adjust/correct some of the ordering and I may have missed some things.
I will need to figure out the cause of the inconsistency at some point.

Fix the linking to make sure the fl_path library is included.
Also make sure the static library link paths are used in the tests as well.

A new flag `return_fail` main flag is added to designate that the final state should be a failure.
This is done because a single file remove failure on file does not exist should not prevent other failures.
(The classic `rm` command will remove all files that it can and return an error for any error.)

The unit tests are updated.
The unit tests are updated to respect the 32-bit to 64-bit type change.
The unit tests now handles the `f_file_access()` calls.
The unit tests now handles the updated directory recursion and pre-process flow.
The `recurse.depth` must now be mocked.

I would further note that at some point in time in the future, I need to not mock `fl_directory_do()` and instead call that directly and mocks its calls.
This is a complex situation that would require mocking the directory list and several other things.
This is too much work to do at this time.

The updated unit tests exposed a concern regarding immediately exiting the pre-process after an "is file type" check.
Move this down to the end of the pre-process to allow for other checks to happen.
I have some concerns with doing this for additional behavior and I will need to review and test other programs.
(That is, the `rmdir` vs `rm` vs `unlink` behavior are directly tied to "is file type" checks.)
I'd rather not make this commit any larger than it already is and so I am leaving the further investigation and changes to another time.
42 files changed:
data/build/remove/settings-mocks.remove
data/build/remove/settings-tests.remove
data/build/remove/settings.remove
data/build/remove/settings.rm
data/build/remove/settings.rmdir
data/build/remove/settings.unlink
data/build/stand_alone/configs/remove-config.h
sources/c/program/kevux/tools/remove/main/common.h
sources/c/program/kevux/tools/remove/main/common/define.h
sources/c/program/kevux/tools/remove/main/common/print.c
sources/c/program/kevux/tools/remove/main/common/print.h
sources/c/program/kevux/tools/remove/main/common/string.c
sources/c/program/kevux/tools/remove/main/common/string.h
sources/c/program/kevux/tools/remove/main/common/type.c
sources/c/program/kevux/tools/remove/main/common/type.h
sources/c/program/kevux/tools/remove/main/operate.c
sources/c/program/kevux/tools/remove/main/operate.h
sources/c/program/kevux/tools/remove/main/preprocess.c
sources/c/program/kevux/tools/remove/main/preprocess.h
sources/c/program/kevux/tools/remove/main/print/debug.c
sources/c/program/kevux/tools/remove/main/print/debug.h
sources/c/program/kevux/tools/remove/main/print/simulate.c
sources/c/program/kevux/tools/remove/main/print/simulate.h
sources/c/program/kevux/tools/remove/main/print/verbose.c
sources/c/program/kevux/tools/remove/main/print/verbose.h
sources/c/program/kevux/tools/remove/main/remove.c
tests/unit/remove/c/mock-remove.c
tests/unit/remove/c/mock-remove.h
tests/unit/remove/c/test-remove-date_accessed.c
tests/unit/remove/c/test-remove-date_changed.c
tests/unit/remove/c/test-remove-date_updated.c
tests/unit/remove/c/test-remove-directory_no_args.c
tests/unit/remove/c/test-remove-directory_recurse_simple.c
tests/unit/remove/c/test-remove-directory_tree_simple.c
tests/unit/remove/c/test-remove-epochtime.c
tests/unit/remove/c/test-remove-file_mode.c
tests/unit/remove/c/test-remove-file_type.c
tests/unit/remove/c/test-remove-group.c
tests/unit/remove/c/test-remove-regular_no_args.c
tests/unit/remove/c/test-remove-time.c
tests/unit/remove/c/test-remove-unix.c
tests/unit/remove/c/test-remove-user.c