Add support for BSDs (tmpfs only)
I'm well aware that profile-sync-daemon was developed specifically for Linux and that's obviously the only way to use the Overlay Filesystem support. That said, the basic tmpfs support can be made to support BSDs with little effort.
I have been working on an OpenBSD port (https://github.com/morgant/my-openbsd-ports/blob/main/www/profile-sync-daemon/patches/patch-common_profile-sync-daemon_in) and the biggest issues I ran into are:
mvdoesn't support the--no-target-directoryoption in OpenBSD. All the uses ofmv --no-target-directoryalready verify that the source is a directory anyway, so the--no-target-directorycan be omitted under OpenBSD because the "source operand is skipped with an error message when the respective destination path is a non-empty directory" (per OpenBSD's mv(1)).cpdoesn't support the--reflink=autooption in OpenBSD. Use ofcp --reflink=autounder Linux just forces it to perform a standard copy anyway (see Linux's cp(1)), so it can be omitted under OpenBSD.dudoesn't have a--max-depthoption in OpenBSD, butdu --max-depth=0can be substituted withdu -d 0under OpenBSD.stat -c %acan be replaced withstat -f %OLpunder OpenBSD, so pretty minor.unlinkdoesn't exist under OpenBSD, so can just usermfor better compatibility on all platforms.pgrepdoesn't have a-c(count) option under OpenBSD, so can just usepgrep -f "psd-suspend-sync" | wc -l | tr -d ' 'for better compatibility on all platforms.- OpenBSD's file system doesn't support extended attributes, so the
-Xoption needs to be stripped fromrsynccalls. That can easily be left as an patch in the OpenBSD port as other BSDs (esp. FreeBSD) file systems do support extended attributes, but I figured I'd mention it anyway.
Some of these are Linux-specific options that are unnecessary under most BSDs (e.g. mv & cp issues), or GNU-style options that differ on BSDs (e.g. du & stat), both of which can probably just be handled as Linux vs BSD cases or be left as patches in the OS-specific ports (especially rsync -X). The others are pretty minor tweaks to just use more portable calls (e.g. unlink & pgrep).
I'll extract a patch from my WIP OpenBSD port and submit a PR in the hopes that others can test under other BSDs (or I can when I have more time). If we can merge in something that handles all BSDs with little extra logic, I'd love that, but if I have to keep maintaining OpenBSD-specific patches in my port, that's totally fine.
Oh, and we don't need to check for kmod on non-Linux OSes since they won't be using OFS.
I'll be trying to put together PRs for this and Issue #343 sometime this week.