A distro packager has requested writable mounts by default, and is
willing to take responsibility for any potential harm to their users:
https://github.com/linux-apfs/linux-apfs-rw/issues/81
Add a build flag to enable this, but leave it undocumented to avoid
confusing anyone.
Signed-off-by: Ernesto A. Fernández <ernesto@corellium.com>
The dkms build fails for the latest release:
https://github.com/linux-apfs/linux-apfs-rw/pull/60
The problem is that dkms does not call my Makefile at all, so the
version header is never generated. Dkms does have a PRE_BUILD hook
though, so use that to call a script that takes care of this.
From now on, I must always remember to run a dkms build before a new
release.
Signed-off-by: Ernesto A. Fernández <ernesto@corellium.com>
The filesystem superblock has an apfs_modified_by field to report which
implementation is responsible for the latest changes. This could be
useful to track down bugs eventually, but it will need to have more
information. Right now we only report my name and the name of the
module; change it to also report the exact commit id, or the tag if
there is one. There is a strict size limit here, so shorten my name to
"eafer", which is what I use on github, so it will make the driver easy
to track down.
Also move the APFS_MODULE_ID_STRING macro definition to super.c. We'll
now need to recompile that file with every build, but if we left it
inside apfs.h then we would have to recompile everything all the time.
Signed-off-by: Ernesto A. Fernández <ernesto@corellium.com>
Using the official LZFSE library (which I already dumped here in the
previous patch), add support for LZFSE compression. For testing I used
images created with the following tool:
https://github.com/Siguza/fscmp
I've tested both resource and attribute compression. For resource
compression, I also tested a file that had a single uncompressed block.
That block had 0xff in the first byte, but I don't know if that's a
general rule so it's better to just check for the first byte of the
LZFSE magic.
Signed-off-by: Ernesto A. Fernández <ernesto@corellium.com>
Use Apple's official LZFSE library[0] to add support for LZVN
compression. Their code for LZFSE compression proper is also dumped with
this patch, but it's not actually rigged up for the driver because I
have no image to test it on.
For the record, the build on Linux 5.15 produces the following objtool
warning:
lzfse/lzvn_decode_base.o: warning: objtool: lzvn_decode()+0x1b0: sibling call from callable instruction with modified stack frame
I'm not sure what this means, but there seems to be no sibling call in
that position, just a regular goto:
1b0: e9 00 00 00 00 jmp 1b5 <lzvn_decode+0x1b5>
I'll ignore it for now, but I guess I should report it if it's a false
positive.
[0]: https://github.com/lzfse/lzfse
Signed-off-by: Ernesto A. Fernández <ernesto@corellium.com>
Implement an ioctl that creates a snapshot for the current transaction.
A matching userland tool has already been added to apfsprogs.
Note that, at this point, snapshots won't be handled correctly on later
writes at all. Being able to actually create snapshots for testing is
only the first step in that direction.
Signed-off-by: Ernesto A. Fernández <ernesto@corellium.com>
This reduces code duplication a tiny bit and makes it easier to change
the value of PWD, for example to the value of the $PWD environment
variable, instead of calling `shell pwd`, should the need arise in the
future.
Allow building in a different directory.
This is useful on NixOS, where all software is stored under /nix.
As a nice side-effect, this change also reduces code duplication a little.
I copied the Makefile from linux-apfs-ott verbatim, so it's not aware of
the new source files involved in write support. Fix this.
Signed-off-by: Ernesto A. Fernández <ernesto@corellium.com>
Start a new out-of-tree repository, like linux-apfs-oot but with write
support.
To get the module to build independently, rewrite the Makefile and
add a definition for the APFS_SUPER_MAGIC macro. Since the intention is
to support a range of kernel versions, use preprocessor checks to handle
kernels without statx, without iversion, and without SB_RDONLY.
Provide a README file based on the original documentation, but with
additional build and mount instructions. Add a LICENSE file as well.
Signed-off-by: Ernesto A. Fernández <ernesto@corellium.com>