Busybox find misbehaves

REPRODUCIBILITY: 100%
OS VERSION: 4.6.x I forgot to check the busybox version before updating to 5.0.x, but I’m guessing it was 1.36.1 just as it is now
HARDWARE: 10 II (but this is not hardware-specific)
UI LANGUAGE: en_GB.utf8
REGRESSION: no

DESCRIPTION:

The busybox find applet has a bug that can result in data loss.

PRECONDITIONS:

Use find on the command line

STEPS TO REPRODUCE:

  1. find -name '*something*' => finds n results under the current directory
  2. find -name '*something*' -delete => deletes results that are elsewhere in the filesystem

EXPECTED RESULT:

Only files that were previously found with the same regex will be deleted.

ACTUAL RESULT:

Files that were not in the previous search result also get deleted

MODIFICATIONS:

ADDITIONAL INFORMATION:

Does it happen if you specify the search start directory?

1 Like

… because the path(s) (for the search base directory(ies)) is not an optional argument, see pubs.opengroup.org/onlinepubs/9699919799/utilities/find.html.

from busybox usage: Defaults: PATH is current directory
so, if find behaves differently from find . that is also a bug

PATH is optional on both GNU find and (more relevantly) busybox find

BusyBox v1.36.1 (2024-12-03 00:00:00 UTC) multi-call binary.

Usage: find [-HL] [PATH]... [OPTIONS] [ACTIONS]
find (GNU findutils) 4.10.0

Usage: find [-H] [-L] [-P] [-Olevel] [-D debugopts] [path...] [expression]

(edit: i’m not saying youre wrong, of course, in that POSIX find says its required…but as far as i know, only macosx peasants have to actually live with such a sadly impoverished shell)

that does sound like a bug to me, though probably not a sailfish bug. can you reproduce with busybox find on other systems?
or give a short script that reproduces?

I am wary trying to reproduce it on my phone.

I tried on my desktop (installed busybox, created a separate user, used busybox find) but could not recreate.

Over the years I learned to rely on using find this way:

  1. find what you want to delete first
  2. use the exact same command line with an added -delete

That not working as expected is a problem.

Of course I cannot complete rule out PEBKAC but the data loss was very real…

I will continue trying to reproduce this without the danger of bricking my phone.

sorry for your loss. you may wish to consider doing something like find -type f -exec echo rm '{}' \; | tee delete-script.sh for scary jobs

also, allow me to offer the worst advice to hear at this time; consider doing full, regular, fully-automated backups

Any advice on full backups of a sailfish device?

The build in Backup isn’t cutting it for me as I couldn’t restore them by just moving the newest one from the last device into the folder for my new device. Restore couldn’t find only the one I made to get the folder established on my share.

I also rummaged in the content to see, what I could restore manually and I didn’t find anything for android apps in there, which was quite the disappointment.

yea, i have advice, but it is somewhat idiosyncratic. my advice is to rsync your entire home dir overnight.

for my backup, i start with a full home rsync, which makes backup simple but restoring a nightmare.
i then take individual things i care about, like commhistory and ~/Pictures, etc, and back them up using more nuanced custom scripts, and then add --excludes to my home backup.

this is the repo where i keep my personal backup scripts. they are not likely to work in any given environment and are for my own weird use, but feel free to take a look and see if you can get them to work for you at your own risk :slight_smile:
https://github.com/teleshoes/sx-config/blob/master/backup-phone

1 Like

but as far as i know, only macosx peasants have to actually live with such a sadly impoverished shell

BSD troglodytes similary have to endure the stone-age agony of their find program, forever chiseling away at their sanity with tools from the digital Paleolithic.

1 Like

This is a bit offtopic…
You can use the search tool which will show you many results.

1 Like