From ba0c0d55ce5dc5d4c60e4d06346b39da96e0b63c Mon Sep 17 00:00:00 2001 From: Lumpiasty Date: Sat, 5 Sep 2026 22:46:39 +0200 Subject: [PATCH] Patch ntfsplus kernel module to support nowindows_names --- modules/default.nix | 1 + .../0001-fix-windows_names-option.patch | 13 +++++++ ...bad-character-check-by-windows_names.patch | 20 ++++++++++ modules/system/ntfsplus.nix | 13 +++++++ pkgs/ntfs/package.nix | 38 +++++++++++++++++++ 5 files changed, 85 insertions(+) create mode 100644 modules/system/ntfsplus-patches/0001-fix-windows_names-option.patch create mode 100644 modules/system/ntfsplus-patches/0002-gate-bad-character-check-by-windows_names.patch create mode 100644 modules/system/ntfsplus.nix create mode 100644 pkgs/ntfs/package.nix diff --git a/modules/default.nix b/modules/default.nix index f39db14..331e846 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -18,6 +18,7 @@ system/ipv6-mostly.nix system/nix.nix system/zfs.nix + system/ntfsplus.nix desktop/plasma.nix desktop/touchpad.nix diff --git a/modules/system/ntfsplus-patches/0001-fix-windows_names-option.patch b/modules/system/ntfsplus-patches/0001-fix-windows_names-option.patch new file mode 100644 index 0000000..1de620d --- /dev/null +++ b/modules/system/ntfsplus-patches/0001-fix-windows_names-option.patch @@ -0,0 +1,13 @@ +diff --git a/fs/ntfs/super.c b/fs/ntfs/super.c +--- a/fs/ntfs/super.c ++++ b/fs/ntfs/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), + diff --git a/modules/system/ntfsplus-patches/0002-gate-bad-character-check-by-windows_names.patch b/modules/system/ntfsplus-patches/0002-gate-bad-character-check-by-windows_names.patch new file mode 100644 index 0000000..e613e8e --- /dev/null +++ b/modules/system/ntfsplus-patches/0002-gate-bad-character-check-by-windows_names.patch @@ -0,0 +1,20 @@ +diff --git a/fs/ntfs/namei.c b/fs/ntfs/namei.c +--- a/fs/ntfs/namei.c ++++ b/fs/ntfs/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(' ') || + diff --git a/modules/system/ntfsplus.nix b/modules/system/ntfsplus.nix new file mode 100644 index 0000000..5a3043c --- /dev/null +++ b/modules/system/ntfsplus.nix @@ -0,0 +1,13 @@ +{ config, lib, pkgs, ... }: + + +{ + boot.extraModulePackages = [ + ((pkgs.callPackage ../../pkgs/ntfs/package.nix { kernel = config.boot.kernelPackages.kernel; }).overrideAttrs { + patches = [ + ./ntfsplus-patches/0001-fix-windows_names-option.patch + ./ntfsplus-patches/0002-gate-bad-character-check-by-windows_names.patch + ]; + }) + ]; +} diff --git a/pkgs/ntfs/package.nix b/pkgs/ntfs/package.nix new file mode 100644 index 0000000..cf6ed56 --- /dev/null +++ b/pkgs/ntfs/package.nix @@ -0,0 +1,38 @@ +{ pkgs +, lib +, kernel ? pkgs.linuxPackages_latest.kernel +}: + +pkgs.stdenv.mkDerivation { + pname = "ntfs-kernel-module"; + inherit (kernel) src version postPatch nativeBuildInputs; + + kernel_dev = kernel.dev; + kernelVersion = kernel.modDirVersion; + + modulePath = "fs/ntfs"; + + buildPhase = '' + BUILT_KERNEL=$kernel_dev/lib/modules/$kernelVersion/build + + cp $BUILT_KERNEL/Module.symvers . + cp $BUILT_KERNEL/.config . + cp $kernel_dev/vmlinux . + + make "-j$NIX_BUILD_CORES" modules_prepare + make "-j$NIX_BUILD_CORES" M=$modulePath modules + ''; + + installPhase = '' + make \ + INSTALL_MOD_PATH="$out" \ + XZ="xz -T$NIX_BUILD_CORES" \ + M="$modulePath" \ + modules_install + ''; + + meta = { + description = "NTFS kernel module"; + license = lib.licenses.gpl3; + }; +} \ No newline at end of file