Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
vivlim committed Mar 16, 2024
0 parents commit b286c29
Show file tree
Hide file tree
Showing 5 changed files with 118 additions and 0 deletions.
13 changes: 13 additions & 0 deletions encrypted-segfault-fix.patch
@@ -0,0 +1,13 @@
*** ext4magic-fix-segfault-extent-free.patch
--- a/src/block.c
+++ b/src/block.c
@@ -699,7 +699,7 @@ errcode_t local_block_iterate3(ext2_fils
mark_extent_block(fs, (char*) inode.i_block);

extent_errout:
- local_ext2fs_extent_free(handle);
+ ext2fs_extent_free(handle);
ret |= BLOCK_ERROR | BLOCK_ABORT;
goto errout;
}

45 changes: 45 additions & 0 deletions ext4magic.nix
@@ -0,0 +1,45 @@
{ lib, stdenv, fetchurl, fetchpatch, file, libuuid, e2fsprogs, zlib, bzip2, ... }:
# This and glibc-fix.patch were copied from nixpkgs on 2024/03/16
# /pkgs/tools/filesystems/ext4magic/default.nix
# https://github.com/NixOS/nixpkgs/blob/master/pkgs/tools/filesystems/ext4magic/default.nix

stdenv.mkDerivation rec {
version = "0.3.2";
pname = "ext4magic";

src = fetchurl {
url = "mirror://sourceforge/ext4magic/${pname}-${version}.tar.gz";
sha256 = "8d9c6a594f212aecf4eb5410d277caeaea3adc03d35378257dfd017ef20ea115";
};

patches = [
(fetchpatch {
url = "https://sourceforge.net/p/ext4magic/tickets/10/attachment/ext4magic-0.3.2-i_dir_acl.patch";
sha256 = "1accydd8kigid68yir2fbihm3r3x8ws3iyznp25snkx41w6y6x8c";
})
./glibc-fix.patch
./encrypted-segfault-fix.patch
];

buildInputs = [ file libuuid e2fsprogs zlib bzip2 ];
installFlags = [ "PREFIX=$(out)" ];

meta = with lib; {
description = "Recover / undelete files from ext3 or ext4 partitions";
longDescription = ''
ext4magic can recover/undelete files from ext3 or ext4 partitions
by retrieving file-information from the filesystem journal.
If the information in the journal are sufficient, ext4magic can
recover the most file types, with original filename, owner and group,
file mode bits and also the old atime/mtime stamps.
It's much more effective and works much better than extundelete.
'';
homepage = "https://ext4magic.sourceforge.net/ext4magic_en.html";
license = licenses.gpl2;
platforms = platforms.linux;
maintainers = [ maintainers.rkoe ];
mainProgram = "ext4magic";
};
}
27 changes: 27 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions flake.nix
@@ -0,0 +1,21 @@
{
description = "a patched version of ext4magic that might not segfault on encrypted drives. patch from markusbauer@users.sourceforge.net https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=854497";
inputs = {
nixpkgs = { url = "github:NixOS/nixpkgs/nixos-unstable"; };
};

outputs = inputs@{ self, nixpkgs, ... }:
{
packages = let
pkgSystems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ];
packagesForEachSystem = f: nixpkgs.lib.genAttrs pkgSystems (system: f {
pkgs = import nixpkgs { inherit system; };
});
in packagesForEachSystem ({ pkgs }:
let
ext4magic = import ./ext4magic.nix pkgs; # needed to add `, ...` to the imported module's param list so it would be ok with the presence of other params like `system`
in {
default = ext4magic;
});
};
}
12 changes: 12 additions & 0 deletions glibc-fix.patch
@@ -0,0 +1,12 @@
diff --git a/src/recover.c b/src/recover.c
index 41b4aee..30b5d8f 100644
--- a/src/recover.c
+++ b/src/recover.c
@@ -24,6 +24,7 @@
#include <errno.h>
#include <fcntl.h>
#include <utime.h>
+#include <sys/sysmacros.h>

#ifndef O_LARGEFILE
#define O_LARGEFILE 0

0 comments on commit b286c29

Please sign in to comment.