Commit Graph

15 Commits

Author SHA1 Message Date
Aditya Garg 0459ba0998 Rename $(CONFIG) to $(APFS_CONFIG) (#116) 2026-03-12 13:08:09 -03:00
Ernesto A. Fernández d9e50e76cf Allow choice of mountable writes by default
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>
2024-11-08 17:20:47 -03:00
Ernesto A. Fernández 5e133a2ca5 Fix version header generation for dkms
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>
2024-01-17 22:36:05 -03:00
Ernesto A. Fernández e0b1eeb29d Include release info in apfs_modified_by field
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>
2023-11-03 22:10:03 -03:00
Ernesto A. Fernández dc829884cb Support reads of LZFSE-compressed files
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>
2023-01-25 21:16:54 -03:00
Ernesto A. Fernández 588475e5f7 Support reads of LZVN-compressed files
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>
2023-01-24 18:50:21 -03:00
Ernesto A. Fernández 66526b4674 Support reads of LZBITMAP-compressed files
Use my recent LZBITMAP library to implement reads of these compressed
files.

Signed-off-by: Ernesto A. Fernández <ernesto@corellium.com>
2023-01-18 19:38:33 -03:00
Ernesto A. Fernández 97863ab914 Add support for taking snapshots
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>
2023-01-06 19:38:54 -03:00
Ernesto A. Fernández dc1ed2cfe7 Rename SPDX license identifier
It seems that the license identifier currently in use (GPL-2.0) has been
deprecated:

  https://spdx.org/licenses/GPL-2.0.html

I don't know how important this is in practice, but I've received some
complaints about it:

  https://github.com/linux-apfs/linux-apfs-rw/issues/18

So, just run

  sed -i 's/2\.0/2.0-only/' *.{c,h}
  sed -i 's/2\.0/2.0-only/' Makefile

and change it to GPL-2.0-only.

Signed-off-by: Ernesto A. Fernández <ernesto@corellium.com>
2021-11-16 18:41:54 -03:00
Luflosi 93c53f6b83 Add install target to Makefile 2021-06-22 19:42:14 -03:00
Luflosi 278c42350c Use variable in Makefile for PWD instead of calling "shell pwd" directly
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.
2021-06-18 23:35:13 -03:00
Luflosi c138e7a34b Allow changing KERNEL_DIR
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.
2021-06-14 19:50:53 -03:00
Stan Skowronek 16c9c4f9b1 Support read of zlib-compressed files
[ernesto: silenced sparse, used bool type, added commit title]

Signed-off-by: Ernesto A. Fernández <ernesto@corellium.com>
2021-04-07 17:45:52 -03:00
Ernesto A. Fernández e665172550 Fix Makefile for the version with write support
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>
2021-03-31 17:52:27 -03:00
Ernesto A. Fernández 45f56acb46 Set up a standalone repository for the APFS module
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>
2021-03-31 17:16:24 -03:00