antfs: kernel mode driver based on NTFS-3G

This commit is contained in:
coolsnowwolf 2020-02-01 19:50:46 +08:00
parent e09686f69e
commit e286695f1c
2 changed files with 119 additions and 0 deletions

43
kernel/antfs/Makefile Normal file
View File

@ -0,0 +1,43 @@
include $(TOPDIR)/rules.mk
include $(INCLUDE_DIR)/kernel.mk
PKG_NAME:=antfs
PKG_RELEASE:=1
PKG_SOURCE_URL:=https://github.com/Sembedded/antfs.git
PKG_SOURCE_PROTO:=git
PKG_SOURCE_DATE:=2018-08-14
PKG_SOURCE_VERSION:=002407a1b4f1bc9ec19fb07a4c01fc5348d216a6
PKG_MIRROR_HASH:=d1c44b2be92531c2caa4fa00b620591f95104436920640e94861f8207d6e9082
PKG_LICENSE:=GPL-2.0-only
PKG_LICENSE_FILES:=LICENSE
include $(INCLUDE_DIR)/package.mk
define KernelPackage/fs-antfs
SUBMENU:=Filesystems
TITLE:=AVM NTFS Read/Write Driver
FILES:=$(PKG_BUILD_DIR)/antfs.ko
AUTOLOAD:=$(call AutoLoad,30,antfs,1)
DEPENDS:=+kmod-nls-base
endef
define KernelPackage/fs-antfs/description
Kernel module for NTFS Filesytem
endef
MAKE_OPTS:= \
ARCH="$(LINUX_KARCH)" \
CROSS_COMPILE="$(TARGET_CROSS)" \
M="$(PKG_BUILD_DIR)"
define Build/Compile
$(MAKE) -C "$(LINUX_DIR)" \
$(MAKE_OPTS) \
CONFIG_ANTFS_FS=m \
CONFIG_ANTFS_SYMLINKS=y \
modules
endef
$(eval $(call KernelPackage,fs-antfs))

View File

@ -0,0 +1,76 @@
--- a/dir.c
+++ b/dir.c
@@ -1133,9 +1133,12 @@ static int antfs_setattr(struct dentry *
}
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 8, 0)
inode->i_mtime = inode->i_ctime = CURRENT_TIME_SEC;
-#else
+#elif LINUX_VERSION_CODE < KERNEL_VERSION(4, 18, 0)
ktime_get_real_ts(&inode->i_mtime);
ktime_get_real_ts(&inode->i_ctime);
+#else
+ ktime_get_real_ts64(&inode->i_mtime);
+ ktime_get_real_ts64(&inode->i_ctime);
#endif
if (inode_needs_sync(inode)) {
sync_mapping_buffers(inode->i_mapping);
--- a/include/ntfstime.h
+++ b/include/ntfstime.h
@@ -47,9 +47,15 @@
*
* Return: A Unix time (number of seconds since 1970, and nanoseconds)
*/
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 18, 0)
static inline struct timespec ntfs2timespec(sle64 ntfstime)
{
struct timespec spec;
+#else
+static inline struct timespec64 ntfs2timespec(sle64 ntfstime)
+{
+ struct timespec64 spec;
+#endif
uint64_t cputime;
cputime = sle64_to_cpu(ntfstime) - NTFS_TIME_OFFSET;
@@ -79,7 +85,11 @@ static inline struct timespec ntfs2times
*
* Return: An NTFS time (100ns units since Jan 1601)
*/
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 18, 0)
static inline sle64 timespec2ntfs(struct timespec spec)
+#else
+static inline sle64 timespec2ntfs(struct timespec64 spec)
+#endif
{
s64 units;
@@ -94,10 +104,15 @@ static inline sle64 timespec2ntfs(struct
static inline sle64 ntfs_current_time(void)
{
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 18, 0)
struct timespec ts;
getnstimeofday(&ts);
+#else
+ struct timespec64 ts;
+ getnstimeofday64(&ts);
+#endif
return timespec2ntfs(ts);
}
--- a/inode.c
+++ b/inode.c
@@ -435,7 +435,11 @@ int antfs_inode_init(struct inode *inode
inode->i_ino ==
(unsigned long)FILE_ROOT))) {
struct antfs_sb_info *sbi = ANTFS_SB(inode->i_sb);
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 18, 0)
struct timespec ts;
+#else
+ struct timespec64 ts;
+#endif
/* Init a base mft record ("regular" inode):
* this has to be done in context of either: