use small patches instead of ntfsplus fork
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
From 8b5c5d23c1218a996a1d6780ca56853454813418 Mon Sep 17 00:00:00 2001
|
||||
From: Lumpiasty <arek.dzski@gmail.com>
|
||||
Date: Thu, 7 May 2026 01:50:05 +0200
|
||||
Subject: [PATCH 1/2] fix windows_names option
|
||||
|
||||
---
|
||||
super.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/super.c b/super.c
|
||||
index 875fb5a..49ad898 100644
|
||||
--- a/super.c
|
||||
+++ b/super.c
|
||||
@@ -91,7 +91,7 @@ static const struct fs_parameter_spec ntfs_parameters[] = {
|
||||
fsparam_flag("sys_immutable", Opt_sys_immutable),
|
||||
fsparam_flag("nohidden", Opt_nohidden),
|
||||
fsparam_flag("hide_dot_files", Opt_hide_dot_files),
|
||||
- fsparam_flag("windows_names", Opt_check_windows_names),
|
||||
+ fsparam_bool("windows_names", Opt_check_windows_names),
|
||||
fsparam_flag("acl", Opt_acl),
|
||||
fsparam_flag("discard", Opt_discard),
|
||||
fsparam_flag("sparse", Opt_sparse),
|
||||
--
|
||||
2.53.0
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
From 7fbf82056e26d99bfa4d5aab87ce287cd8c8cbef Mon Sep 17 00:00:00 2001
|
||||
From: Lumpiasty <arek.dzski@gmail.com>
|
||||
Date: Thu, 7 May 2026 01:56:33 +0200
|
||||
Subject: [PATCH 2/2] gate bad character check by windows_names
|
||||
|
||||
---
|
||||
namei.c | 6 +++---
|
||||
1 file changed, 3 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/namei.c b/namei.c
|
||||
index 9e937d1..7369943 100644
|
||||
--- a/namei.c
|
||||
+++ b/namei.c
|
||||
@@ -61,12 +61,12 @@ static int ntfs_check_bad_windows_name(struct ntfs_volume *vol,
|
||||
const __le16 *wc,
|
||||
unsigned int wc_len)
|
||||
{
|
||||
- if (ntfs_check_bad_char(wc, wc_len))
|
||||
- return -EINVAL;
|
||||
-
|
||||
if (!NVolCheckWindowsNames(vol))
|
||||
return 0;
|
||||
|
||||
+ if (ntfs_check_bad_char(wc, wc_len))
|
||||
+ return -EINVAL;
|
||||
+
|
||||
/* Check for trailing space or dot. */
|
||||
if (wc_len > 0 &&
|
||||
(wc[wc_len - 1] == cpu_to_le16(' ') ||
|
||||
--
|
||||
2.53.0
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
{ config, pkgs, lib, ntfsplus, ... }:
|
||||
|
||||
# Builds and loads the ntfsplus kernel driver (github:namjaejeon/linux-ntfs),
|
||||
# a maintained out-of-tree NTFS driver for Linux 6.1+.
|
||||
#
|
||||
# The upstream driver is used as-is, with two local patches applied on top
|
||||
# (see ntfsplus-patches/). This avoids maintaining a fork that would need
|
||||
# rebasing on every upstream update — patches are plain files that apply
|
||||
# cleanly regardless of upstream churn.
|
||||
#
|
||||
# The ntfsplus flake's nixosModule is NOT used directly. It builds the kernel
|
||||
# module as a `let` binding inside the module closure — not exposed as a
|
||||
# package in its flake outputs — so there is nothing in pkgs to override.
|
||||
# Replicating the module here is the only way to substitute a patched source.
|
||||
#
|
||||
# The ntfsplus flake (github:cmspam/ntfsplus-flake) is reused only for:
|
||||
# - its linux-ntfs source input (ntfsplus.inputs.linux-ntfs)
|
||||
# - its bundled Makefile (${ntfsplus}/Makefile)
|
||||
# The flake ships its own Makefile because the upstream repo's Makefile
|
||||
# has an ifneq KERNELRELEASE guard that breaks the out-of-tree nix build.
|
||||
#
|
||||
# The derivation is built inside this module (not via an overlay) so that
|
||||
# config.boot.kernelPackages.kernel resolves to whatever kernel the host
|
||||
# declares, with no extra indirection or per-host maintenance.
|
||||
#
|
||||
# ntfsplus is passed in via specialArgs in lib/mkNixosSystem.nix.
|
||||
|
||||
let
|
||||
cfg = config.services.ntfsplus;
|
||||
|
||||
patchedSrc = pkgs.applyPatches {
|
||||
name = "linux-ntfs-patched";
|
||||
src = ntfsplus.inputs.linux-ntfs;
|
||||
patches = [
|
||||
# fsparam_flag → fsparam_bool so windows_names=0/1 is accepted as a
|
||||
# mount option rather than being treated as a bare flag.
|
||||
./ntfsplus-patches/0001-fix-windows_names-option.patch
|
||||
# Gate the bad-character check behind NVolCheckWindowsNames so that
|
||||
# the check only runs when windows_names is actually enabled.
|
||||
./ntfsplus-patches/0002-gate-bad-character-check-by-windows_names.patch
|
||||
];
|
||||
};
|
||||
|
||||
ntfsplus-mod = pkgs.stdenv.mkDerivation {
|
||||
pname = "ntfsplus-module";
|
||||
version = ntfsplus.inputs.linux-ntfs.shortRev or ntfsplus.inputs.linux-ntfs.rev;
|
||||
src = patchedSrc;
|
||||
nativeBuildInputs = config.boot.kernelPackages.kernel.moduleBuildDependencies;
|
||||
preBuild = "cp ${ntfsplus}/Makefile Makefile";
|
||||
makeFlags = [
|
||||
"KDIR=${config.boot.kernelPackages.kernel.dev}/lib/modules/${config.boot.kernelPackages.kernel.modDirVersion}/build"
|
||||
"KVERSION=${config.boot.kernelPackages.kernel.modDirVersion}"
|
||||
"CONFIG_NTFS_FS_POSIX_ACL=y"
|
||||
];
|
||||
installPhase = ''
|
||||
mkdir -p $out/lib/modules/${config.boot.kernelPackages.kernel.modDirVersion}/extra
|
||||
cp ntfs.ko $out/lib/modules/${config.boot.kernelPackages.kernel.modDirVersion}/extra/
|
||||
'';
|
||||
};
|
||||
in
|
||||
{
|
||||
options.services.ntfsplus = {
|
||||
enable = lib.mkEnableOption "ntfsplus kernel driver and utilities";
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
boot.extraModulePackages = [ ntfsplus-mod ];
|
||||
boot.kernelModules = [ "ntfs" ];
|
||||
boot.extraModprobeConfig = ''
|
||||
alias fs-ntfs ntfs
|
||||
alias ntfsplus ntfs
|
||||
'';
|
||||
services.udev.extraRules = ''
|
||||
SUBSYSTEM=="block", ENV{ID_FS_TYPE}=="ntfs", ENV{ID_FS_TYPE}="ntfs"
|
||||
'';
|
||||
environment.systemPackages = [ pkgs.ntfsprogs-plus ];
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user